Comments (11)
If you have Protractor installed globally via npm on Windows 64-bit, you can use these steps
%APPDATA%\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\binaries\chrome_xml.js
- Replace
getLatestChromeDriverVersion
function with:
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'] == 'win32')['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,
})
}
});
}
%APPDATA%\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\update.js
- Replace line 240 [
fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
] with:
if (fileName.indexOf('chromedriver_') != -1) {
fs.renameSync(path.resolve(outputDir, 'chromedriver-win32', binary.zipContentName()), mv)
} else {
fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
}
Finally, do a webdriver-manager update
- it should get you to the next Chromedriver major version
from webdriver-manager.
For anyone who uses patch-package, this is a cross platform patch based on the above. (This assumes a non-global install)
Put it in a file named webdriver-manager+12.1.9.patch
.
diff --git a/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js b/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
index 6dfbea5..58bc44b 100644
--- a/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
+++ b/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js
@@ -55,14 +55,74 @@ class ChromeXml extends config_source_1.XmlConfigSource {
return 'linux';
}
}
+
+ /**
+ * Based on 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json' platforms
+ */
+ getPlatformForDownload() {
+ const os = require('os')
+ const arch = os.arch()
+
+ console.log(os.platform(), os.arch())
+
+ switch (os.platform()) {
+ case 'darwin':
+ return arch === 'x64'? 'mac-x64' : 'mac-arm64'
+ case 'win32':
+ return arch === 'x64'? 'win64' : 'win32'
+ default:
+ return 'linux64'
+ }
+ }
+
/**
* 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);
- });
+ 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 platformForDownload = this.getPlatformForDownload()
+ const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find(obj => obj['platform'] == platformForDownload)['url']
+
+ console.log("Platform", platformForDownload)
+ console.log("Latest Version", latestVersion)
+ console.log("Latest Version URL", latestVersion_Url)
+ const latestMajorVersion = latestVersion.split('.')[0]
+
+ console.log("Latest Major Version", latestMajorVersion)
+
+ const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
+ .find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || ''
+
+
+ const localVersion = localVersion_FileName.split('_').at(-1)
+ const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion)
+
+ const localMajorVersion = localVersion.split('.')[0]
+
+ console.log("Local File Name", localVersion_FileName)
+ console.log("Local Version", localVersion)
+ console.log("Local Version Url", localVersion_Url)
+ console.log("Local Major Version", localMajorVersion)
+
+ 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/webdriver-manager/built/lib/cmds/update.js b/node_modules/webdriver-manager/built/lib/cmds/update.js
index b98cdce..86f7709 100644
--- a/node_modules/webdriver-manager/built/lib/cmds/update.js
+++ b/node_modules/webdriver-manager/built/lib/cmds/update.js
@@ -16,6 +16,7 @@ const utils_1 = require("../utils");
const Opt = require("./");
const initialize_1 = require("./initialize");
const opts_1 = require("./opts");
+const os = require('os')
config_1.Config.runCommand = 'update';
let logger = new cli_1.Logger('update');
let prog = new cli_1.Program()
@@ -207,6 +208,26 @@ function updateBinary(binary, outputDir, proxy, ignoreSSL) {
}
});
}
+
+/**
+ * Based on 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json' platforms
+ */
+function getPlatformForDownload() {
+ const os = require('os')
+ const arch = os.arch()
+
+ console.log(os.platform(), os.arch())
+
+ switch (os.platform()) {
+ case 'darwin':
+ return arch === 'x64'? 'mac-x64' : 'mac-arm64'
+ case 'win32':
+ return arch === 'x64'? 'win64' : 'win32'
+ default:
+ return 'linux64'
+ }
+}
+
function unzip(binary, outputDir, fileName) {
// remove the previously saved file and unzip it
let osType = config_1.Config.osType();
@@ -222,8 +243,8 @@ function unzip(binary, outputDir, fileName) {
}
}
// unzip the file
- logger.info(binary.name + ': unzipping ' + fileName);
- if (fileName.slice(-4) == '.zip') {
+ logger.info(binary.name + ': unzipping ' + fileName);
+ if (fileName.slice(-4) == '.zip') {
try {
let zip = new AdmZip(path.resolve(outputDir, fileName));
zip.extractAllTo(outputDir, true);
@@ -237,7 +258,11 @@ function unzip(binary, outputDir, fileName) {
child_process.spawnSync('tar', ['zxvf', path.resolve(outputDir, fileName), '-C', outputDir]);
}
// rename
+ if (fileName.indexOf('chromedriver_') != -1) {
+ fs.renameSync(path.resolve(outputDir, 'chromedriver-' + getPlatformForDownload(), 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);
from webdriver-manager.
As alternatives you can use new library provided by selenium team - selenium - manager
from webdriver-manager.
we have now a CVE-2023-28155 reporting a vulnerability on protractor.
Can these dependencies be updated to not use protractor or use any other vulnerable dependency ?
currently this is clearly shown on :
$ npm audit
# npm audit report
request *
Severity: moderate
Server-Side Request Forgery in Request - https://github.com/advisories/GHSA-p8p7-x288-28g6
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/request
webdriver-manager *
Depends on vulnerable versions of request
node_modules/webdriver-manager
protractor >=4.0.0
Depends on vulnerable versions of webdriver-manager
node_modules/protractor
@angular-devkit/build-angular >=0.1100.0-next.0
Depends on vulnerable versions of protractor
node_modules/@angular-devkit/build-angular
4 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
from webdriver-manager.
It sure looks like webdriver-manager is EOL along with PRotractor. See #524 -- unless 3rd party post-EOL support comes along, the answer to your question is no, the dependencies for webdriver-manager will not be updated. I guess you could always fork it to fix yourself? Or look into the alternative in the second comment here.
from webdriver-manager.
Thanks @alexsch01, this worked for me after replacing win32
to linux64
:)
from webdriver-manager.
@DavidDudson Thanks, that worked! The other solution didnt work for me on mac eventhough I changed win32 to mac-x64.
from webdriver-manager.
If you have Protractor installed globally via npm on Windows 64-bit, you can use these steps
%APPDATA%\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\binaries\chrome_xml.js
* Replace `getLatestChromeDriverVersion` function with:
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'] == 'win32')['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, }) } }); }%APPDATA%\npm\node_modules\protractor\node_modules\webdriver-manager\built\lib\cmds\update.js
* Replace line 240 [`fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);`] with:
if (fileName.indexOf('chromedriver_') != -1) { fs.renameSync(path.resolve(outputDir, 'chromedriver-win32', binary.zipContentName()), mv) } else { fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv); }Finally, do a
webdriver-manager update
- it should get you to the next Chromedriver major version
After making this patch, ChromeDriver updates to 118 (latest as of 2023-10-16), but then I get this error when I try to actually run a protractor test:
[17:35:56] E/launcher - Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DW-1-NEW', ip: '10.12.135.101', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16.1'
Driver info: driver.version: unknown
from webdriver-manager.
For anyone who uses patch-package, this is a cross platform patch based on the above. (This assumes a non-global install)
Put it in a file named
webdriver-manager+12.1.9.patch
.diff --git a/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js b/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js index 6dfbea5..58bc44b 100644 --- a/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js +++ b/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js @@ -55,14 +55,74 @@ class ChromeXml extends config_source_1.XmlConfigSource { return 'linux'; } } + + /** + * Based on 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json' platforms + */ + getPlatformForDownload() { + const os = require('os') + const arch = os.arch() + + console.log(os.platform(), os.arch()) + + switch (os.platform()) { + case 'darwin': + return arch === 'x64'? 'mac-x64' : 'mac-arm64' + case 'win32': + return arch === 'x64'? 'win64' : 'win32' + default: + return 'linux64' + } + } + /** * 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); - }); + 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 platformForDownload = this.getPlatformForDownload() + const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find(obj => obj['platform'] == platformForDownload)['url'] + + console.log("Platform", platformForDownload) + console.log("Latest Version", latestVersion) + console.log("Latest Version URL", latestVersion_Url) + const latestMajorVersion = latestVersion.split('.')[0] + + console.log("Latest Major Version", latestMajorVersion) + + const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium')) + .find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '' + + + const localVersion = localVersion_FileName.split('_').at(-1) + const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion) + + const localMajorVersion = localVersion.split('.')[0] + + console.log("Local File Name", localVersion_FileName) + console.log("Local Version", localVersion) + console.log("Local Version Url", localVersion_Url) + console.log("Local Major Version", localMajorVersion) + + 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/webdriver-manager/built/lib/cmds/update.js b/node_modules/webdriver-manager/built/lib/cmds/update.js index b98cdce..86f7709 100644 --- a/node_modules/webdriver-manager/built/lib/cmds/update.js +++ b/node_modules/webdriver-manager/built/lib/cmds/update.js @@ -16,6 +16,7 @@ const utils_1 = require("../utils"); const Opt = require("./"); const initialize_1 = require("./initialize"); const opts_1 = require("./opts"); +const os = require('os') config_1.Config.runCommand = 'update'; let logger = new cli_1.Logger('update'); let prog = new cli_1.Program() @@ -207,6 +208,26 @@ function updateBinary(binary, outputDir, proxy, ignoreSSL) { } }); } + +/** + * Based on 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json' platforms + */ +function getPlatformForDownload() { + const os = require('os') + const arch = os.arch() + + console.log(os.platform(), os.arch()) + + switch (os.platform()) { + case 'darwin': + return arch === 'x64'? 'mac-x64' : 'mac-arm64' + case 'win32': + return arch === 'x64'? 'win64' : 'win32' + default: + return 'linux64' + } +} + function unzip(binary, outputDir, fileName) { // remove the previously saved file and unzip it let osType = config_1.Config.osType(); @@ -222,8 +243,8 @@ function unzip(binary, outputDir, fileName) { } } // unzip the file - logger.info(binary.name + ': unzipping ' + fileName); - if (fileName.slice(-4) == '.zip') { + logger.info(binary.name + ': unzipping ' + fileName); + if (fileName.slice(-4) == '.zip') { try { let zip = new AdmZip(path.resolve(outputDir, fileName)); zip.extractAllTo(outputDir, true); @@ -237,7 +258,11 @@ function unzip(binary, outputDir, fileName) { child_process.spawnSync('tar', ['zxvf', path.resolve(outputDir, fileName), '-C', outputDir]); } // rename + if (fileName.indexOf('chromedriver_') != -1) { + fs.renameSync(path.resolve(outputDir, 'chromedriver-' + getPlatformForDownload(), 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);
Hey @DavidDudson ! thanks for this! can you post the code changes you made without the patch output?
Cheers!
I am seeing issues if you set the version in the cli (instead of using latest) but I am trying to solve this now 🤞
from webdriver-manager.
Related Issues (20)
- [WD12.1.8] Update gecko returns statusCode=403 because cURL get a redirect from GitHub HOT 1
- Intel Mac downloading Apple arch geckodriver instead of x86
- "webdriver-manager update" downloads chrome driver version 98.0.4758.80 instead of version 98.0.4758.102 HOT 2
- webdriver-manager update error confusing while running in docker on m1 mac
- webdriver-manager update command always fails on first try but passes after HOT 1
- Session Not Created Exception
- Change default out_dir HOT 1
- Protractor--WebdriverManager issue Error: Server terminated early with status 2
- compilation error on latest webdriver-manager 13 master
- webdriver-manager update fails on Node 18 HOT 1
- Set default branch to latest code
- CVE-2023-28155 wedriver-manager depends on vulnerable version of protractor HOT 4
- Failing to download Linux Arm64 chrome inside DevContainer on Mac M1
- Latest chrome is not supported 115.0.5790.98 HOT 13
- Will HeroDevs maintain this project after August 2023? HOT 6
- webdriver-manager-replacement 2.0.2 throw the error by executing npm install command
- delete
- Vulnerability - request-2.88.2tgz HOT 1
- Vulnerability - xml2js-0.4.23.tgz HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webdriver-manager.