forked from webdriverio/webdriverio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (58 loc) · 2.06 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
62
63
64
65
66
67
68
69
70
/**
* webdriverio
* https://github.com/Camme/webdriverio
*
* 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]>
* Vincent Voyer <[email protected]>
*/
var WebdriverIO = require('./lib/webdriverio'),
Multibrowser = require('./lib/multibrowser'),
ErrorHandler = require('./lib/utils/ErrorHandler'),
package = require('./package.json'),
path = require('path'),
fs = require('fs');
// expose version number
module.exports.version = package.version;
// expose error handler
module.exports.ErrorHandler = ErrorHandler;
// use the chained API reference to add static methods
var remote = module.exports.remote = function remote(options, modifier) {
options = options || {};
/**
* initialise monad
*/
var wdio = WebdriverIO(options, modifier);
/**
* build prototype: commands
*/
['protocol', 'commands'].forEach(function(commandType) {
var dir = path.join(__dirname, 'lib', commandType),
files = fs.readdirSync(dir);
files.forEach(function(filename) {
var commandName = filename.slice(0, -3);
wdio.lift(commandName, require(path.join(dir, filename)));
});
});
var prototype = wdio();
prototype.defer.resolve();
return prototype;
};
module.exports.multiremote = function multiremote(options) {
var multibrowser = new Multibrowser();
Object.keys(options).forEach(function(browserName) {
multibrowser.addInstance(
browserName,
remote(options[browserName], multibrowser.getInstanceModifier())
);
});
return remote(options, multibrowser.getModifier());
};