forked from webdriverio/selenium-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
54 lines (42 loc) · 1.24 KB
/
index.js
File metadata and controls
54 lines (42 loc) · 1.24 KB
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
var spawn = require('child_process').spawn;
var conf = require( './conf.js' );
var async = require( 'async' );
var whereis = require( 'whereis' );
var path = require( 'path' );
module.exports = standalone;
var processes = [];
/**
* Get a standalone selenium server running with
* chromedriver available
* @param {Object} spawnOptions={ stdio: 'inherit' }
* @param {string[]} seleniumArgs=[]
* @return {ChildProcess}
*/
function standalone(spawnOptions, seleniumArgs) {
spawnOptions = spawnOptions || { stdio: 'inherit' };
seleniumArgs = seleniumArgs || [];
var args = [
'-jar',
conf.selenium.path,
'-Dwebdriver.chrome.driver=' + conf.chromeDr.path
];
if (process.platform === 'win32') {
args.push('-Dwebdriver.ie.driver=' + conf.ieDr.path);
}
args = args.concat(seleniumArgs);
var selenium = spawn('java', args, spawnOptions);
processes.push(selenium);
return selenium;
}
function kill() {
var process;
while (process = processes.shift()) {
process.kill('SIGTERM');
}
}
['exit', 'SIGTERM', 'SIGINT'].forEach(function listenAndKill(evName) {
process.on(evName, kill);
});
// backward compat with original programmatic PR
// https://github.com/vvo/selenium-standalone/pull/4
standalone.start = standalone;