forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (54 loc) · 1.69 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* webdriverjs
* https://github.com/Camme/webdriverjs
*
* A WebDriver module for nodejs. Either use the super easy help commands or use the base
* Webdriver wire protocol commands. Its totally inspired by jellyfishs webdriver, but the
* goal is to make all the webdriver protocol items available, as near the original as possible.
*
* Copyright (c) 2013 Camilo Tapia <[email protected]>
* Licensed under the MIT license.
*
* Contributors:
* Dan Jenkins <[email protected]>
* Christian Bromann <[email protected]>
*/
var singletonInstance = null,
WebdriverJS = require('./lib/webdriverjs');
var oneInstance = null;
// expose the man function
// if we need a singleton, we provide the option here
exports.remote = function(options) {
// make sure we have a default options if none are provided
options = options || {};
if (options.singleton) {
if (!singletonInstance) {
singletonInstance = new WebdriverJS(options);
oneInstance = singletonInstance;
}
return singletonInstance;
} else {
var newInstance = new WebdriverJS(options);
oneInstance = newInstance;
return newInstance;
}
};
exports.endAll = function(callback) {
var client = new WebdriverJS({logLevel:'silent'});
client.endAll(callback);
}
exports.sessions = function(callback) {
var client = new WebdriverJS({logLevel:'silent'});
var sessions = null;
var error = null
client.sessions(function(err, result) {
if (!err) {
sessions = result.value;
}
else {
error = err;
}
}).end(function() {
callback(error, sessions)
});
}