Last active
March 6, 2025 14:55
-
-
Save koppen/f95bfaed321a01148d0f3ec48035a18a to your computer and use it in GitHub Desktop.
Update for the new Chrome for Testing setup
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
#!/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