Skip to content

Instantly share code, notes, and snippets.

@Amr1977
Last active September 4, 2018 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amr1977/fa3ba0e33ba1a333c20cf3c047ef1b48 to your computer and use it in GitHub Desktop.
Save Amr1977/fa3ba0e33ba1a333c20cf3c047ef1b48 to your computer and use it in GitHub Desktop.
Auto update ChromeDriver and GeckoDriver if needed.
# https://gist.github.com/ziadoz/3e8ab7e944d02fe872c3454d17af31a5
# https://gist.github.com/birdsarah/23312f1d7cbd687ac376c95662254773
# This script checks & downloads latest chromeDriver and geckoDriver IF needed.
# New drivers are extracted and copied to $driversDestination
# IMPORTANT: Remember to change $driversDestination variable below to match your case
# You can call this script before launching your test suite so you always get latest drivers each run
os=linux64
driversDestination=../dependencies/browser-drivers/
if [ -e chromedriver_last.txt ]
then
chromedriver_last_download=`cat chromedriver_last.txt`
fi
chromedriver_latest_version=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`
if [ "$chromedriver_last_download" = "$chromedriver_latest_version" ]; then
echo "Already has last chromedriver version" $chromedriver_latest_version
else
echo "Updating chromedriver from " $chromedriver_last_download "to" $chromedriver_latest_version
wget -N http://chromedriver.storage.googleapis.com/$chromedriver_latest_version/chromedriver_$os.zip -O chromedriver_linux64.zip
echo "$chromedriver_latest_version" > "chromedriver_last.txt"
unzip -o chromedriver_$os.zip -d $driversDestination
rm chromedriver_$os.zip
fi
if [ -e geckodriver_last.txt ]
then
geckodriver_last_download=`cat geckodriver_last.txt`
fi
geckodriver_latest_version=`curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name"`
if [ "$geckodriver_last_download" = "$geckodriver_latest_version" ]; then
echo "Already has last geckodriver version" $geckodriver_latest_version
else
echo "Updating geckodriver from " $geckodriver_last_download "to" $geckodriver_latest_version
wget https://github.com/mozilla/geckodriver/releases/download/$geckodriver_latest_version/geckodriver-$geckodriver_latest_version-$os.tar.gz -O geckodriver.tar.gz
echo "$geckodriver_latest_version" > "geckodriver_last.txt"
tar -xvzf geckodriver.tar.gz
rm geckodriver.tar.gz
chmod +x geckodriver
mv geckodriver $driversDestination
fi
@Amr1977
Copy link
Author

Amr1977 commented Aug 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment