Features and Improvements in Selenium 4

DZone 's Guide to

Features and Improvements in Selenium 4

Take a look at this rundown of some of the forthcoming features of Selenium 4.

· DevOps Zone ·
Free Resource

selenium 4

Here's what you can expect from Selenium 4.
Selenium is a well-known suite of tools to automate web application tests across many platforms. Selenium runs in many browsers with operating systems and can be controlled by programming languages such as Java, C#, and Python. 
You may also enjoy:  Selenium 4 Is Releasing Soon: What Every QA Must Know

In this article, I am going to introduce new features of Selenium 4 and improvements over Selenium 3.


  • Improved Docker support 
  • Improved identification of parent frame directly
  • Grid Concepts: some of commands, URLs and some properties have changed and improved in Selenium Grid.

New Features

  • Support for the Chromium driver for Microsoft Edge browser
  • Has native support for Chrome DevTools with new API in order to get detailed Chrome Development properties (ApplicationCache, Fetch, Network, Performance, Profiler, ResourceTiming, Security and Target CDP domains)
  • Instead of JSON wire protocol, native support of W3C standard using (for Session processes, Desired Capabilities)
  • Support of Relative Locators 
  • Running with different browsers in same time and with different tabs in one browser window (Window and Tab Management)

ChromiumDriver and DevTools: 

In Selenium 3, EdgeDriver and ChromeDriver have their own implementations and are directly inherited from the RemoteWebDriver shown in Figure 1 and Figure 2. 

ChromeDriver Extension
ChromeDriver Extension
EdgeDriver Extension
EdgeDriver Extension

However, EdgeDriver and ChromeDriver extend from ChromiumDriver which has new ChromeDevTools implementations, and you can see the new methods in Figure 3 and Figure 4;

EdgeDriver methods
EdgeDriver methods
ChromeDriver methods

When you open the Chrome browser, you can inspect the Chrome developer tools. Now, as you can see in the screenshot below, you can access these developer tools by calling the methods in Selenium 4.

Calling methods

Calling methods

Relative Locators

This is a new feature of Selenium 4. Generally, when starting to write automation tests, you can find the element using by CSS or Xpath locators such as find by ID, name, link text, etc. Now with Selenium 4, you can find your element using Relative Locators. This means you can find your element that is close to other ones. 

We have several methods to find a close-by (relative) element. These are:

  • toLeftOf() : Element located to the left of specified element.
  • toRightOf() : Element located to the right of the specified element.
  • above() : Element located above with respect to the specified element.
  • below() : Element located below with respect to the specified element.
  • near() : Element is at most 50 pixels far away from the specified element. The pixel value can be modified.

The methods which are represented above are overloaded accept a By or a WebElement. You can also see the usage of these properties in Figure 6:

Relative LocatorsWindow and Tab Management:

Relative locators

With Selenium 4, you can run two different windows at the same time and you can navigate to different URLs. A coding example is in Figure 7: 

Figure 7

In addition, you can run two different tabs in one Chrome browser session. An implementation of code example is in Figure 8:

Multiple Chrome tabs
Multiple Chrome Locators

These features are not supported by Selenium 3. Selenium 4 also supplies more efficiency by providing a screenshot of a specific WebElement and the location and size of a WebElement by using a Rectangle object.

Selenium 4.0.0-alpha-3 is currently deployed in a Maven repository, and you can click this link to download the beta version. The final version is expected to be released by the end of the year. 

Further Reading

How Selenium 4 Relative Locator Can Change The Way You Test

What To Expect From The New Version Of Selenium 4 Alpha

selenium, selenium automation, selenium automation testing, selenium docker, selenium grid, selenium test automation, selenium training, selenium tutorials, selenium web driver, test automation

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}