Testing Made Easy: Chrome for Testing and Selenium Manager Join Forces

Santhosh
6 min readAug 6, 2023

Introducing Chrome for Testing: Your Ultimate Tool for Web App Testing!
Guess what? There’s an amazing version of Chrome called “Chrome for Testing,” specially crafted for web app testing and automation. This article will reveal why the Chrome team thought of this idea and how it can be a game-changer for developers / QA.

The Auto-Update Dilemma: Good for Users, Bad for Developers:
-
Chrome has a cool auto-update feature that users really like. It makes sure they always have the newest and safest browser with all the latest features and fixes. If the browser updates itself while they’re testing, it can mess things up.
- Also, developers want to use a specific browser version for their tests. But auto-update doesn’t let them do that. So, using regular Chrome for automated testing might not work well. This creates a difference between what’s good for regular users and what’s good for developers doing tests.

In summary, while auto-update is a great feature for everyday users,
it presents significant challenges for developers aiming to maintain consistency and control in their testing environments.

Finding Chrome Binaries with Specific Versions — Challenge:
Apart from auto-updates, you might have noticed that it’s tough to find a Chrome binary with a specific version. Google intentionally doesn’t offer versioned Chrome downloads because they want users to always have the latest version automatically. This is great for users but can be a challenge for developers who need an older version to reproduce a bug.

One particular problem arises when using ChromeDriver for browser automation. You not only have to get a Chrome binary, but you also need a matching ChromeDriver binary to ensure compatibility.
To work around these issues, some developers resort to downloading Chromium binaries instead of Chrome, but this has its drawbacks.
1. These Chromium binaries may not be reliably available on all platforms.
2. They are separate from the Chrome release process, making it hard to link them to real Chrome versions.
3. Chromium is not exactly the same as Chrome.

Introducing “Chrome for Testing” (CfT) — Your Special Chrome Version for Testing!
Chrome for Testing is a new Chrome flavor that specifically targets web app testing and automation use cases.

  1. CfT is a dedicated version of Chrome made specifically for testing purposes.
  2. It is not meant for regular users, so it won’t be found on Chrome’s download page.
  3. Unlike regular Chrome, CfT does not auto-update, ensuring stability during testing.
  4. It is independent of Chrome’s release channels (Stable, Beta, Dev, Canary). CfT tracks official Chrome release branches and is bundled with ChromeDriver.
  5. It has a distinct visual indicator to differentiate it from regular Chrome, reminding users not to use it for regular browsing.
  6. CfT follows the same release schedule as Chrome Stable/Beta but without certain browser functionalities like auto-updating.
    It offers fewer long-term support guarantees, similar to Chrome Canary, but is perfect for testing and automation purposes.

Use cases: Maintaining Testing Consistency with CfT
-
Let’s say you have a web application that works perfectly on Chrome version 114, but the current version is 115. Unfortunately, finding the right Chrome version for testing can be a real headache since Chrome doesn’t offer specific version downloads.
- To make matters worse, your application isn’t yet compatible with version 115, and when an update happens, your automated tests end up running on the wrong version.

With CFT, you can easily maintain the Chrome version you need (in this case, version 114). This allows you to do manual testing on the exact version required and also provides the driver file for smooth automation testing.

Downloading CfT — Follow these steps:
1. Assets page: Go to URL — https://googlechromelabs.github.io/chrome-for-testing/ and download the respective binary file and driver file

2. Node command: Open the terminal and provide the below commands

# Download a specific Chrome for Testing version.
npx @puppeteer/browsers install chrome@116.0.5793.0

# Download the latest available ChromeDriver version-Canary(upcoming)
npx @puppeteer/browsers install chromedriver@canary

3. JSON API endpoints — Refer to the following page for endpoint details https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints

Selenium embraces Chrome for Testing:
Now, here comes the best part — Selenium Manager! Starting from version 4.11.0, it supports Chrome for Testing. It takes care of managing the right version of Chrome for our tests. We can tell Selenium Manager which Chrome version we want, and it handles everything — finding, downloading, and managing that specific version for us.

Simplified Explanation of Selenium Manager’s Use Cases:
- No Browser Installed:
When you don’t have any browser on your machine and don’t specify a version, Selenium Manager automatically considers the latest stable version. It downloads and installs the browser for you, making testing easy.
- Matching Local Version: If you have the latest stable version (e.g., 115) of the browser on your machine and want to run tests on that version, Selenium Manager downloads only the driver file and executes tests on your local browser.
- Specific Version Needed: If you don’t have any browser but want to run tests on a specific version (e.g., 113), Selenium Manager downloads the required browser binaries and driver files. It sets up Chrome for Testing to run your tests on that version.
- Testing on Different Versions: Suppose you have the latest version (e.g., 115) but want to test on older versions (e.g., 113 and 114). Selenium Manager will download the necessary binaries for 113 and 114. Your tests will run on Chrome for Testing, keeping your local browser unaffected.

  • CfT extends support from Chrome version 113 onward, with drivers now accessible via the CfT dashboard instead of the traditional Chromium download location (https://chromedriver.chromium.org/downloads), and Selenium retrieves them accordingly.
  • The possible impact of using older Selenium versions (Pre 4.11):
    If you are working with Selenium versions that are older than 4.11 and you’re testing with the newer Chrome 115, there’s a possibility that your test scripts might stop working. This is because the older Selenium Manager searches for the driver file in an old
    location that’s no longer used in Chrome 115 and onwards. Instead, Chrome has a new location for the driver file starting from version 115. So, when you use the older Selenium with Chrome 115, it might end up using a driver file (latest version on the page i.e., 114) and this could cause compatibility issues and script failures. To avoid this problem, it’s recommended to use the latest version of Selenium.
ChromeOptions options=new ChromeOptions();
options.setBrowserVersion("115");
//To run tests on 113 version
options.setBrowserVersion("113");
//To run tests on upcoming versions
options.setBrowserVersion("116.0.5793.0");
//To run tests on upcoming versions that is in development
options.setBrowserVersion("dev");
//If you have 114 version browser in local and you want to run on 114 CfT
options.setBinary("..../chrome.exe")
Selenium Manager downloads the binaries to the local .cache folder
Here you find the chrome.exe (114) that Selenium launches the browser
Here you find the chromedriver.exe file that Selenium uses for running the tests

You might have a question — How Chromium is different from CfT?
Chromium is built from arbitrary revisions that don’t necessarily map to user-facing Chrome releases, whereas Chrome for Testing is a dedicated flavor of Chrome targeting the testing use case, without auto-update, integrated into the Chrome release process, made available for every Chrome release across all channels (Stable/Beta/Dev/Canary).

In conclusion, Chrome for Testing (CfT) is a game-changer in testing and automation. It enables developers/testers to use specific Chrome versions, ensuring consistency in tests. With Selenium Manager’s support for CFT, managing browsers and versions becomes effortless. Whether it’s the latest stable version or upcoming releases get ready for seamless testing with CFT and Selenium Manager!

Reference Links
https://googlechromelabs.github.io/chrome-for-testing/
https://developer.chrome.com/blog/chrome-for-testing/
https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/

--

--