Skip to content

Commit

Permalink
feat: add fallback conditional to chrome driver (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbourdais authored Sep 5, 2023
1 parent e3307ef commit 5cd25d0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/scripts/install-chromedriver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ else
fi

CHROME_VERSION_STRING="$(echo "$CHROME_VERSION" | sed 's/.*Google Chrome //' | sed 's/.*Chromium //')"
# shellcheck disable=SC2001
CHROME_VERSION_MAJOR="$(echo "$CHROME_VERSION_STRING" | sed "s/\..*//" )"
echo "Chrome version major is $CHROME_VERSION_MAJOR"

# print Chrome version
echo "Installed version of Google Chrome is $CHROME_VERSION_STRING"
Expand Down Expand Up @@ -144,14 +147,19 @@ if command -v chromedriver >/dev/null 2>&1; then
fi
fi

echo "ChromeDriver $CHROMEDRIVER_VERSION will be installed"

# download chromedriver
if [[ $CHROME_RELEASE -lt 115 ]]; then
curl --silent --show-error --location --fail --retry 3 \
--output chromedriver_$PLATFORM.zip \
"http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_$PLATFORM.zip"
else
MATCHING_CHROMEDRIVER_URL_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROMEDRIVER_VERSION/linux64/chromedriver-linux64.zip')
echo $MATCHING_CHROMEDRIVER_URL_RESPONSE
if [[ $MATCHING_CHROMEDRIVER_URL_RESPONSE == 404 ]]; then
echo "Matching Chrome Driver Version 404'd, falling back to first matching major version."
CHROMEDRIVER_VERSION=$( curl https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone.json | grep -o "$CHROME_VERSION_MAJOR.*" | grep -o "version.*" | grep -o '\:*'"$CHROME_VERSION_MAJOR"'.*,' | sed 's/".*//')
echo "New ChromeDriver version to be installed: $CHROMEDRIVER_VERSION"
fi
echo "$CHROMEDRIVER_VERSION will be installed"
if [[ $PLATFORM == "linux64" ]]; then
PLATFORM="linux64"
Expand Down

0 comments on commit 5cd25d0

Please sign in to comment.