Created
April 15, 2020 17:05
-
-
Save headquarters/d4b5d9f61c803252a249e93912477be1 to your computer and use it in GitHub Desktop.
Get ChromeDriver version
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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.