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

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

Related

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

Find latest available Chrome version (on Linux, eg from a shell script)

How can I find the latest version of Google Chrome from a shell script (e.g. bash) on Linux ?
For ChromeDriver, I can do this:
curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE
Can I do something similar for Chrome?
Background to question
T
his needs to be done in a pipeline and there is no local install of Chrome, no tools to inspect packages (rpm, deb, and the like). The reason I want this is so that I can download the latest version as a numbered package. I could do this
wget -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
but that results in a file called google-chrome-stable_current_amd64.deb rather than one that is version stamped such as google-chrome-stable_73.0.3683.103-1_amd64.deb.
If I know the version in advance, I can get a version-stamped file using this:
GOOGLE_CHROME_VERSION=73.0.3683.103-1
wget http://dl.google.com/linux/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${GOOGLE_CHROME_VERSION}_amd64.deb
So what I'm really looking for is either generic URL that always returns the latest version-stamped file or a way to set GOOGLE_CHROME_VERSION in the above.
If you are using Ubuntu Desktop like mine 16.04, here is the command
google-chrome --version
ref. https://askubuntu.com/a/505532/22308

Browser Automation using Bash On Ubuntu On Windows

We have a strong regression automation suite developed with Watir for Web Apps and Calabash for IOS and Android and so far our executions are happening on Mac OS.
We want to use RVM on Windows 10 so enabled bash feature on Windows 10 and installed RVM using Bash On Ubuntu On Windows. Using this installed RVM I would like to trigger the browsers installed on my Windows. I would like to know whether I am trying something that is possible ?
Just to check, I tried to trigger chrome browser in irb.
I placed my chrome driver below.
I have set my path and find the same below
On triggering chrome browser in irb I am getting the below error even though the path is set correct.
Selenium::WebDriver::Error::WebDriverError: Unable to find chromedriver.
I would like to know whether trying to trigger the browser installed on my windows environment through the Bash On Ubuntu On Windows terminal is practically possible attempt or not ? If so, please let me know where the disconnect had happened in my setup.
Below are the versions I am installed with .
rvm 1.29.3 (latest)
ruby-2.2.7
watir (6.8.4)
The error you are getting generally indicates that you have installed the chromedriver.exe file into a directory that is not on your path. Either move the file to a directory that is in the default path, or modify the path to add the directory with chromedriver.exe to the path.
Generally it's best to do that with the default path set by Windows on boot-up lest you have to have some batchfile that is run to alter the path before running IRB or a script that runs your tests.
Use the webdrivers gem. It ensures you always have the latest chromedriver.exe in your ~/.webdrivers directory, by downloading the newest version as necessary. It directs the Ruby code to use that driver regardless of what other chromedriver is on your system and whether it is or isn't on PATH.

How can I downgrade to Chrome 42.0.2311.90?

Google Chrome on my machine recently got updated to v44.
I'm working with Selenium WebDriver on Chrome and as soon as I updated Chrome, all my tests went dead. I use Chromedriver v2.16. My partner's PC has Chrome v42.0.2311.90 and Chromedriver v2.16. And tests run fine on his machine. Now, based on this I'm pretty sure the problem is probably not with Chromedriver.
So, how can I downgrade to Chrome 42.0.2311.90?
I've tried using an offline installer from here:
Google Chrome Alternate Offline Installer
But this always gives me the latest version to install i.e. v44.
The release that I need can be found here:
Google Chrome v42.0.2311.90 Stable Channel Update
Uninstall your current chrome version.
Remove all Chrome data for current version from: C:\Users\username\AppData\Local\Google\Chrome
Download your particular version from chrome_installer.
Disable chrome updates using instructions given on this link.
Following steps help you to install your desired google chrome version :
1 - Uninstall your current google chrome version.
2 - Download your desired google chrome version from here : Google Chrome Download
3 - Restart PC once so if any registry or temp file stored of previous google chrome then it will get refresh.
4 - Install your downloaded google chrome. And then turn off automatic chrome update.
I struggled with this same problem on Mac, trying to downgrade, and stay downgraded from Chrome 53 to 52 due to a serious bug affecting webaudio.
None of the other recommendation appear to apply any more (or on Mac OS X at least). The app attempts to upgrade itself and there doesn't be a way to configure that in a "Chrome-friendly" way.
Eventually I resorted to force...
Close and uninstall Chrome
Edit your /etc/hosts file to prevent update checks from working by overriding the DNS entry:
0.0.0.0 tools.google.com
Find and download an old release. This is left as an exercise, this was actually hard and fraught with fear of bad binaries. I was able to cross-reference MD5s from one site that didn't have downloads with another that had downloads.
Install and run the older version
Important: Check the "About" page, and point and laugh at Chrome's attempts to check in.
This is how you can use an older chrome version "in general":
Uninstall your current chrome
Install the chrome version you desire
DO NOT open chrome!! after installation
Instead disable auto-updates like here or here
Only then may you work with your desired chrome browser version
As for how to get a specific older version:
You need to google, search forums or try sites like this. It's just "grunt work" to find the version you are looking for. If you're extremely unlucky, the very version you need might even not be around any more.
If you are running on a windows machine you can leverage the package manager chocolatey, this is how we I'm doing it from Jenkins, we call a powershell that uninstalls a previous version and install a specific one: From a powershell ide script window, you need to have installed the modules for chocolatey that is a small price to pay for a lot of benefit:
choco install googlechrome --version 62.0.3202.94 -y
Then to prevent Chrome to self update I am performing this steps:
1. Verify Chrome's current version.
(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo
Install the version I'm aiming for:
choco install googlechrome --version 62.0.3202.94 -y
You can look for available versions here:
https://chocolatey.org/packages/GoogleChrome
(Find Version History Section)
Kill GoogleCrashHandler.exe in any of its variants 32 or 64 bits or both.
Delete the Directories
C:\Program Files (x86)\Google\Update and
C:\Program Files (x86)\Google\CrashReporter
You will loose the ability to auto update (which is the whole purpose right) and
you will loose the ability to send crash reports and piggy back on that executable to update against your will whenever google deems convenient.
5.Disable Chrome Services

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