New Comings with Selenium 4

Amil Uslu
4 min readNov 11, 2019

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 some programming languages for example Java, C#, python etc. In these days, there are important changes in Selenium 4 that’s why automation testers are looking forward to wait Selenium 4.

In this article, I am going to introduce new features of Selenium 4 and improvements according to 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 of 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 etc.)
  • 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 has own implementation and directly inherited from RemoteWebDriver shown in Figure 1 and Figure 2.

Figure 1
Figure 2

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

Figure 3
Figure 4

When you open the chrome browser, you can inspect the chrome developer tools. Now, as you can see in the below, you can access this developer tools via calling the methods in Selenium 4.

Figure 5

Relative Locators:

This is new feature of Selenium 4. Generally, when started 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. Namely, you can find your element that 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 usage of this properties in Figure 6;

Figure 6

Window and Tab Management:

With Selenium 4, you can run two different window in same time and you can navigate to different URLs. Coding example is in Figure 7;

Figure 7

In addition, you can run two different tabs in one chrome browser session. Implementation of code example is in Figure 8;

Figure 8

These properties which explained above, are not supported by Selenium 3. Selenium 4 also supplies more effiency, screenshot of a specific WebElement and location and size of a WebElement by using Rectangle object.

Recently, Selenium 4.0.0-alpha-3 is deployed in maven repository. You can click this link in order to get from maven repository. The final version is expected to be released by the end of the year.

Thanks.

Amil Uslu

--

--