Skip to content

Instantly share code, notes, and snippets.

@dok
Created June 30, 2017 17:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dok/6f8dbac175947284c975dc71114ad9e8 to your computer and use it in GitHub Desktop.
Save dok/6f8dbac175947284c975dc71114ad9e8 to your computer and use it in GitHub Desktop.
install, start, selenium-standalone with geckodriver
// npm install selenium-standalone@6.5.0
var selenium = require('selenium-standalone');
var webdriverio = require('webdriverio');
const version = '3.4.0';
const drivers = { chrome:
{ version: '2.30',
arch: 'x64',
baseURL: 'https://chromedriver.storage.googleapis.com' },
ie:
{ version: '3.4.0',
arch: 'x64',
baseURL: 'https://selenium-release.storage.googleapis.com' },
firefox:
{ version: '0.16.1',
arch: 'x64',
baseURL: 'https://github.com/mozilla/geckodriver/releases/download' },
edge: { version: '15063' } };
const startOptions = {
baseURL: 'https://selenium-release.storage.googleapis.com',
version: version,
drivers: drivers,
seleniumArgs: [],
spawnOptions: { stdio: 'inherit' },
logger: console.log,
javaPath: '/usr/bin/java'
};
selenium.install({
version: version,
drivers: drivers
}, (err) => {
if(err) {
console.log('info', `ERROR INSTALLING SELENIUM-STANDALONE: ${err}`);
}
console.log('installing');
selenium.start(startOptions, (err, child) => {
if(err) {
console.log('info', `ERROR STARTING SELENIUM-STANDALONE: ${err}`);
}
console.log(child);
// child.stderr.on('data', function(data){
// console.log('info', `${data}`);
// });
console.log('info', `SUCCESSFULLY STARTED SELENIUM-STANDALONE ${child}`);
var options = {
"host": "127.0.0.1",
"port": 4444,
"waitforTimeout": 5000,
"connectionRetryCount": 10,
"connectionRetryTimeout": 30000,
"desiredCapabilities": {
"browserName": "firefox",
},
logLevel: 'debug',
};
var client = webdriverio.remote(options);
client.init()
.url('http://example.com')
.pause(1000)
.end()
.then(process.exit)
.catch(function(e) {
console.log(e);
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment