selenium-standalone
Advanced tools
Comparing version 2.44.0-3 to 2.44.0-4
@@ -9,3 +9,4 @@ var path = require('path'); | ||
path: path.join(__dirname, '.selenium', version, 'server.jar'), | ||
v: version | ||
v: version, | ||
hub: 'http://localhost:4444/wd/hub/status' | ||
}, | ||
@@ -12,0 +13,0 @@ chromeDr: { |
@@ -0,1 +1,5 @@ | ||
# 2.44.0-4 (2015-01-02) | ||
* programmatic API now exposes a callback to inform when selenium has started | ||
# 2.44.0-3 (2015-01-02) | ||
@@ -2,0 +6,0 @@ |
37
index.js
@@ -6,2 +6,3 @@ var spawn = require('child_process').spawn; | ||
var path = require( 'path' ); | ||
var request = require('request').defaults({json: true}); | ||
@@ -14,2 +15,5 @@ module.exports = standalone; | ||
var RETRIES = 60; | ||
var RETRY_INTERVAL = 1000; | ||
/** | ||
@@ -20,5 +24,7 @@ * Get a standalone selenium server running with | ||
* @param {string[]} seleniumArgs=[] | ||
* @param {Function} callback=function() {} | ||
* @return {ChildProcess} | ||
*/ | ||
function standalone(spawnOptions, seleniumArgs) { | ||
function standalone(spawnOptions, seleniumArgs, callback) { | ||
if (!registered) { | ||
@@ -48,5 +54,34 @@ killEvents.forEach(listenAndKill); | ||
checkStarted(function(err) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
callback(null, selenium); | ||
} | ||
}); | ||
return selenium; | ||
} | ||
function checkStarted(callback) { | ||
var retries = 0; | ||
var started = function () { | ||
if (++retries > RETRIES) { | ||
return callback('Unable to connect to selenium'); | ||
} | ||
request(conf.selenium.hub, function (err, resp) { | ||
if (resp && resp.statusCode === 200) { | ||
callback(null); | ||
} else { | ||
setTimeout(started, RETRY_INTERVAL); | ||
} | ||
}); | ||
}; | ||
started(); | ||
} | ||
function kill() { | ||
@@ -53,0 +88,0 @@ var process; |
{ | ||
"name": "selenium-standalone", | ||
"version": "2.44.0-3", | ||
"version": "2.44.0-4", | ||
"description": "installs a `start-selenium` command line to start a standalone selenium server with chrome-driver", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"mkdirp": "^0.5.0", | ||
"request": "^2.47.0", | ||
"request": "^2.51.0", | ||
"rimraf": "^2.2.8", | ||
@@ -29,0 +29,0 @@ "unzip": "^0.1.11", |
@@ -69,12 +69,13 @@ # selenium-standalone | ||
var server = selenium(spawnOptions, seleniumArgs); | ||
// or, var server = selenium(); | ||
// returns ChildProcess instance | ||
// http://nodejs.org/api/child_process.html#child_process_class_childprocess | ||
selenium(spawnOptions, seleniumArgs, function(err, server) { | ||
// or, var server = selenium(); | ||
// returns ChildProcess instance | ||
// http://nodejs.org/api/child_process.html#child_process_class_childprocess | ||
// spawnOptions defaults to `{ stdio: 'inherit' }` | ||
// seleniumArgs defaults to `[]` | ||
// spawnOptions defaults to `{ stdio: 'inherit' }` | ||
// seleniumArgs defaults to `[]` | ||
server.stdout.on('data', function(output) { | ||
console.log(output); | ||
server.stdout.on('data', function(output) { | ||
console.log(output); | ||
}); | ||
}); | ||
@@ -81,0 +82,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13733
255
96
Updatedrequest@^2.51.0