Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function(error) {
if (error) throw new Error(error); // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
require('fs').stat(SELENIUM_PATH, function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function (error) {
if (error) throw new Error(error); // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
require('fs').stat(`${BINPATH}selenium.jar`, (err, stat) => { // got it?
if (err || !stat || stat.size < 1) {
console.log("???", `${BINPATH}selenium.jar`, stat, err);
require('selenium-download').ensure(BINPATH, (error) => {
console.log("???", "error:", error);
if (error) throw new Error(error); // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
var fs = require('fs');
var mkdirp = require('mkdirp');
var path = require('path');
var selenium = require('selenium-download');
// Download Selenium server and Chromedriver
selenium.ensure(__dirname, function(error) {
if (error) {
console.error(error.stack);
} else {
// Rename so that we don't need to update paths in project configs
var oldSeleniumPath = path.join(__dirname, 'selenium.jar');
var newSeleniumPath = path.join(__dirname, 'selenium-server.jar');
fs.rename(oldSeleniumPath, newSeleniumPath, function(error) {
if (error) console.log(error);
return;
});
mkdirp(path.join(__dirname, 'drivers'));
var oldChromedriverPath = path.join(__dirname, 'chromedriver');
var newChromedriverPath = path.join(__dirname, 'drivers', 'chromedriver');
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function (error) {
if (error) throw new Error(error); // no point continuing so exit!
console.log('✔ Selenium & chrome driver downloaded to:', BINPATH);
});
}
});
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function(error) {
if (error) console.log(error); // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // eslint-disable-line
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function (error) { // eslint-disable-line
if (error) throw new Error(error) // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH)
})
}
})
const selenium = require('selenium-download');
const execSync = require('child_process').execSync;
const get = require('http').get;
selenium.ensure('./bin', function(error) {
if (error) {
throw new Error(error);
} else {
return start();
}
});
function start () {
get('http://localhost:4444/wd/hub/status', function (res) {
if (res && res.statusCode === 200){
res.on("data", function(chunk) {
console.log('Selenium is running:',
JSON.stringify(JSON.parse(chunk), null, 2));
return; // res.end is automatically called.
});
}
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function (error) {
if (error) throw new Error(error); // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH);
});
}
});
const selenium = require('selenium-download');
const path = require('path');
selenium.ensure(path.join(__dirname, 'bin'), () => {
process.exit(0);
});