How to auto update chromedriver in webdriverIO - selenium-chromedriver

I have an automation framework developed using webdriverIO. The issue is all test cases start failing whenever chrome updated as chromedriver didn't update automatically.
This version of ChromeDriver only supports Chrome version 92
is there any way that ChromeDriver updated automatically whenever there is new available

Please note down latest version of Chrome (Help > About Google Chrome )
then check your package.json file where we have line like
"chromedriver": "^98.0.0",
update above line with latest chrome version like
"chromedriver": "^100.0.0",
then run command
npm install

Use the following commands this will auto-update all the JSON dependencies to the latest version
To update to the latest version
npx npm-check-updates -u

npm install and npm install chromedriver --save-dev

Related

Unable to use correct ChromeDriver version

I am conducting QA automation testing. The code was running and working fine last week, but on restarting my computer over the weekend, it has stopped working with this error message:
Request failed with status 500 due to session not created:
This version of ChromeDriver only supports Chrome version 103
I assume it auto-updated Chrome when I restarted the laptop, as it's gone from version 103 to 105, which means I need to update my ChromeDriver.
I've done this before a few months ago, can't totally remember the steps I followed but I got it working. I possibly did something wrong then, as I can't seem to update ChromeDriver from 103 to 105.
I've tried to remove my current instance and reinstall the newer version by running:
npm uninstall chromedriver -g
npm install -g chromedriver --detect_chromedriver_version --scripts-prepend-node-path
Also tried the same having downloaded it from here:
https://chromedriver.storage.googleapis.com/index.html?path=105.0.5195.52/
and doing
npm install -g chromedriver --chromedriver_filepath=<PATH>
Also tried removing chromedriver from my package.json, doing an npm install, then adding it back in and doing an npm install. Each of these methods say they have installed the correct chromeDriver version (105.0.5195.52)
My package.json currently shows:
"dependencies": {
"chromedriver": "^105.0.0",
},
and when I do chromeDriver -v I see:
ChromeDriver 105.0.5195.52
Any ideas? If additional information is required please let me know. I know I could probably get around this by downgrading my Chrome version to 103, but I'd prefer to avoid that if possible.
On further investigation, I think it's something to do with selenium. Running my tests on their own works, but if I do selenium-standalone start and then run them, it's failing as above.
I've updated selenium by running:
npm install selenium-standalone#latest -g
npm install
Following that, when I try to start it, it's giving me an error that chromedriver is missing within the selenium node_modules folder.
A bit more investigation and I've found I also needed to run
selenium-standalone install
This did some updating, and then I was able to run
selenium-standalone start
All good now :)

How can I get chromedriver to work properly with chrome in wsl2?

I am trying to run automated tests on a repository forked from here. I haven't really worked with yarn or mocha before (or chromedriver) so I'm going off of what the instructions are saying.
I've set up Ubuntu 18.04 in wsl2 and installed google-chrome-stable and chromedriver both at version 99.0.4844.51 in /usr/bin/. I have yarn start running in one terminal and when I try actually run yarn test it gives me:
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 94
Current browser version is 99.0.4844.51 with binary path /usr/bin/google-chrome-stable
I've tried upgrading chromedriver from here to version 100.0.4896.20 but it gives me the same error saying it only supports Chrome version 94. I'm having a hard time trying to find Google version 94 for linux, and I'll be happy either way, either upgrading the chromedriver or downgrading chrome.

How can I download Appropriate Chromedriver in Protractor using Webdriver-Manager

