Skip to content

Instantly share code, notes, and snippets.

@headquarters
Created April 15, 2020 17:05
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 headquarters/d4b5d9f61c803252a249e93912477be1 to your computer and use it in GitHub Desktop.
Save headquarters/d4b5d9f61c803252a249e93912477be1 to your computer and use it in GitHub Desktop.
Get ChromeDriver version
# Get the currently installed version of Chrome
# Works in Codebuild Ubuntu image; may need to use `chrome` instead of `google-chrome` elsewhere
CHROME_VERSION=$(google-chrome --version | awk -F '[ .]' '{print $3"."$4"."$5}')
# Get the compatible version of ChromeDriver based on the Chrome version
# See https://chromedriver.chromium.org/downloads/version-selection for more info on how this works
CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION)
# With these environment variables, things like webdriver-manager can be called to update with a specific version:
# webdriver-manager update --gecko false --versions.chrome $CHROME_DRIVER_VERSION
@headquarters
Copy link
Author

Because AWS Codebuild images bake in their own version of Chrome ("latest" as of the last release of the image, which you have no way of knowing or controlling), getting a compatible ChromeDriver version can be difficult. If you pin your version of ChromeDriver, Chrome may update. If you don't pin, ChromeDriver may update and be incompatible with the installed version of Chrome. This script can be used to get the installed version of Chrome, get ChromeDriver's compatible version, and then use that to tell WebDriver Manager which version you want to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment