WebDriver Manager Update Issue In Protractor | Devstringx

Devstringx Technologies
2 min readMar 27, 2024

--

Problem Statement-

In Protractor, For updating the driver’s latest version, we use the web driver-manager update command. But now as we know Protractor is going to EOL Soon and along with Protractor, WebDriver-Manager is also going to EOL So Now if you try to update the webdriver-Manager it will only update it to Chrome version 114 but the latest version of Chrome is 120.0.6099.217. So You will not be able to run your protractor tests as webdriver-Manager is not updated, and you will get an error in the console.

To resolve the above-mentioned issue you can follow the steps-

Step 1–

Open the Chrome.xml file and replace the getLatestChromeDriverVersion() function.

You can find the chrome_xml.js file in this path-

APPDATA%\npm\node_modules\protractor\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'] == '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,
})
}
});
}

The above-mentioned method will fetch the latest version of Chrome from https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json response body and will update the driver accordingly.

Step 2–

Go to

%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 the below code-

if (fileName.indexOf('chromedriver_') != -1) {
fs.renameSync(path.resolve(outputDir, 'chromedriver-win32', binary.zipContentName()), mv)
} else {
fs.renameSync(path.resolve(outputDir, binary.zipContentName()), mv);
}

Step 3

Update Webdriver Manager using the below command-

webdriver-manager update

Now It will update Chrome Driver as per the latest version available.

Related Post:-

Originally published at https://www.devstringx.com on March 27, 2024

--

--

Devstringx Technologies
Devstringx Technologies

Written by Devstringx Technologies

Devstringx Technologies is highly recommended IT company for custom software development, mobile app development and automation testing services