Skip to content

Commit

Permalink
Updates selenium webdriver update script
Browse files Browse the repository at this point in the history
OKTA-324375
<<<Jenkins Check-In of Tested SHA: 30f12eb for [email protected]>>>
Artifact: okta-angular
  • Loading branch information
vijetmahabaleshwar-okta authored and eng-prod-CI-bot-okta committed Mar 6, 2021
1 parent f3abc0b commit bef8c5a
Show file tree
Hide file tree
Showing 4 changed files with 1,224 additions and 1,121 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts/update-se-drivers.js
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0",
"angular2-template-loader": "0.6.2",
"axios": "^0.21.0",
"chalk": "2.4.2",
"codelyzer": "^6.0.1",
"core-js": "3.1.3",
Expand Down
42 changes: 42 additions & 0 deletions scripts/update-se-drivers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const axios = require('axios');
const { execSync, execFileSync } = require('child_process');

function getOS() {
let os = process.platform;
if (os === 'darwin') {
os = 'MacOS';
} else if (os === 'win32' || os === 'win64') {
os = 'Windows';
} else if (os === 'linux') {
os = 'Linux';
}
return os;
}

const os = getOS();
console.log(`Operating System - ${os}`);

let chromeVersion;
if (os === 'MacOS') {
const chromeVersionString = execSync('/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version').toString();
// Get the major and minor version of the chrome version using regex (1 or more digits followed by a dot followed by 1 or more digits)
const matchIndex = 0;
chromeVersion = chromeVersionString.match(/(\d+(\.\d+)?)/)[matchIndex];
} else {
chromeVersion = execSync('google-chrome --product-version').toString();
}

const chromeMajorVersion = chromeVersion.split('.')[0];
console.log(`Chrome Major Version - ${chromeMajorVersion}`);

const chromeDriverUrl = `https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${chromeMajorVersion}`;

axios.get(chromeDriverUrl).then((response) => {
const chromeDriverVersion = response.data;
console.log(`Chrome Driver Version - ${chromeDriverVersion}`);

execFileSync(`${__dirname}/../node_modules/protractor/bin/webdriver-manager`, ["update", "--versions.chrome", chromeDriverVersion, "--gecko", "false", "--versions.standalone", "latest"]);
console.log('Webdriver was updated');
}).catch((err) => {
console.log(err);
});
Loading

0 comments on commit bef8c5a

Please sign in to comment.