Skip to content

Instantly share code, notes, and snippets.

@jlegido
Forked from cgoldberg/geckodriver-install.sh
Last active May 8, 2020 06:22
Show Gist options
  • Select an option

  • Save jlegido/7dbace98bb899180e5801002f5204dee to your computer and use it in GitHub Desktop.

Select an option

Save jlegido/7dbace98bb899180e5801002f5204dee to your computer and use it in GitHub Desktop.
download and install latest geckodriver for linux or mac (selenium webdriver)
#!/bin/bash
# download and install latest geckodriver for linux or mac.
# required for selenium to drive a firefox browser.
set -e
install_dir="/usr/local/bin"
url="https://api.github.com/repos/mozilla/geckodriver/releases/latest"
if [[ $(uname) == "Darwin" ]]; then
release_url=$(curl -s "$url" | jq -r '.assets[].browser_download_url | \
select(contains("macos"))')
elif [[ $(uname) == "Linux" ]]; then
release_url=$(curl -s "$url" | jq -r '.assets[].browser_download_url | \
select(contains("linux64"))')
else
echo "can't determine OS"
exit 1
fi
tarball="geckodriver.tar.gz"
curl -L -s -o "$tarball" "$release_url"
tar -xzf "$tarball"
rm "$tarball"
chmod +x geckodriver
sudo mv geckodriver "$install_dir"
echo "installed geckodriver in $install_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment