Last active
March 28, 2018 01:04
-
-
Save prantlf/a3c2a267ed48f4f779888189c269d349 to your computer and use it in GitHub Desktop.
Script to reproduce the chromedriver process not stopping for https://github.com/vvo/selenium-standalone/issues/351
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const selenium = require('selenium-standalone') | |
const webdriverio = require('webdriverio') | |
const configuration = { | |
version: '3.8.1', | |
baseURL: 'http://selenium-release.storage.googleapis.com', | |
drivers: { | |
chrome: { | |
version: '2.37', | |
arch: process.arch, | |
baseURL: 'https://chromedriver.storage.googleapis.com' | |
} | |
} | |
} | |
let child | |
let client | |
install() | |
.then(start) | |
// commenting out the following two lines does not leave the chromedriver | |
// process running after stopping the selenium process | |
.then(initialize) | |
.then(uninitialize) | |
.then(stop) | |
function install () { | |
return new Promise(function (resolve, reject) { | |
console.log('Installing Selenium server.') | |
selenium.install(configuration, function (error) { | |
if (error) { | |
reject(error) | |
} else { | |
console.log('Installed Selenium server.') | |
resolve() | |
} | |
}) | |
}) | |
} | |
function start () { | |
return new Promise(function (resolve, reject) { | |
console.log('Starting Selenium server.') | |
selenium.start(configuration, function (error, selenium) { | |
if (error) { | |
reject(error) | |
} else { | |
child = selenium | |
console.log('Started Selenium server: ' + child.pid + '.') | |
resolve() | |
} | |
}) | |
}) | |
} | |
function initialize () { | |
console.log('Connecting to the browser driver.') | |
client = webdriverio.remote({ | |
desiredCapabilities: { | |
browserName: 'chrome', | |
chromeOptions: { | |
args: ['--headless'] | |
} | |
} | |
}) | |
return client.init() | |
} | |
function uninitialize () { | |
console.log('Disconnecting from the browser driver.') | |
return client.end() | |
// removing the comment from the following line and letting it perform | |
// stops the chromedriver process too after stopping the selenium process | |
// .pause(100) | |
} | |
function stop () { | |
console.log('Stopping Selenium server: ' + child.pid + '.') | |
child.kill() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ DEBUG=selenium-standalone:* node selenium.test.js.txt | |
selenium-standalone:env-details Platform: linux 4.15.0-12-generic +0ms | |
selenium-standalone:env-details Architecture: x64 +2ms | |
selenium-standalone:env-details Node.js: v8.10.0 +0ms | |
selenium-standalone:env-details CWD: /home/user/test/test +0ms | |
selenium-standalone:env-details Module Path: /home/user/test/node_modules/selenium-standalone/lib +0ms | |
selenium-standalone:env-details Package Version: 6.13.0 +1ms | |
Installing Selenium server. | |
selenium-standalone:install Install API called with { version: '3.8.1', | |
baseURL: 'http://selenium-release.storage.googleapis.com', | |
drivers: | |
{ chrome: | |
{ version: '2.37', | |
arch: 'x64', | |
baseURL: 'https://chromedriver.storage.googleapis.com' } } } +0ms | |
selenium-standalone:install setDriverFilePermissions /home/user/test/node_modules/selenium-standalone/.selenium/chromedriver/2.37-x64-chromedriver +308ms | |
selenium-standalone:install /home/user/test/node_modules/selenium-standalone/.selenium/chromedriver/2.37-x64-chromedriver stats : Stats { | |
selenium-standalone:install dev: 2050, | |
selenium-standalone:install mode: 33261, | |
selenium-standalone:install nlink: 1, | |
selenium-standalone:install uid: 1000, | |
selenium-standalone:install gid: 1000, | |
selenium-standalone:install rdev: 0, | |
selenium-standalone:install blksize: 4096, | |
selenium-standalone:install ino: 12644415, | |
selenium-standalone:install size: 7874704, | |
selenium-standalone:install blocks: 15384, | |
selenium-standalone:install atimeMs: 1521628499027.0286, | |
selenium-standalone:install mtimeMs: 1521628499107.028, | |
selenium-standalone:install ctimeMs: 1521631468523.9392, | |
selenium-standalone:install birthtimeMs: 1521631468523.9392, | |
selenium-standalone:install atime: 2018-03-21T10:34:59.027Z, | |
selenium-standalone:install mtime: 2018-03-21T10:34:59.107Z, | |
selenium-standalone:install ctime: 2018-03-21T11:24:28.524Z, | |
selenium-standalone:install birthtime: 2018-03-21T11:24:28.524Z } +1ms | |
Installed Selenium server. | |
Starting Selenium server. | |
selenium-standalone:start Start API called with { version: '3.8.1', | |
baseURL: 'http://selenium-release.storage.googleapis.com', | |
drivers: | |
{ chrome: | |
{ version: '2.37', | |
arch: 'x64', | |
baseURL: 'https://chromedriver.storage.googleapis.com' } }, | |
progressCb: [Function: noop] } +0ms | |
selenium-standalone:start Spawning Selenium Server process /usr/bin/java [ '-Dwebdriver.chrome.driver=/home/user/test/node_modules/selenium-standalone/.selenium/chromedriver/2.37-x64-chromedriver', | |
'-jar', | |
'/home/user/test/node_modules/selenium-standalone/.selenium/selenium-server/3.8.1-server.jar' ] +5ms | |
Started Selenium server: 9579. | |
Connecting to the browser driver. | |
Disconnecting from the browser driver. | |
Stopping Selenium server: 9579. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment