Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webdriver-manager deprecation ? #517

Open
bboycs opened this issue Nov 29, 2022 · 14 comments
Open

Webdriver-manager deprecation ? #517

bboycs opened this issue Nov 29, 2022 · 14 comments

Comments

@bboycs
Copy link

bboycs commented Nov 29, 2022

As Protractor is going to EOL soon, how about webdriver-manager ?
Can webdrive-manager handover to protractor partner(herodevs) for further maintenance ?

@StanislavKharchenko
Copy link

As alternatives you can use new library provided by selenium team - selenium - manager

@tambor81
Copy link

tambor81 commented Mar 20, 2023

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

@thw0rted
Copy link

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.

@alexsch01
Copy link

alexsch01 commented Aug 10, 2023

@thw0rted

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

@leroybm
Copy link

leroybm commented Aug 17, 2023

Thanks @alexsch01, this worked for me after replacing win32 to linux64 :)

@DavidDudson
Copy link

DavidDudson commented Sep 4, 2023

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);

@bashbers
Copy link

@DavidDudson Thanks, that worked! The other solution didnt work for me on mac eventhough I changed win32 to mac-x64.

olzraiti added a commit to luomus/laji-form-builder that referenced this issue Oct 11, 2023
olzraiti added a commit to luomus/laji-form-builder that referenced this issue Oct 11, 2023
@JordanRieger
Copy link

JordanRieger commented Oct 17, 2023

@thw0rted

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

@emmapatterson
Copy link

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 🤞

kosarko added a commit to ufal/lindat-common that referenced this issue Mar 19, 2024
- added firefox to the testing suite
- partial fix based on angular/webdriver-manager#517 (comment) and patch-package (if you have chrome version that matches latest driver...)
- chrome needs to run `--headless` ¯\_(-_-)_/¯
@OrangeDog
Copy link

OrangeDog commented May 29, 2024

@DavidDudson this still does not work for me:

[e2e] (node:27172) UnhandledPromiseRejectionWarning: TypeError: localVersion_FileName.split(...).at is not a function
[e2e] at .\node_modules\webdriver-manager\built\lib\binaries\chrome_xml.js:104:63

Probably because Node v14 is too old?

Replacing .at(-1) with .pop() should fix it.

Edit:
On a second run on Windows it messes up, thinking that .exe is part of the version:

[e2e] Local File Name chromedriver_125.0.6422.78.exe
[e2e] Local Version 125.0.6422.78.exe
[e2e] Local Version Url https://storage.googleapis.com/chrome-for-testing-public/125.0.6422.78.exe/win64/chromedriver-win64.zip
[e2e] Local Major Version 125
[e2e] [17:01:22] E/downloader - Expected response code 200, received: 404

Adding a .replace(/\.exe$/, '') fixes that.

@OrangeDog
Copy link

I also removed some of the unnecessary changes and spammy logging:

--- 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,55 @@ class ChromeXml extends config_source_1.XmlConfigSource {
             return 'linux';
         }
     }
+
+    getPlatformForDownload() {
+        const os = require('os')
+        const arch = 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']
+        const latestMajorVersion = latestVersion.split('.')[0]
+
+        const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
+          .find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || ''
+        const localVersion = localVersion_FileName.split('_').pop().replace(/\.exe$/, '')
+        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.
--- a/node_modules/webdriver-manager/built/lib/cmds/update.js
+++ b/node_modules/webdriver-manager/built/lib/cmds/update.js
@@ -207,6 +208,21 @@ function updateBinary(binary, outputDir, proxy, ignoreSSL) {
         }
     });
 }
+
+function getPlatformForDownload() {
+  const os = require('os')
+  const arch = 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();
@@ -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);

@arbabnazar
Copy link

If someone is looking for the solution to the same problem mentioned by @JordanRieger on Ubuntu Linux, it is here:

/usr/lib/node_modules/webdriver-manager/built/lib/binaries/chrome_xml.js

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,
            })
        }
    });
}``

/usr/lib/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-linux64', binary.zipContentName()), mv)
    } else {
        fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
    }

@jcompagner
Copy link

did nobody fork the webdriver-manager to make this fix? so we can install that one besides protractor?

@JordanRieger
Copy link

@jcompagner I had to rewrite all my tests using the new selenium-manager without protractor at all. Big hassle, but at least I don't have to manually patch stuff any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests