Selenium 4 Features

In this post, we will see Selenium 4 Features, Installation of Selenium 4 and difference between Selenium 3.0 and Selenium 4.0.

Introduction of Selenium

Selenium is a functional, regression automation testing tool for web based application. It allows choosing a different programming language to create automation test scripts.

Firstly Selenium is launched in 2004 as Selenium Core. Selenium IDE and Selenium WebDriver are added in 2007. Later on Selenium name changed to Selenium 2 (2011), Selenium 3 (2016). Now Selenium 4.0 is launched.

What’s new in Selenium 4

Selenium 4 contains different features like relative locators, improved selenium grid architecture, improved documentation and many more.

The most significant changes in Selenium 4 is W3C compliance of WebDriver APIs.

Selenium 4 Features 2021

Here are some changes which I have mentioned below.

1. Selenium WebDriver W3C Standardization:

In Selenium 3, JSON wire protocol is responsible for communicating between selenium test code and web browser. But in selenium 4, it does not require encoding and decoding in request and responses communicated across the protocol.

Based on W3C standards, any software that follows W3C standards can be integrated with selenium 4 without any compatibility issue.

JSON wire protocol is deprecated in Selenium 4.

2. Improved Selenium Grid:

Selenium Grid used for run the test cases on multiple OS, multiple browser and on different versions.

  • In Selenium 4, selenium grid removed the connection issue of node and hub.
  • It improved the Grid UI, user friendly.
  • It also supports Docker and IPv6 addresses.
  • It also enhance the Devops process as it supports to Azure, AWS and more.

3. Relative Locators

In Selenium 3, there were no ways (or specific methods) to locate Web Elements relative to the nearby elements but in Selenium 4, it introduced relative locators which ease locating Web Elements based on visual location on UI relative to other DOM elements.

In simple words, relative locators allow use to locate web elements based on their position with respect to other elements.

There are 5 locators added into Selenium 4.

  • above(): The required web element is just above of a specified element.
  • below(): The required web element is just below of a specified element.
  • toLeftOf():The required web element is to left of a specified element.
  • toRightOf():The required web element is just to right of a specified element.
  • near():  The required web element is at most 50 pixels away from a specified element.
 Note: The above locators supports ‘withTagName’ method which returns an instance of Relative locator. 


WebElement ele1;
ele1 = driver.findElement("123"));
String ele2 = driver.findElement(withTagName("AYZ").below(ele1)).getText();
System.out.println("Element below ele1 is "+ ele2);
//Assume element0 is above element1
WebElement ele1;
ele1 = driver.findElement("1234"));
String element0 = driver.findElement(withTagName("ABC").above(ele1)).getText();
System.out.println("Element above ele1 is "+ element0);
//Assume element1 is on the left side of element3
WebElement element1;
element1 = driver.findElement( withTagName("ABC").toLeftOf(0ele3)).getText();
System.out.println(" Left of element 3 is : "+ element1);
//Assume element3 is on the right side of element1
WebElement ele3;
ele3 = driver.findElement( withTagName("ABC").toRightOf(element1)).getText();
System.out.println(" Right of element 1 is : "+ ele3);

4. Upgraded Selenium IDE:

We know this in Selenium suite, there is a one record and playback tool called Selenium IDE. It is a Firefox add-on till Selenium 3. But in Selenium it is upgraded and supports to most of the browsers like Firefox, Chrome, IE etc.

The new selenium 4 IDE provides following features.

  • Improved user friendly GUI
  • Supported most of the browsers like Chrome, Firefox, IE etc.
  • It provides report with information like a total no. of test cases executed, total passed test cases and number of total failed test cases.
  • Improved control flow mechanism for usage of if, else, while etc..

5. Enhanced Selenium 4 Documentation

Selenium 4 documentation all information about Selenium IDE, Selenium GRID and WebDriver W3C protocols. L

This will help individual testers to get the information from this document.

You can assess this document from Here

6. Better window and Tab management

Sometimes when we click on any link it will open in a new tab/window. In Selenium 3, we handle it using switch operation and windowHandle method.

Now in Selenium 4, it comes with new API – newWindow that allow user to create and switch to a new window/tab without creating a new webdriver object.

Sample Code for open a new window:

// Opens a new window and switch on that

// Opens Automationtesting homepage in the newly opened window

Sample Code for open a new tab:

// Opens a new tab in existing window

// Opens Browserstack homepage in the newly opened tab

7. Modifications in Actions Class

Actions class in Selenium is used to perform mouse and keyboard operation on a specific web element.

In Selenium 4, there are several new methods are added to the Actions class.

  • click(WebElement) –  This method is added into Actions class to replace moveToElement(element).click. It is used to click on any webelement.
  • clickAndHold(WebElement): This method is added into Actions class to replace moveToElement(element).clickAndHold(). It is used to click on an element without releasing the click.
  • contextClick(WebElement): This method replaced moveToElement(element).contextClick(). It is used to right click on an element.
  • doubleClick(WebElement): This method is replaced moveToElement(element).doubleClick(). It is used to double click on an element.

8. WebElement Screenshot:

In Selenium 3, we can take screenshot of only web page. But in Selenium 4 e can take screenshot of also a particular web element.


WebElement screenshot =driver.Findelement (By.xpath("locator"));
File srcFile = screenshot.getScreenshotAs(OutputType.FILE);
File dstFile = new File("Image.jpg");

9. Monitoring

Request tracing and logging related processes are quite optimized in Selenium 4.

Selenium 4 release date

The latest version of Selenium is Selenium 4.0 Alpha , released in March-2020.

Selenium Version      Release DateKey Features
Selenium 4.0 Alpha 5, Selenium latest versionMarch 2020Improves docker support
Selenium 4.0 Alpha 4January 2020Chrome debugging protocol
Selenium 4.0 Alpha 3July 2019Add relative locator, Moves to new grid, deleting the old standalone server
Selenium 4.0 Alpha 2May 2019Add Chromium based edge support, Add extra domains for CDP network
Selenium 4.0 Alpha 1May 2019Deprecated methods and classes removed
Selenium 3.141.59April 2019Fixed displayed content in help servlet
Selenium 3.141.0Nov 2018Nodes and hubs in a grid can be start in any order.
Selenium 3.14.0August 2018Allows temporary installation of FF extension, Add node to hub status


Selenium 3 features

Selenium 3 supports Java 8.

To perform testing on Firefox, we need to use geckodriver , which is based on the evolving W3C specification.


Upgrade from Selenium 3 to Selenium 4

To upgrade the Selenium from Selenium 3 to Selenium 4, go to official site of Selenium and download jar file of different version.

After download all jar files, import jar files into your project.

Read this link- How to import jar file into Selenium project.

Upgrade Selenium 3 to Selenium 4 in Maven Project

If you are using Selenium project with Maven, then you can easily upgrade selenium version by changing jar in POM.xml file.

Download Selenium 4 dependency from Here

Selenium 4 Maven Dependency



<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""


        <!-- -->
        <!-- -->




I hope you have enjoyed this post.

I am sure this content added some additional value in your skills.

Final word, Bookmark this post “Selenium 4 Features” for future reference.

Happy Learning 🙂


Must Read: Complete Guide of Selenium basics

Leave a Comment