lib/webdriver.js

Maintainability

87.38

Lines of code

57

Created with Raphaël 2.1.002550751002014-11-28

2014-11-28
Maintainability: 87.38

Created with Raphaël 2.1.00153045602014-11-28

2014-11-28
Lines of Code: 57

Difficulty

10.38

Estimated Errors

0.08

Function weight

By Complexity

Created with Raphaël 2.1.0WebDriver1

By SLOC

Created with Raphaël 2.1.0WebDriver4
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
'use strict';
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, events) {
35
  this.events = events;
36
  this.opts = opts;
37
};
38
 
39
/**
40
 * Webdriver base class
41
 *
42
 * @namespace Internal
43
 * @module DalekJS
44
 * @class Webdriver
45
 */
46
 
47
WebDriver.prototype = {
48
 
49
  /**
50
   * Local options, used to store data
51
   * like the current sessionId or similar
52
   */
53
 
54
  options: {},
55
 
56
  /**
57
   * Checks if we have a valid webdriver session
58
   *
59
   * @method hasSession
60
   * @return {bool} Is valid session
61
   */
62
 
63
  hasSession: function () {
64
    return !!this.options.sessionId;
65
  },
66
 
67
  /**
68
   * Closes the current webdriver session
69
   *
70
   * @method hasSession
71
   * @chainable
72
   */
73
 
74
  closeSession: function () {
75
    delete this.options.sessionId;
76
    return this;
77
  }
78
};
79
 
80
// export the module
81
module.exports = WebDriver;