-
Notifications
You must be signed in to change notification settings - Fork 2
/
wd.js
34 lines (30 loc) · 828 Bytes
/
wd.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
'use strict';
var async = require('async');
var url = require('url');
var wd = require('wd');
module.exports = function(seleniumUrl) {
return {
clients: {},
create: function(capabilities, callback) {
var client = wd.remote(url.parse(seleniumUrl));
client.init(capabilities, function(error, sessionId) {
this.clients[sessionId] = client;
if (typeof callback === 'function') {
callback(error, client, {
wd: wd
});
}
}.bind(this));
},
end: function(callback) {
var client;
var quitFunctions = [];
for (var id in this.clients) {
client = this.clients[id];
delete this.clients[id];
quitFunctions.push(client.quit.bind(client));
}
async.series(quitFunctions, callback);
}
};
};