How to always download the latest version of chromedriver and geckodriver?

0

Issue

Running automation tests on our CI. Currently, we are retrieving the latest versions of Chrome and Firefox as part of our setup, however, the versions of chromedriver and geckodriver we use are hardcoded because there seems to be no link to the latest version.

Ex. here is the line that downloads the latest firefox version

wget -nv -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"

While here is the line that downloads a specific version of geckodriver

wget -nv -O ~/geckodriver.tar.gz "https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz"

Is there anyway to always get the latest chromedriver and geckodriver?

Solution

Check if this gist helps, at least for chromedriver:

version=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
download_location= " http://chromedriver.storage.googleapis.com/ $version /chromedriver_linux64.zip "
rm /tmp/chromedriver_linux64.zip
wget -P /tmp $download_location
unzip /tmp/chromedriver_linux64.zip -d .
mv ./chromedriver ./chromedriver.linux
chmod u+x ./chromedriver.linux

Same idea for geckodriver:

install_dir= " /usr/local/bin "
json= $( curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest )
if [[ $( uname )  ==  " Darwin " ]] ;  then
url= $( echo " $json "  | jq -r ' .assets[].browser_download_url | select(contains("maces")) ' )
elif [[ $( uname )  ==  " Linux " ]] ;  then
url= $( echo " $json "  | jq -r ' .assets[].browser_download_url | select(contains("linux64")) ' )
else
 echo  " can't determine OS "
 exit 1
fi
curl -s -L " $url "  | tar -xz
chmod +x geckodriver
sudo mv geckodriver " $install_dir "

Answered By – VonC

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More