I have designed a cucumber-protractor based automation framework where everything is working fine except for the Webdriver-manager. I need to update the binaries manually each time the IT Department updates google chrome version.
When i use command "webdriver-manager update --proxy=http://someproxy.com:PORT#", webdriver-manager always downloads the latest chromdriver binaries instead of a compatible version as per the current Chrome Version.
Please help me if there is a way to determine the chrome version automatically and download the corresponding Chrome binaries.
I have tried to search for similar behavior and forums elsewhere but none of the commands work. Instead it always downloads the latest version of chromedriver binaries instead of a compatible one.
Please help with some sample code in-case you come through a solution to this.
You could run a sh prior to starting your tests that will determine wether the chromedriver needs to be updated:
#!/bin/bash
# get existing chromedriver version
EXISTING_CD_VERSION=$(node_modules/.bin/chromedriver -version | egrep -o '(\d+)\.(\d+)\.(\d+)')
# get installed Google Chrome version
CHROME_VERSION=$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version | egrep -o '(\d+)\.(\d+)\.(\d+)')
if [ "$EXISTING_CD_VERSION" = "$CHROME_VERSION" ]; then
echo "ChromeDriver version matches the Google Chrome version"
else
NEW_CD_VERSION=$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION)
node_modules/.bin/webdriver-manager update --versions.chrome $NEW_CD_VERSION
fi
NOTE: The script above is getting the Google Chrome version from a MacOS system. If you're on Linux, you need to change that to google-chrome --version
https://github.com/angular/webdriver-manager/blob/legacy/docs/versions.md
webdriver-manager start --versions.chrome 87.0.4280.88
you can use --versions.chrome to specify the driver version
what you actually need to do is to match a version of your local chrome to the version of chromedriver. So
First, find out what your version of chrome is. From example it is 86.0.4240.111
Then, find out what chromedriver version can be used. Take the major version of the browser (first 3 numbers, 86.0.4240 in our case) and find the corresponding version of the driver by going to this url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION} (put the major browser version instead of ${CHROME_VERSION}). You'll see the chromedriver you're looking for is 86.0.4240.22
then just update webdriver specifying the desired version of chromedriver
webdriver-manager update --gecko=false --versions.chrome $VERSION
Make sure to put 86.0.4240.22 instead of $VERSION
But it maybe tricky here because there are 2 installation of protractor usually:
local
global
and each has it's own webdriver-manager. So make sure you're updating the right one
Thus you may need to go to it's folder and from that folder run npm i webdriver-manager#latest and then node ./bin/webdriver-manager update --gecko=false
when you updated the right webdriver, install the right chromedriver like so
node ./bin/webdriver-manager update --gecko=false --versions.chrome $VERSION

How to update Chromium version on a cloned repository?

I have the latest version of Chromium installed globally, but right now I'm working on a cloned repository which has in node_modules\puppeteer\.local-chromium\win64-756035\chrome-win folder an older version of Chromium, and because of that I can't run e2e tests. How can I update it? I've tried to run the webdriver-manager update command but it doesn't work.
This is the error shown:
```E/launcher - session not created: This version of ChromeDriver only supports Chrome version 87
Current browser version is 83.0.4103.0 with binary path C:\Users\.....\Documents\.....\.....\node_modules\puppeteer\.local-chromium\win64-756035\chrome-win\chrome.exe
(Driver info: chromedriver=87.0.4280.20 (c99e81631faa0b2a448e658c0dbd8311fb04ddbd-refs/branch-heads/4280#{#355}),platform=Windows NT 10.0.19041 x86_64)```
Each release of puppeteer will install a specific version of Chromium in a directory similar to the path you posted. You can find out which version of Chromium will come with a version of puppeteer in their release notes.
webdriver-manager update will try to install the latest available version of the Chromium webdriver, I believe by checking the catalog of available versions, or more specifically https://chromedriver.storage.googleapis.com/LATEST_RELEASE. (Today, that's 91.0.4472.101). That version almost certainly won't correspond to the exact version of Chromium installed by puppeteer. You need to manually specify which version of the webdriver you want webdriver-manager to install by passing the flag --versions.chrome=x.y.z.
(My personal problem is that the webdriver catalog linked above does not actually include a webdriver for the release bundled with any of the recent puppeteer releases, so I'm sticking with v6.0.0 for now.)

Install specific chromedriver for protractor

I am having an issue with chrome driver that runs on the CircleCi.
The problem is that when running:
./node_modules/.bin/webdriver-manager update
and then checking the version of chromedriver and selenium with the command:
ls -lt node_modules/protractor/selenium
it shows the latest versions are:
selenium-server-standalone-2.45.0.jar
chromedriver
chromedriver_2.15.zip
According to the npm.taobao.org note ChromeDriver version 2.15 supports Chrome v40-43. But CicleCi documentation says that it uses Chrome version 38.0.
Consequently, I need to use ChromeDriver v2.13 which is compatible with Chrome v38.0.
My question is that how can I force webdriver-manager to use ChromeDriver v2.13 instead of the latest one.
This should probably be a feature request for the protractor team. But this is what I recommend you to do:
Change the webdriverVersions property on protractor's config.json file. webdriver-manager uses this property to download the files.
#Andres suggested a good solution, but the easiest can be adding a circle.yml file that contains the following command to upgrade chrome version:
test:
pre:
- sudo apt-get update && sudo apt-get install --only-upgrade google-chrome-stable