What’s new in Selenium 4 and What’s deprecated

Selenium has been the most preferred tool suite when it comes to automated cross-browser testing of web applications. Selenium 4 has been gaining immense attention since the time it was publicly announced by Simon Stewart, the founding member of Selenium in August 2018. Since then, Selenium 4 has been gaining immense traction for its new makeover in terms of features and functionalities.

At a high level, the Selenium 4 tools suite comes with enhanced Selenium Grid architecture, W3C standardized protocol, revamped IDE, new APIs, relative locators, and a few others.

  • Selenium WebDriver: an open-source API that allows you to programmatically interact with a browser on an operating system the way a real user would. It was created exclusively for browser automation.
  • Selenium IDE: a record and playback automation tool.
  • Selenium Grid: save time by spreading your tests across multiple machines.

W3C compliance of WebDriver APIs

In Selenium’s earlier versions (i.e., Selenium 3), the JSON Wire Protocol was responsible for communication between the web browser and the test code. This led to the additional overhead of encoding and decoding the API requests using the W3C protocol.

A significant change under the hood for WebDriver is the complete W3C compliance of the WebDriver APIs. This standardization will eliminate the need for encoding and decoding the API requests by the JSON wire protocol for communication between browsers and test scripts. This means the WebDriver will now interact directly with the target browser. This standardization will result in more stable cross browser tests. In a nutshell, JSON wire protocol is deprecated in Selenium 4.

The native support for Opera and Phantom JS has been terminated in Selenium 4 as their WebDriver implementations are no longer active. For optimizations on Opera, QAs can rely on Chrome testing as Opera too is based on Chromium. For PhantomJS, users should use Chrome or Firefox in headless mode.

Selenium 4 new features

Enhanced Selenium Grid

Managing Selenium Grid is now smooth and easy as there will no longer be any need to set up and start hubs and nodes separately. Teams can now deploy the grid in three modes: Standalone mode, Hub and Node, Fully distributed.

The Grid will now support IPV6 addresses, and users can communicate with the Grid using the HTTPS protocol. It would be much easier to use configuration files as users can configure the Grid using human-understandable TOML (Tom’s Obvious, Minimal Language) language.

The new Selenium Grid comes with Docker support. This will enable developers or testers to spin up the containers rather than setting up heavy virtual machines. Moreover, it is redesigned in a way that will allow QAs to deploy the grid on Kubernetes for better scaling.

The Grid in Selenium 4 also comes with an enhanced user-friendly GUI, a new front-end console, which is powered by a GraphQL endpoint. This allows you to run a GraphQL query against the Selenium grid and you can extract a whole bunch of useful information. Overall, the revamped Selenium Grid will enhance the DevOps process as it provides compatibility with tools like Azure, AWS, and more.

Upgraded Selenium IDE

With Selenium 4, the IDE is revived and now its add-on is available for major web-browsers like Firefox and Chrome. The add-on for Selenium IDE is now also available on the MS store.

The new Selenium 4 IDE provides some notable features like improved GUI for intuitive user experience, improved control flow mechanism that enables testers to write better “while” and “if” conditions, enhanced element locator strategy. The automation tests recorded using the Selenium IDE can be now be exported as code for all official language bindings like Java, C#, Python, .NET, and JavaScript. This can be useful for black-box testers who want to enter the field of automation testing but have limited implementation knowledge in Selenium.

Relative Locators in Selenium 4

Selenium 4 brings an easy way of locating elements with the inclusion of relative locators like To left of, To right of, Above, Below, etc. The introduction of this new method in Selenium 4 helps locate web elements based on the visual location relative to other DOM elements.

Support for Chrome Debugging Protocol

Selenium 4 comes with native support for Chrome DevTools Protocol. This means QAs can now use Chrome development properties like Fetch, Network, Profiler, Performance, Application cache, and more. QAs can also leverage the APIs offered by Chrome DevTools to simulate poor network conditions and perform geolocation testing.

Better Window/Tab Management in Selenium 4

Selenium 4 provides a new API newWindow that lets you create a new window (or tab) and automatically switches to it. Since the new window or tab is created in the same session, it avoids creating a new WebDriver object.

Deprecation of Desired Capabilities

Desired Capabilities were primarily used in the test scripts to define the test environment (browser name, version, operating system) for execution on the Selenium Grid. In Selenium 4, capabilities objects are replaced with Options. This means testers now need to create an Options object, set test requirements, and pass the object to the Driver constructor.

Modifications in the Actions Class

Actions class in Selenium is primarily used to simulate input actions from mouse and keyboard on specific web elements. In Selenium 4, several new methods have been added to the Actions class: click(WebElement) | clickAndHold(WebElement) | contextClick(WebElement) | doubleClick(WebElement) | release()

When it comes to Selenium 3 vs Selenium 4 comparison, the introduction of the WebDriver W3C protocol (and retiring of JSON Wire Protocol) is one of the significant architectural changes that will redefine the Selenium framework experience.

Apart from this significant under-the-hood change, considering all the points above, one can conclude that the features in Selenium 4 appear quite promising in terms of making the test process easier.

Leave a Reply

Your email address will not be published.