1 | /*!
|
2 | *
|
3 | * Copyright (c) 2013 Sebastian Golasch
|
4 | *
|
5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
6 | * copy of this software and associated documentation files (the "Software"),
|
7 | * to deal in the Software without restriction, including without limitation
|
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
9 | * and/or sell copies of the Software, and to permit persons to whom the
|
10 | * Software is furnished to do so, subject to the following conditions:
|
11 | *
|
12 | * The above copyright notice and this permission notice shall be included
|
13 | * in all copies or substantial portions of the Software.
|
14 | *
|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
21 | * DEALINGS IN THE SOFTWARE.
|
22 | *
|
23 | */
|
24 |
|
25 | ;
|
26 |
|
27 | /**
|
28 | * Stores the injected options as an object property
|
29 | *
|
30 | * @param {object} opts Webdriver options
|
31 | * @constructor
|
32 | */
|
33 |
|
34 | var WebDriver = function (opts) {
|
35 | this.opts = opts;
|
36 | };
|
37 |
|
38 | /**
|
39 | * Webdriver base class
|
40 | *
|
41 | * @namespace Internal
|
42 | * @module DalekJS
|
43 | * @class Webdriver
|
44 | */
|
45 |
|
46 | WebDriver.prototype = {
|
47 |
|
48 | /**
|
49 | * Local options, used to store data
|
50 | * like the current sessionId or similar
|
51 | */
|
52 |
|
53 | options: {},
|
54 |
|
55 | /**
|
56 | * Checks if we have a valid webdriver session
|
57 | *
|
58 | * @method hasSession
|
59 | * @return {bool} Is valid session
|
60 | */
|
61 |
|
62 | hasSession: function () {
|
63 | return !!this.options.sessionId;
|
64 | },
|
65 |
|
66 | /**
|
67 | * Closes the current webdriver session
|
68 | *
|
69 | * @method hasSession
|
70 | * @chainable
|
71 | */
|
72 |
|
73 | closeSession: function () {
|
74 | delete this.options.sessionId;
|
75 | return this;
|
76 | }
|
77 | };
|
78 |
|
79 | // export the module
|
80 | module.exports = WebDriver;
|