Browser Automation via Chromium

Browser automation has advanced a lot, not only regarding the frameworks and tools but also in the most fundamental piece: the browser itself. Google Chrome is now very mature, has the biggest market share (as of mid'2023), and complies with all web standards, so it is an excellent starting point for automation projects.

In this post, I'll mention the most relevant pieces you need to set it up.


Using Google's Chromium instead of the main Chrome has two main advantages:

  • Some of the Google-specific features are removed, and any Google APIs require API keys to function, so they will be disabled by default
  • Unlike with Chrome, it is easy to get previous builds, so you're not forced to always test only with the latest version

But otherwise, it is the same browser.

There is a handy latest build link to download Chromium: https://download-chromium.appspot.com

Since June 2023, Google also publishes Chrome for Testing, all builds way more accesible (including downloading JSON files with the URLs, handy for automation). The only caveat is that, same as the official Chromium ones, they come without the DRM flag (explanation in the next paragraph).

Be aware that those builds, under Linux, come without the Widevine (DRM) compilation flag, so even if you follow the steps below, it won't work with protected content.

The ungoogled-chromium-binaries GitHub project provides Linux binaries compiled with the DRM flag. From the releases page is easy to pick either the latest version or a specific one:

https://github.com/clickot/ungoogled-chromium-binaries/releases/download/112.0.5615.165-1/ungoogled-chromium_112.0.5615.165-1.1_linux.tar.xz

An alternative site that hosts binaries for all platforms compiled with the DRM flag is: https://chromium.woolyss.com/

ChromeDriver is another critical piece, alongside an automation framework like WebDriverIO. It is easy to automate fetching a certain version via their download URLs:

https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1109220/chromedriver_linux64.zip

As mentioned before, Chromium might come without the DRM library, Widevine. You can fetch specific versions via URLs like the following:

https://dl.google.com/widevine-cdm/4.10.2557.0-linux-x64.zip

Following the instructions provided at the chromium-widevine GitHub project set it up, which consists of extracting the files in a certain subfolder structure inside Chromium's main folder.

Another URL you'll use a lot when setting up Chromium automation is https://peter.sh/experiments/chromium-command-line-switches/, because it contains a complete list of the hundreds of command-line arguments/flags/switches. There is no official documentation, so this is really valuable.

For debugging errors thrown by the browser, you probably want to use the flags --enable-logging=stderr --v=1.

Suppose you plan to run automated browsers in a Linux environment without display (like a Docker container, or a CI instance installed without the X Server). In that case, you will probably want to use XVFB (and xvfb-run).

Finally, if you are really brave, and have some spare time, you can manually download and compile Chromium from the source code, but it is time-consuming.

UPDATE #1: Added friend suggestion of another page containing binaries for all platforms (including Linux with DRM flag).

UPDATE #2: Added Chrome for Testing URL.

Browser Automation via Chromium published @ . Author: