Skip to Content
Technical Articles
Author's profile photo Nayden Zhekov

UI5 Testing: How to Handle ChromeDriver Update in Docker Image

As you probably know, it’s a big challenge to maintain multiple versions of ChromeDriver. To know which version to select you need to first know what version of Chrome you are using it with. You can execute UI5 Test on Chrome (headless) in docker image (Ubuntu 18.04), so you always need to be up to date with the latest stable Chrome browser and ChromeDriver.

There is an automatic way to update your docker image with the latest stable version of Chrome browser, with just a button click and there are manual steps. After the update, ChromeDriver can publish the image in a docker repository where it will be consumed from. In this blogpost, I will tell you about these two ways to update ChromeDriver in docker image and what are the pros and cons of each of them.

Different options to update ChromeDriver in docker image

Manually update Chrome browser and ChromeDriver

  • Check the Chrome Platform status for the last stable Chrome version. For example, Chrome 87 just became stable which means:
    • Chrome browser 87.0.4280.67
    • ChromeDriver 87.0.4280.20
  • On your docker image, you have Chrome 86 and you want to update it to 87.
  • In Dokerfile for your image perform this command:
# add latest stable chrome installation

RUN curl -s https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && apt-get update && apt-get install -y google-chrome-stable

=>

Setting up google-chrome-stable (87.0.4280.67) ...

  • Manually download ChromeDriver 87.0.4280.20 and replace ChromeDriver on docker image /usr/bin/chromedriver.
  • Push the docker image in the docker repository so each time you execute UI5 tests, the last version of the image will be used.

Pros:

– You have control over the exact ChromeDriver 87 version used and added in docker image.

Cons:

– You need to manually download the latest stable version of ChromeDriver and add it to docker image (Dockerfile).

 

Automatically update Chrome browser and ChromeDriver

  • ChromeDriver uses the same version number scheme as Chrome. For more details, see https://www.chromium.org/developers/version-numbers.
  • Each version of ChromeDriver supports Chrome with matching major, minor, and build version numbers. For example, ChromeDriver 87.0.4280.20 supports all Chrome versions that start with 87.0.4280.
    • Here are the steps to choose the version of ChromeDriver to download:
      1. Find out which version of Chrome you are using. In our example, google-chrome-stable (executed at step 4 above) is Chrome 87.0.4280.67.
      2. Take the Chrome version number, remove the last part and append the result to the URL “https://chromedriver.storage.googleapis.com/LATEST_RELEASE_”. For example, with Chrome version 87.0.4280.67, you’d get the URL “https://chromedriver.storage.googleapis.com/LATEST_RELEASE_87.0.4280”
      3. Use the URL created in the last step to retrieve a small file containing the version of ChromeDriver to use. For example, the above URL will create a file containing “87.0.4280.20”. The actual number may change in the future, of course.
      4. Use the version number retrieved from the previous step to construct the URL for downloading ChromeDriver. With version 87.0.4280.20, the URL would be https://chromedriver.storage.googleapis.com/87.0.4280.20/chromedriver_linux64.zip
  • Execute the instructions from the first four bullets described in “Manually update Chrome browser and ChromeDriver”.
  • Your Chrome browser version (google-chrome –version) is 87.0.4280.67.
  • Store Chrome browser main version in chromebrowser-main-version.txt. In this case, it’s 87.0.4280.
RUN google-chrome --version | grep -oE "[0-9]{1,10}.[0-9]{1,10}.[0-9]{1,10}" > /tmp/chromebrowser-main-version.txt
  • Create file latest_chromedriver_version.txt containing the latest chromedriver 87. In our case, this is 87.0.4280.20.
RUN wget --no-verbose -O /tmp/latest_chromedriver_version.txt https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$(cat /tmp/chromebrowser-main-version.txt)
  • Install ChromeDriver.
# Install chromedriver for Selenium

RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$(cat /tmp/latest_chromedriver_version.txt)/chromedriver_linux64.zip && rm -rf /opt/selenium/chromedriver && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium && rm /tmp/chromedriver_linux64.zip && mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$(cat /tmp/latest_chromedriver_version.txt) && chmod 755 /opt/selenium/chromedriver-$(cat /tmp/latest_chromedriver_version.txt) && ln -fs /opt/selenium/chromedriver-$(cat /tmp/latest_chromedriver_version.txt) /usr/bin/chromedriver
  • Push the docker image in the docker repository so each time you execute UI5 tests, the last version of the image will be used.

 

Pros:

– Automatically detects and installs the latest version of ChromeDriver based on what version is google-chrome-stable at the time.

– No manual effort where the whole process takes only a few minutes.

Cons:

– Doesn’t state the exact version of ChromeDriver to be downloaded/used.

 

How to run UI5 Tests with the correct ChromeDriver version

After performing these steps, the ChromeDriver that you use for UI5 Tests in the docker image is the latest one installed at /usr/bin/chromedriver. The respective WebDriver version is specified in basic profile and can be overwritten from the command line:

$ uiveri5 --config.connectionConfigs.direct.binaries.chromedriver.localPath=/usr/bin/chromedriver

To sum up, these are the two ways to update ChromeDriver in docker image. It’s up to you to decide which one to use.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Md Akramul Islam
      Md Akramul Islam

      Very well explained. Helpful article.