Features and Improvements in Selenium 4
Features and Improvements in Selenium 4
Take a look at this rundown of some of the forthcoming features of Selenium 4.
Join the DZone community and get the full member experience.
Join For FreeYou 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.
Improvements
- 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.


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;


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.
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:
Window and Tab Management:
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:

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

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
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}