Skip to content

Instantly share code, notes, and snippets.

@koppen
Last active August 22, 2023 07:40
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 koppen/f95bfaed321a01148d0f3ec48035a18a to your computer and use it in GitHub Desktop.
Save koppen/f95bfaed321a01148d0f3ec48035a18a to your computer and use it in GitHub Desktop.
Update for the new Chrome for Testing setup
#!/bin/bash
# This script installs the version of Chromedriver that matches the installed
# Chrome applicaton.
#
# It installs the chromedriver binary into ~/bin/. If an existing chromedriver
# is installed it will be replaced by the updated binary.
#
# Assumptions:
#
# - Bash
# - MacOS
# Halt on errors
set -e
# Fetch the version of the installed Chrome
CHROME_VERSION=`/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version`
echo "Chrome version: $CHROME_VERSION"
CHROME_MILESTONE=`echo $CHROME_VERSION | cut -f 3 -d " " | cut -f 1 -d "."`
echo "Chrome milestone: $CHROME_MILESTONE"
# Figure out the platform
# Would be nice to be able to figure out the 'mac' part as well...
ARCHITECTURE=`uname -m`
PLATFORM="mac-$ARCHITECTURE"
echo "Platform: $PLATFORM"
# Fetch the URL of the matching Chromedriver
CHROMEDRIVER_URL=`curl https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json | jq -r --arg milestone "$CHROME_MILESTONE" --arg platform "$PLATFORM" '.milestones[$milestone].downloads.chromedriver[] | select(.platform == $platform).url'`
echo $CHROMEDRIVER_URL
# Download the chromedriver package and extract the binary
wget -O /tmp/chromedriver.zip $CHROMEDRIVER_URL
unzip -j -o /tmp/chromedriver.zip chromedriver-$PLATFORM/chromedriver -d ~/bin/
rm /tmp/chromedriver.zip
chmod ugo+rx ~/bin/chromedriver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment