Last active
September 4, 2018 19:27
-
-
Save Amr1977/fa3ba0e33ba1a333c20cf3c047ef1b48 to your computer and use it in GitHub Desktop.
Auto update ChromeDriver and GeckoDriver if needed.
This file contains hidden or 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found also https://github.com/bonigarcia/webdrivermanager