What is New In Selenium 4?

New Selenium 4

The wait is over. Selenium 4 has made an official release on October 13, 2021.

Selenium provides tools that can interact with browsers and automate browser actions like click, input, select, navigate, etc., with the help of scripts. Selenium is ideal for beginners as it has a broad community of support online.

Understanding automation is the first step towards automation testing. The Selenium Software suite is not just a single tool but a variety of tools that cater to an organization’s specific Selenium QA software testing needs.

Selenium is the most popular suite of tools for automated testing web applications across multiple browsers. The public announcement of Selenium 4 was made in 2018. The new features and functionality have gained Selenium 4 a significant amount of popularity since then.

Special tools offered in Selenium 4 are the enhanced Selenium Grid, W3C-standard protocols, a revamped IDE, new APIs, relative locators, and other enhancements.

Before moving to the new features of Selenium 4, let us look at what Selenium 4 is.

What Is Selenium 4?

Selenium 4 is the brand new and improved version of the automated testing framework, Selenium, with some excellent features and improvements. One of the essential features or improvements in Selenium 4 is that now with Selenium WebDriver, you can directly interact with the browser. You are not supposed to use the JSON wire protocol as earlier.

In August 2018, Simon Stewart, the founding member of Selenium, announced Selenium 4. Since then, it has received immense attention. Still, developers and Selenium explorers can download the Alpha version of Selenium 4 to check out its features.

So, is there anything new in Selenium 4, and how advanced are its features compared with that of Selenium 3?

The new features in Selenium 4 are both excellent and exciting. You all must have heard, the official Selenium 4 release came out recently, and you must be excited to know about all the new features.

What’s New In Selenium 4?

The WebDriver APIs are fully compliant with the W3C standard, which is a significant change. Introducing this standard eliminates the need to encode and decode API requests through a JSON wire protocol while communicating between browsers and test scripts in Selenium 3 and earlier releases. In other words, the WebDriver now interacts directly with the target browser.

As a result of this standardization, cross-browser testing will be more stable. Existing users will not be affected by the change in the protocol since popular browser drivers such as ChromeDriver and GeckoDriver are compliant with W3C standards. Selenium 4 deprecates the JSON wire protocol.

Relative Locators is another highly anticipated feature added in Selenium 4. The returned elements are now sorted according to proximity to make the results more predictable. In addition, you can use any selector (not just tag name) to locate any relative locator.

Work on NetworkInterceptor has also begun in this release. Once it is complete, the functionality will come as part of the new ChromeDevTools feature and allow testers to stub out network requests!

Several professionals are looking forward to the Selenium community and Selenium 4 with its super-improved Grid.

  1. Optimized and Improved Selenium Grid

Distributed testing is done by a system called Selenium Grid, which is based on a hub-and-spoke architecture. It is necessary to start the Hub and Nodes separately before you can perform the automation tests. The Hub and Node will be packaged in one jar file, so this will become obsolete. When the server starts, it will act as both Hub and Node.

In Selenium Grid’s earlier releases, you could test for Router, Session Map, and Distributor processes. Through the Selenium Grid 4, which features greater scalability and traceability, four cycles are supported – Router, Session Map, Distributor, and Node.

Grid users will now communicate with the Grid via HTTPS, and this will support IPV6 addresses. The Selenium Grid can be configured in human-understandable TOML (Tom’s Obvious, Minimal Language) language, thus making it much easier to use configuration files with the improved Grid.

See also  Six Useful Tips for Food Packaging Designs

Selenium 4’s Grid benefits from an improved user interface. VMs can now run Selenium Grid 4 using Docker; previously, it had trouble running on Windows. The Selenium Grid is also deployable on Kubernetes, enabling users to have a flexible deployment strategy. Selenium Grid 4 can support tools like AWS, Azure, and more, which can be beneficial in the DevOps process.

  1. Selenium IDE Enhanced

An automation test engineer who is familiar with record-and-playback testing would be familiar with Selenium IDE. It is a pretty straightforward, turn-key solution that is web-ready and works in its original state. There were not enough exciting features in Selenium IDE, which was at first only available as a Firefox extension.

It is finally possible to use the Selenium IDE on major web browsers like Chrome and Firefox with Selenium 4, as it is now integrated into Selenium 4. A plugin (or web extension) for Selenium IDE will soon be released on the MS Edge Store.

Utilizing the Selenium IDE can create better tests thanks to its control-flow mechanism (when using if-else, while, etc.). As well as the sleek and user-friendly Selenium IDE interface, Selenium 4 also includes the Selenium IDE Runner tool, which lets you run side projects on Node.js. This tool can run cross-browser tests in parallel, either from an on-premise test database or a cloud-based Selenium grid.

The backup element locator strategy is used when the web element cannot be located using the specified element locator. By executing tests from the Selenium IDE, you can ensure they are stable and reliable.

Testing automation can be recorded and exported as code for all the official language bindings using the Selenium IDE, including Java, C#, Python, .NET, and JavaScript. Testing black-box software can be helpful for testers with limited Selenium implementation knowledge or testers seeking to enter the field of automation testing. Using the Selenium IDE, you can easily customize the configuration files (in .yml format) used by the SIDE runner to enable parallel testing.

