Reputation: 7199
I have a set of tests that downloads the latest Google Chrome from https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb and then parses the contents on https://chromedriver.chromium.org/downloads to figure out the right chrome driver version to download. The Chrome version eg: 102.0.5005.115, does not always match the chrome driver version, eg: 102.0.5005.61.
Currently, I parse the contents of https://chromedriver.chromium.org/downloads and try to figure out the right version. This is brittle as the HTML contents may change.
#!/bin/sh
GOOGLE_CHROME_VERSION="$(google-chrome --version | cut -f 3 -d ' ')"
# https://www.chromium.org/developers/version-numbers/
GOOGLE_CHROME_VERSION_MAJOR=$(echo "${GOOGLE_CHROME_VERSION}" | cut -f 1 -d'.')
echo "GOOGLE_CHROME_VERSION_MAJOR => [${GOOGLE_CHROME_VERSION_MAJOR}]"
# https://chromedriver.chromium.org/downloads
GOOGLE_CHROME_DRIVER_LINE=$(curl https://chromedriver.chromium.org/downloads | grep "If you are using Chrome version ${GOOGLE_CHROME_VERSION_MAJOR}," | head -1)
GOOGLE_CHROME_DRIVER_VERSION=$(echo "${GOOGLE_CHROME_DRIVER_LINE}" | rev | cut -f 1 -d' ' | rev)
echo "GOOGLE_CHROME_DRIVER_VERSION => [${GOOGLE_CHROME_DRIVER_VERSION}]"
wget https://chromedriver.storage.googleapis.com/${GOOGLE_CHROME_DRIVER_VERSION}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
chmod a+x chromedriver
mv chromedriver /usr/local/bin
Is there a simpler way to download a chrome driver for a specific version of google chrome?
Upvotes: 3
Views: 6066
Reputation: 36
https://chromedriver.chromium.org/downloads/version-selection
I hope this helps. Apparently, it supports some automated URL resolving:
First, find out which version of Chrome you are using. Let's say you have Chrome
72.0.3626.81
.Take the Chrome version number, remove the last part, and append the result to URL
https://chromedriver.storage.googleapis.com/LATEST_RELEASE_
. For example, with Chrome version72.0.3626.81
, you'd get a URLhttps://chromedriver.storage.googleapis.com/LATEST_RELEASE_72.0.3626
.Use the URL created in the last step to retrieve a small file containing the version of ChromeDriver to use. For example, the above URL will get your a file containing
72.0.3626.69
. (The actual number may change in the future, of course.)Use the version number retrieved from the previous step to construct the URL to download ChromeDriver. With version
72.0.3626.69
, the URL would behttps://chromedriver.storage.googleapis.com/index.html?path=72.0.3626.69/
.After the initial download, it is recommended that you occasionally go through the above process again to see if there are any bug fix releases.
Upvotes: 2
Reputation: 21
An update for new versions. This is a script that looks for the latest version of chromedriver, downloads it to the current directory, and deletes the downloaded zip files.
https://github.com/Ismola/linux-chromedriver-updater
Upvotes: 0
Reputation: 12787
This shell script will download the latest chrome driver and update to latest google chrome version in your Linux.
#!/bin/sh
#get latest version
version=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)`;
echo 'Currently LATEST_RELEASE:' $version;
#download the latest version chrome driver available as per the above line
wget -N http://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip -d /usr/local/bin
chmod a+x /usr/local/bin/chromedriver
#upgrade to latest google chrome
yum upgrade google-chrome-stable
google_version=`google-chrome --version`;
echo 'Google Chrome Version:' $google_version;
echo 'Currently LATEST_RELEASE:' $version;
echo 'End of the script'
This can be automated via Cron Scheduler
to update in a specified frequency if you Linux server is OS patched. According to Google Chrome
issues releases every six weeks. As a fact it is better to use the latest chrome to avoid security vulnerabilities. Therefore crontab
will come in handy to safe guard you.
Upvotes: 1