-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
executable file
·67 lines (55 loc) · 1.42 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
var webdriverio = require('webdriverio');
var env = process.env;
var buildOptions = function(args){
var options = args.config, attr;
for(attr in args){
if(!options[attr]){
options[attr] = args[attr];
}
}
delete options['config'];
delete options['base'];
return options;
};
var SeleniumBrowser = function (baseBrowserDecorator, args, logger) {
var options = buildOptions(args),
log = logger.create('webdriverio'),
self = this,
browserRunning = false;
baseBrowserDecorator(this);
this.name = 'selenium for ' + args.browserName;
this._start = function (url) {
log.info('Selenium browser started at http://' + options.host+ ':' + options.port + options.path);
self.browser = webdriverio
.remote(options)
.init()
.url(url)
.then(function(){
browserRunning = true;
});
};
this.on('kill', function(done){
if(!browserRunning){
process.nextTick(done);
}
self.browser
.end()
.then(function(){
log.info('Browser closed');
self._done();
done();
});
});
};
SeleniumBrowser.prototype = {
name: 'Selenium',
DEFAULT_CMD: {
linux: require('webdriverio').path,
darwin: require('webdriverio').path,
win32: require('webdriverio').path
}
};
SeleniumBrowser.$inject = ['baseBrowserDecorator', 'args', 'logger'];
module.exports = {
'launcher:Selenium': ['type', SeleniumBrowser]
};