Selenium IDE’s remarkable development is its rewrite to make it an Electron app, enabling it to work as a standalone app. By tightly binding with the browser, this would make test recording more powerful and feature-rich because we would be able to listen out for events within the browser.

  1. Relative Locators

There was no straightforward method (or specific) of locating WebElements within the context of nearby elements in Selenium 3. One of the Selenium 4 Alpha features is the introduction of relative Selenium locators, encouraging WebElements to be located based on their visual position relative to other DOM elements.

Local locators, also known as Friendly locators, allow you to locate web elements near, to the left, right, above, or below a specified part. For Selenium 4 Java and Python, the relative locator methods are supported with a name (in Selenium 4) and with_tag_name (in Selenium 4) parameters.

  1. Chrome Dev Tools

As part of the ‘DevTools’ interface, Selenium 4 (Alpha) supports Chrome DevTools natively. Currently, Chrome DevTool support is available only for Chrome browsers. Chrome Development tools are used for getting Chrome Development properties such as Fetch, Application Cache, Network, Performance, Profiler, and so forth.

The Chrome DevTools, a collection of web development tools, connects QA engineers and developers with APIs that let them modify pages on the fly and diagnose problems faster. Website speed and efficiency are improved as a result of these features.

The DevTools APIs of Chrome can be used to simulate network conditions and geolocation.

Selenium 4 Alpha’s native support for Chrome DevTools Protocol is one of its most promising features, which would accelerate the development of websites with features such as geolocation testing, simulating various network conditions, and more.

  1. Chrome Debugging Protocol Support
See also  Tips For Hiring the Best Bail Bond Company 

As part of Selenium 4, developers can access the Chrome DevTools Protocol. Chrome development properties like Fetch, Network, Profiler, Performance, Application cache, and more can now be used by Quality Assurance teams. Additionally, Chrome DevTools features APIs that QAs can use to simulate poor network conditions and conduct geolocation tests.

Developers and quality analysts can test and resolve critical bugs for specific web pages more quickly and on the fly using this API.

  1. Selenium 4 Offers Better Window/Tab Management.

In test automation, there are several instances where one would have to open a particular link in any new tab or window for completing special tasks. It was necessary to create a new driver object in Selenium 3 to accomplish this, then to switch operations using the WindowHandle method to complete a series of subsequent tasks.

This is expected to change with Selenium 4 since it features a new API and a new window that allows users to perform. It eliminates the need to create a new WebDriver object each time you create or switch to a new window or tab.

Has Selenium 4 Changed and Deprecated Certain Features?

Selenium 4 provides a stable and feature-rich test automation platform with the help of some long-awaited improvements. Because Selenium is compliant with the W3C protocol, you can expect it to continue handling browser automation for some time to come. When combined with all the new features, usability improvements, and performance enhancements, users can feel confident that Selenium will remain relevant for many years to come.

In addition to the significant enhancements in Selenium 4, the 4th release of Selenium also includes a few deprecations. The test code migration from Selenium 3 to Selenium 4 will only be affected by breaking changes in Selenium 4.

For Java and .NET, the Selenium 4 changelogs provide a good starting point for understanding what’s new and deprecated in Selenium 4.

The Following Items Have Been Deprecated In Selenium 4:

  • DesiredCapabilities Are Being Deprecated

The DesiredCapabilities are primarily used in Selenium 3 when working with RemoteWebDrivers. Set up the browser capabilities before running tests on a Selenium Grid like LambdaTest, which runs the tests in the cloud.

As a result, Capabilities objects have been replaced with Options objects, and we must create an Options object before using the Driver class. The Selenium 4 framework requires us to set the test requirements (i.e., browser and Operating System combinations) and pass the object to the Driver constructor. For purposes of developing browser-specific capabilities, the following Options object will be used:

  • Chrome – ChromeOptions
  • Firefox – FirefoxOptions
  • Internet Explorer (IE) – InternetExplorerOptions
  • Safari – SafariOptions
  • Microsoft Edge – EdgeOptions
  • The Actions Class Adds New Features

Several methods are available in the Selenium Actions Class to perform a single action or a set of actions on DOM elements. The two broad categories of actions are mouse actions (such as clicking, double-clicking, etc.) and keyboard actions (such as keyUp, keyDown, and sendKeys).

A new Actions class replaces the classes under the org.openqa.selenium.interactions package in Selenium 4.


Taking all the points above into consideration, one can conclude that the features in Selenium 4 are pretty promising in terms of making the test process more efficient. However, we should perform tests in real device environments for accurate test results, irrespective of the used Selenium version.

Suppose you are looking to take maximum advantage of the Selenium 4 Alpha features. You can execute tests on LambdaTest Selenium Testing Grid, a scalable and reliable Selenium 4 Grid that can run tests simultaneously across different browsers and OS combinations. On the Selenium 4 Grid, you can conduct geolocation testing in 27+ countries using this approach.

Although Selenium 4 is still in the Alpha phase, the recently introduced features help accelerate testing activities, which the previous version could not do.


Please enter your comment!
Please enter your name here