Skip to content

Commit

Permalink
patch webdriver (see angular/webdriver-manager#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
olzraiti committed Nov 2, 2023
1 parent 40711e9 commit 514c93a
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 0 deletions.
216 changes: 216 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"types": "lib/index.d.ts",
"scripts": {
"prepare": "self-import",
"postinstall": "patch-package",
"start": "npx webpack serve",
"build:lib": "rimraf lib && NODE_ENV=production tsc -p tsconfig.lib.json && copyfiles -f src/styles.css lib/",
"build:dist": "rimraf dist && NODE_ENV=production webpack --config webpack.config.dist.js && rimraf dist/styles.js",
Expand Down Expand Up @@ -46,6 +47,7 @@
"jasmine-spec-reporter": "^4.2.1",
"json-loader": "^0.5.7",
"mini-css-extract-plugin": "^1.6.2",
"patch-package": "^8.0.0",
"protractor": "^7.0.0",
"protractor-console-plugin": "^0.1.1",
"rimraf": "2.5.4",
Expand Down
73 changes: 73 additions & 0 deletions patches/protractor++webdriver-manager+12.1.7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff --git a/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/.chrome_xml.js.swp b/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/.chrome_xml.js.swp
new file mode 100644
index 0000000..9d62614
Binary files /dev/null and b/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/.chrome_xml.js.swp differ
diff --git a/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js b/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
index 5fb5eaa..ea6a36d 100644
--- a/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
+++ b/node_modules/protractor/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
@@ -55,12 +55,41 @@ class ChromeXml extends config_source_1.XmlConfigSource {
/**
* Gets the latest item from the XML.
*/
- getLatestChromeDriverVersion() {
- const latestReleaseUrl = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE';
- return http_utils_1.requestBody(latestReleaseUrl).then(latestVersion => {
- return this.getSpecificChromeDriverVersion(latestVersion);
- });
- }
+ getLatestChromeDriverVersion() {
+ const path = require('path')
+ const fs = require('fs')
+
+ const lastKnownGoodVersionsWithDownloads_Url = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
+ return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then(body => {
+ const latestVersion_Body = JSON.parse(body)['channels']['Stable']
+
+ const latestVersion = latestVersion_Body['version']
+ const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find(obj => obj['platform'] == 'linux64')['url']
+
+ const latestMajorVersion = latestVersion.split('.')[0]
+
+ const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
+ .find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || ''
+
+ const localVersion = localVersion_FileName.slice(13, -4)
+ const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion)
+
+ const localMajorVersion = localVersion.split('.')[0]
+
+ if (latestMajorVersion == localMajorVersion) {
+ return Promise.resolve({
+ url: localVersion_Url,
+ version: localVersion,
+ })
+ } else {
+ return Promise.resolve({
+ url: latestVersion_Url,
+ version: latestVersion,
+ })
+ }
+ });
+ }
+
/**
* Gets a specific item from the XML.
*/
diff --git a/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js b/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js
index b98cdce..4c5b27b 100644
--- a/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js
+++ b/node_modules/protractor/node_modules/webdriver-manager/built/lib/cmds/update.js
@@ -237,7 +237,11 @@ function unzip(binary, outputDir, fileName) {
child_process.spawnSync('tar', ['zxvf', path.resolve(outputDir, fileName), '-C', outputDir]);
}
// rename
- fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
+ if (fileName.indexOf('chromedriver_') != -1) {
+ fs.renameSync(path.resolve(outputDir, 'chromedriver-linux64', binary.zipContentName()), mv)
+ } else {
+ fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
+ }
// set permissions
if (osType !== 'Windows_NT') {
logger.info(binary.name + ': setting permissions to 0755 for ' + mv);

0 comments on commit 514c93a

Please sign in to comment.