Skip to content

Instantly share code, notes, and snippets.

@minedun6
Forked from cgoldberg/geckodriver-install.sh
Created November 13, 2017 09:02
Show Gist options
  • Save minedun6/ad4433a2c7f3b7caf575ca812b5713e2 to your computer and use it in GitHub Desktop.
Save minedun6/ad4433a2c7f3b7caf575ca812b5713e2 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.
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("macos"))')
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"
echo "installed geckodriver binary in $install_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment