Created
August 18, 2019 02:51
-
-
Save BigTexasDork/625f11da595fec264156d2e1b2a4afb5 to your computer and use it in GitHub Desktop.
Download ChromeDriver - WebDriver for Chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from https://chromedriver.chromium.org/downloads/version-selection | |
# 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 version 72.0.3626.81, | |
# you'd get a URL "https://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 be "https://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. | |
OS=$(uname) | |
echo "executing on ${OS}" | |
CHROME_VER=$(google-chrome-stable --version) | |
CHROME_VER_TRIMMED=${CHROME_VER% *} # trim tailing space | |
CHROME_VER_NUM="${CHROME_VER_TRIMMED##* }" # everything after the last space | |
echo " chrome version: $CHROME_VER_NUM" | |
CHROME_VER_SHORT=${CHROME_VER_NUM%.*} # everything before the last period | |
echo " chrome version short: ${CHROME_VER_SHORT}" | |
CHROME_DRIVER_INFO_URL="https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VER_SHORT}" | |
echo " driver info url is: ${CHROME_DRIVER_INFO_URL}" | |
CHROME_DRIVER_VER=$(wget ${CHROME_DRIVER_INFO_URL} -q -O -) | |
echo "chrome driver version is: $CHROME_DRIVER_VER" | |
if [ ! -f env/bin/chromedriver ]; then | |
echo "downloading chromedriver" | |
if [ "Darwin" == "$OS" ]; then | |
wget -q https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VER/chromedriver_mac64.zip | |
unzip chromedriver_mac64.zip | |
else | |
wget -q https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VER/chromedriver_linux64.zip | |
unzip chromedriver_linux64.zip | |
fi | |
cp chromedriver env/bin/ | |
else | |
echo "chromedriver exists" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment