We use cookies to ensure that we give you the best experience on our website. By continuing to browse or closing this banner, you acknowledge that you have read and agree to our Privacy Policy and Terms of Service.

Coding Jag - Get The Best News Around Test, DevOps & Automation To Your Inbox, Weekly!

Subscribe Now >

Selenium 4

Selenium 4, the latest version of Selenium, has become the talk of the town since its announcement in 2018. Though it is currently available in the Alpha Version, and there is no official announcement on the 'final' release date. Still, that doesn't deter Selenium users and test automation enthusiasts from exploring and experimenting with it. And why not? After all, Selenium 4 is packed with a host of new features and enhancements than its predecessor. If you are thinking of trying Selenium 4, this tutorial will help.

Selenium 4 New Features

Selenium 4 IDE TNG

The record and playback feature of Selenium is taken to a whole new level with advanced and rich features. Previously Selenium only used to support Chrome. But with the latest selenium version, i.e., Selenium 4, a plugin will allow you to run Selenium on any browser. Also, a user can now declare their own locator strategy.

There is also a new CLI runner - which is based on Node JS, instead of the old HTML based CLI runner.

  • It has the ability to execute test cases in parallel and provide information like passed and failed test cases, the time required, etc.
  • The new IDE runner is completely based on WebDriver.

WebDriver API Became W3C Standardized in Selenium 4

WebDriver API is not only used in Selenium but in multiple automation tools as well. Mobile testing tools like Appium depend heavily on it for web testing of mobile applications. The most highlighted change with the latest selenium version, i.e., Selenium 4, is the standardization of the WebDriver API with respect to W3C standards. This means it can now be implemented across different software without any compatibility issues.

Previously, when web testing was performed using Selenium 3, browser communication was performed via JSON wire protocol from the local end, which required API encoding and decoding. Not anymore, though, as with Selenium 4, you won’t have to decode and encode your API request using the W3C protocol. Java bindings, however, will be backward compatible while being focused on the W3C protocol. Yet, support for PhantomJS and Opera has been removed since WebDriver implementation for those browsers are not anymore developed.

Mostly because of the W3C standardization of WebDriver, the release date of Selenium 4 got postponed. But keeping in mind the new features, it’s worth waiting. Once the specification is complete, the remaining job will fall on the hand of browser vendors who will decide how they will implement the new WebDriver API. This is a more logical approach since the internal architecture of browsers is better known by the vendors.

Selenium 4 Comes With an Improved Grid

If you have worked with Selenium earlier, you must have faced the configuration challenges and the issues that arise when you try to set it up for the first time. The latest selenium version, i.e., Selenium 4, makes you free from the installation worries. It allows you to execute test cases in parallel on multiple browsers, systems, and operating systems. The 2 main elements of the new Selenium Grid are:


A test machine on which you can execute the test cases.


The server acts as a central point to control all other machines available in the network. Selenium Grid has only one hub whose purpose is to allocate the test case execution to a specific node.

Till version 3, testers faced a lot of difficulties while connecting the hub with nodes. But in the latest selenium version, Selenium 4, the process is much easier. The moment you start the Selenium Grid, it will act as both node and hub. There is also better Docker support and no chance of thread safety bugs. The new Selenium 4 Grid server also allows the user to output logs in a single line format in JSON.

A Better UI in the latest Selenium Version

A user-friendly interface is a must-have feature for all applications. Selenium has done a lot to improve its UI in the latest selenium version, Selenium 4. The grid UI is more user-friendly, has relevant information about the capacity to execute test cases or details about the running sessions, etc.

Better Observability

Logging with hooks and request tracing is also improved since debugging or observability is no longer for DevOps only. Automation testers will now have a better hold on debugging with the improved UI.

Documentation For The Latest Selenium Version

Documentation is essential for any project to succeed. Since the release of Selenium 2, the documents were not updated for years. Meaning, anyone willing to learn Selenium had to rely on the old tutorials, in which many of the features changed in version 3. With Selenium 4, SeleniumHQ promised us to deliver a refreshed and updated documentation, which is the most anticipated update among test automation engineers.

1. Upgrading From Selenium 3 To Selenium 4?

Selenium 4 offers several new features like relative locators, Chrome DevTools, improved Selenium Grid, and more, making it a worthy upgrade over Selenium 3. In this chapter, we will cover in detail how to upgrade from Selenium 3 to Selenium 4 for Java language bindings. If you are using Maven for the project, upgrading to Selenium 4 is about fetching the Selenium 4 from the Maven Repository and adding the same in pom.xml.

Apart from Java, it is easy to upgrade to Selenium 4 for Selenium supported languages like Python, C#, PHP, Ruby, and JavaScript.

Learn More!!

Ready to upgrade from Selenium 3 to Selenium 4? Check out our blog on How To Upgrade From Selenium 3 To Selenium 4?.

2. What’s New In Selenium 4 & What’s Being Deprecated?

Selenium 4 is packed with excellent features like relative locators, improved Selenium Grid architecture, and a super-useful Selenium IDE, to name a few. The most significant under-the-hood change in Selenium 4 is W3C compliance of WebDriver APIs, which boils down to less flaky and more stable cross browser tests. In this chapter, we will cover some of the significant enhancements in Selenium 4 in detail. Also, we will cover some of the features that are deprecated and changed in this newest version.

Learn More!!

To learn more check out our blog on What Is New In Selenium 4 And What Is Deprecated In It?.

3. Selenium 4 With Python

The Alpha release 7 (Selenium-4.0.0.a7) for Selenium 4 Python was released in the second week of November 2020. Do you know that the Alpha Release-7 of Selenium for Python is touted to be the last Alpha release, post which developers can expect only Beta releases? Selenium Python developers can rejoice as Selenium-4.0.0a7 offers several cool features with Selenium 4 for Python.

In this chapter, we will show you how to install Selenium 4 for Python. Also, we walk you through the Python Selenium 4 features and how you can use those features in your Python Selenium tests.

Learn More!!

To learn more you can check out our blog on Selenium 4 With Python.

4. Selenium 4 Is Now W3C Compliant

Selenium users can expect less flaky, more consistent, and more stable Selenium automation testing with WebDriver W3C protocol in Selenium 4. Though JSON Wire Protocol will retire in Selenium 4, the possibility is that your tests might be using W3C protocol even though they are not tested on Selenium 4. This is because the WebDriver W3 protocol is available in Selenium v3.8 onwards. The catch is that the WebDriver implementation is backward compatible (i.e., if the tests do not work as expected on W3C protocol, they are tested against the JSON Wire Protocol).

Before we dive into what W3C compliance in Selenium 4 means for the Selenium framework users, let’s first discuss WebDriver W3C Protocol in Selenium 4.

WebDriver W3C Protocol in Selenium 4

‘WebDriver W3C’ is the newly introduced protocol in Selenium 4. It has received an endorsement from W3C (World Wide Web Consortium), the community which works on web standards development. W3C Working Draft and W3C Editor’s Draft are excellent resources to keep a tab on the progress of WebDriver W3C Protocol.

In Selenium 4, WebDriver W3C Protocol replaces the older JSON Wire protocol. It essentially means that you no longer need to encode and decode the API request using the W3C protocol, and the tests can directly communicate with the web browser. The information will not be transferred by sending and receiving HTTP requests and HTTP responses, respectively.

As seen from WebDriver W3C Protocol's architecture, there is a direct information exchange between the client and server, without the need for the JSON Wire Protocol. As Selenium WebDriver and web browsers use the same protocol, automated Selenium testing will consistently execute tests between different browsers. And Flakiness in web automation can be considerably reduced if a standard protocol is used.

With WebDriver W3C Protocol in action, automation testers would no longer need to change the automation test scripts to work across different web browsers. Stability and Consistency in tests are the two significant advantages of WebDriver W3C protocol in Selenium 4.

Learn More!!

To learn more about Selenium 4 and its Support To W3C WebDriver Protocol, check out our blog on Selenium 4 Is Now W3C Compliant.

5. How To Use Selenium 4 Relative Locator?

Selenium 4 Alpha now offers a new type of locator called the Relative locator. The relative locator in Selenium 4 is an exciting advancement using which developers can access nearby web elements with fewer lines of implementation — wondering how you can use it to pace up your test cycles? Let's find out.

Learn More!!

To learn more check out our blog on How Selenium 4 Relative Locator Can Change The Way You Test?.

6. Selenium Grid 4 Tutorial For Distributed Testing

Selenium Grid has been an integral part of automation testing, as it lets you perform test case execution on different combinations of browsers, operating systems (or platforms), and machines. It also enables you to perform parallel execution to expedite the cross browser testing process.

Selenium Grid 4, the successor to Selenium Grid 3, has been in the Alpha stage for the last couple of months. The developer community was very excited regarding Selenium 4 (Alpha), and the addition of several useful features such as Selenium 4 Relative Locator has helped accelerate activities related to Selenium test automation. Selenium 4 Alpha features an improved Selenium Grid design; the significant change is introducing a ‘fully distributed mode.’ In this chapter, we take a deep dive into Selenium 4 and the vital architectural differences compared to Selenium 3.

Architecture of Selenium Grid 3

The Grid 3 version consists of two major blocks – Hub and Node, as shown in the graphic below.

Architecture of Selenium Grid 4

Earlier versions of the Grid only had two components – Hub and Node, but that has changed with Selenium Grid 4. Selenium Grid 4 consists of four processes – Router, Distributor, Session Map, and Node.

Here is the top-level architecture diagram of Selenium 4 Alpha (in a Fully Distributed Mode):

Learn More!!

Ready to perform distributed testing with Selenium Grid 4? Check out our Selenium Grid 4 Tutorial For Distributed Testing.

Join 400,000+ developers & testers who rely on LambdaTest for web testing.

Start Testing