Skip to content

Instantly share code, notes, and snippets.

@Izhaki
Last active December 11, 2018 11:46
Show Gist options
  • Save Izhaki/19b87516636290cc747d43a9a1022d9e to your computer and use it in GitHub Desktop.
Save Izhaki/19b87516636290cc747d43a9a1022d9e to your computer and use it in GitHub Desktop.
A small script to update webdriver if needed prior to running protractor.
const isWebdriverUpToDate = () => {
const fs = require('fs');
const path = require('path');
const SeleniumConfig = require('webdriver-manager/built/lib/config').Config;
const updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
return fs.existsSync(updateJson);
};
const updateWebdriver = () => {
const { spawnSync } = require('child_process');
spawnSync('yarn', ['webdriver:update']);
};
if (!isWebdriverUpToDate()) {
console.log('Webdriver updating...');
updateWebdriver();
console.log('Webdriver updated.');
} else {
console.log('Webdriver up to date.');
}
@Izhaki
Copy link
Author

Izhaki commented Dec 11, 2018

In use:

{
  "scripts": {
    "webdriver:update": "webdriver-manager update --versions.chrome=2.40",
    "webdriver:upsert": "node ./scripts/tasks/upsertWebdriver.js",
    "cucumber": "npm run webdriver:upsert && protractor test/protractor_conf_cucumber.js --baseUrl http://localhost:3000/",
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment