TechBuzzPro

Selenium 4 RC1: What's New in the Release Candidate

· 6 min read · Apps & Browsers

In this article
  1. Background: Why Selenium 4 Took So Long
  2. Relative Locators: Finding Elements by Position
  3. WebDriver BiDi: The Future of Browser Automation
  4. Selenium Grid 4: A Complete Rewrite
  5. What Was Deprecated and Removed
  6. How to Upgrade from Selenium 3
  7. Common Problems and Misconceptions
  8. Frequently Asked Questions

Selenium 4 Release Candidate 1 (RC1) was the first near-final build of the Selenium 4 major version, introducing the long-awaited relative locators, a redesigned Selenium Grid with Docker support, and the new WebDriver BiDirectional Protocol (BiDi) API. It also marked the official deprecation of the old Selenium RC (Remote Control) code and the promotion of WebDriver as the sole automation interface. RC1 was released on October 13, 2020, giving testers a stable preview before the final Selenium 4.0 release in October 2021.

Background: Why Selenium 4 Took So Long

Selenium 4 was in development for over two years. The previous major version, Selenium 3, had been released in 2016 and was essentially a transitional release that moved the project from the old Selenium RC API to WebDriver. The core goal of Selenium 4 was to complete that transition, modernize the codebase, and add features that testers had been requesting for years. RC1 was the first release candidate, meaning the feature set was frozen and the team was focusing on bug fixes and stability. It was a significant milestone because it signaled that the long-awaited version was almost ready for production use.

Relative Locators: Finding Elements by Position

The most user-visible new feature in Selenium 4 RC1 was relative locators (initially called "friendly locators"). These allow you to find an element based on its position relative to another element, using methods like above(), below(), toLeftOf(), toRightOf(), and near(). For example, in Java you could write:

WebElement passwordField = driver.findElement(withTagName("input")
    .below(driver.findElement(By.id("username"))));

This was particularly useful for elements that don't have stable IDs or CSS classes, such as form fields in complex layouts. The locator uses the element's bounding box coordinates to determine proximity, so it works even when the page layout is responsive. It was a major quality-of-life improvement over writing fragile XPath expressions.

WebDriver BiDi: The Future of Browser Automation

RC1 introduced the first implementation of the WebDriver BiDirectional Protocol (BiDi), a new standard that allows the browser and the automation script to communicate in both directions. Unlike the classic WebDriver protocol, which is purely request-response (the script sends a command and waits for a response), BiDi enables the browser to push events to the script, such as console logs, network requests, and DOM mutations. In RC1, the focus was on the core infrastructure and a few early commands, like listening to log entries. The full BiDi API, including network interception and DOM event listening, was rolled out in later versions. This was a foundational change that would eventually make Selenium faster and more powerful, as it reduces the overhead of polling for page state.

Selenium Grid 4: A Complete Rewrite

Selenium Grid, the component that allows running tests on multiple machines in parallel, was completely rewritten for Selenium 4. RC1 introduced a new, more flexible architecture with separate components: a Router, Distributor, Session Map, and Node. This modular design made it easier to scale and to run in containerized environments. The most notable addition was native Docker support, allowing you to start a Grid and browser containers with a single command:

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:4.0.0-rc-1

The new Grid also had a revamped UI, showing live session details, logs, and the ability to pause or stop sessions. It was a major improvement over the old Grid, which was often criticized for being hard to configure and debug.

What Was Deprecated and Removed

RC1 officially deprecated the last remnants of the old Selenium RC API. While the selenium-server-standalone jar still included the legacy RC classes, they were marked for removal in the final release. The DesiredCapabilities class, which had been the standard way to configure browser options, was also deprecated in favor of the newer Options classes (like ChromeOptions and FirefoxOptions). This was a breaking change for many test suites, but it pushed users to adopt the more modern and type-safe approach. Additionally, the old Actions class was updated to support the new pointer and wheel input devices, aligning with the W3C WebDriver specification.

How to Upgrade from Selenium 3

Upgrading to Selenium 4 RC1 required some code changes, but the team provided a migration guide. The main steps were:

  • Replace DesiredCapabilities with the corresponding Options class (e.g., ChromeOptions).
  • Update any code that used the old Actions API, as some methods were renamed or changed to use the new pointer input API.
  • Remove any references to org.openqa.selenium.remote.DesiredCapabilities and use the new RemoteWebDriver builder pattern.
  • For Grid users, update the configuration to use the new YAML or TOML format instead of the old JSON.

Most test suites could be migrated with minimal changes, especially if they already used WebDriver directly. The RC1 release was designed to be backward-compatible with Selenium 3 for the most part, but the deprecations were a clear signal that old APIs would not survive the final release.

Common Problems and Misconceptions

One common misconception is that Selenium 4 RC1 was the final release. In fact, there were two more release candidates (RC2 and RC3) before the stable 4.0.0. Another issue testers faced was that the new relative locators were not supported by all browser drivers initially. For example, the near() method, which finds elements within a certain pixel distance, had some quirks with responsive layouts. Also, the new Grid's Docker support required a good understanding of Docker networking, which was a hurdle for teams not familiar with containers. Finally, the BiDi API in RC1 was incomplete, so some testers were disappointed that they couldn't use it for network interception right away. It's important to remember that RC1 was a preview, not a finished product.

Frequently Asked Questions

Is Selenium 4 RC1 stable enough for production?

Release candidates are generally feature-complete and only contain critical bug fixes. However, they are not officially recommended for production use because there may still be undiscovered issues. For most teams, it was safer to wait for the final release or use the RC in a staging environment to test compatibility.

Can I use Selenium 4 RC1 with Selenium 3 tests?

Yes, Selenium 4 was designed to be backward-compatible with Selenium 3. Most existing WebDriver tests will run without changes, but you may see deprecation warnings for old APIs like DesiredCapabilities. It's recommended to address these warnings before the final release.

What is the difference between relative locators and XPath?

Relative locators are a more readable and maintainable way to find elements based on their position relative to other elements. XPath is more powerful and can traverse the DOM in complex ways, but it is often brittle and hard to read. Relative locators are not a replacement for XPath, but a complementary tool for common cases.

How do I use the new Grid with Docker?

You need to pull the Selenium Grid images from Docker Hub and run them with the appropriate ports. For example, run the hub with docker run -d -p 4444:4444 selenium/hub:4.0.0-rc-1 and then start node containers for each browser. The new Grid automatically registers nodes, so you don't need to manually specify the hub URL in the node command.

Will my browser driver work with Selenium 4 RC1?

Most browser drivers that support the W3C WebDriver specification will work. You need to ensure you have the latest version of the driver (e.g., ChromeDriver, GeckoDriver) that supports the same protocol version. Selenium 4 RC1 required drivers that support the W3C protocol, which all modern drivers do.

What happened to Selenium IDE in Selenium 4?

Selenium IDE is a separate tool and was not part of the Selenium 4 release. It continued to be developed independently, and the new version (Selenium IDE 3.x) was already available. Selenium 4 focused on the WebDriver API and Grid, not the IDE.