Blog

What’s new in Selenium 4 – Key Features and Differentiators

Published: 23 Jun 2021

What’s new in Selenium 4 – Key Features and Differentiators

Last Updated: 13 Sep 2021


Today, every business needs high-quality software in less time, and to achieve high-quality software, organizations need effective software testing by leveraging automation testing. With agile and DevOps methodologies on the go, software automation testing is taking new heights. The test automation process helps to quicken the testing process with re-usable test suites, and there are many test automation frameworks used by QA testers.

1.  Selenium Tool Overview
2.  Major differences between Selenium 2 and Selenium 3
3.  What is Selenium 4?
4.  What is the difference between Selenium 3 and Selenium 4?
5.  What are the new features of Selenium 4?
6.  What is deprecated and changed in Selenium 4?
7.  How can TestingXperts (Tx) help businesses with their Selenium Automation Testing need?
8.  Conclusion

Selenium Tool Overview

Though there are varieties of automation frameworks available, one framework that is widely used by testing teams across the globe for automation testing is the selenium framework. Different versions of Selenium released in the market include Selenium 1 (Selenium RC), Selenium 2, Selenium 3, and the recently updated Selenium 4 beta. Selenium tool has a marked presence in the automation testing world due to its open-source nature and numerous features that make the testing process faster when compared to other tools.

Selenium 4

Selenium is the most preferred tool suite that is used to automate tests for web applications. The tool has the capability to operate across different browsers and operating systems. Selenium  is an automation test suite that has various components given below:

– Selenium Core

– Selenium RC

– Selenium IDE

– Selenium Grid

– Selenium Webdriver

Selenium 2 and Selenium 3 have been in use for many years now, and have some differences between them given in a tabular form below.

Major differences between Selenium 2 and Selenium 3

Selenium 2
Selenium 3
Selenium 2 supports Selenium WebDriver and Selenium RC (Selenium 1). It uses Selenium Core for backward compatibility Selenium 3 supports Selenium Grid and Selenium WebDriver.
In addition, the Selenium core is removed but supports Selenium RC indirectly through a back-end web driver.
Firefox is the default browser, and it supports Firefox browser versions below 47.0.2 A separate driver for Firefox has been introduced, which is called GeckoDriver. It supports 47.0.2 and above versions
It supports headless HTMLUnit browser It does not support headless HTMLUnit browser
It is not W3C (World Wide Web Consortium) standard It has become a W3C (World Wide Web Consortium) standard
It supports and automates Mobile applications using AndroidDriver and iPhoneDriver. Mobile automation support is removed i.e. AndroidDriver and iPhoneDriver have been removed from the Selenium WebDriver library. One can use tools like Appium for mobile automation testing

What is Selenium 4?

What is Selenium 4 tool

Selenium 4 Beta 1 is the latest version of Selenium that has been released on 15th February 2021. This new tool suite comes with advanced features such as Selenium grid, W3C compliance, advanced IDE, New APIs, and many more. Selenium 4  is a suite of tools that has various components in it as given below:

Selenium WebDriver

It is an open-source API that allows the creation of robust browser-based regression automation suites and tests, scales, and distributes scripts across many environments. The webDriver also allows to interact with the browser just like a real user

Selenium IDE

It is a Chrome and Firefox add-on that simply records and playbacks the user interactions with the browser

Selenium Grid-

It allows saving time by distributing and running tests on multiple browsers, operating systems, and machines. It enables the management of multiple environments from a central point.

What is the difference between Selenium 3 and Selenium 4?

Typically, there are some significant differences between Selenium 3 and Selenium 4 listed below:

Selenium 3
Selenium 4
In Selenium 3, the chrome driver extends directly to the Remote Web Driver. In Selenium 4 Chrome driver class extends to Chromium Driver, which has some predefined methods to access the dev tool.
In Selenium 3, JSON Wire Protocol was the major mode of communication between the test code and the browser. Effectively, Selenium 4 uses the WebDriver W3C protocol as it has W3C compliance.
A difficult task in Selenium 3 was that testers were always to start the Hub and Node jars each time to perform automation testing on the Grid. In Selenium 4, the testers need not start the hub and node jars every time they perform the automation testing.

What are the new features of Selenium 4?

Selenium 4 Features

1. WebDriver became W3C (World Wide Web Consortium) Standardization:

Selenium 4 WebDriver updates

• Selenium WebDriver is now W3C Standardized, and this WebDriver provides a friendly and flexible API for browser automation

• W3C standard encourages compatibility across various software implementations of WebDriver and API.

• Most of the W3C standards revolve around the standardization of web technologies, making the framework more stable and reducing complexities across browsers.

2. Selenium Grid enhanced with updates:

Selenium 4 Grid updates

• The earlier versions of Selenium Grid were complex as it was based on Hub and Node(s) architecture. The Hub and Node(s) need to be separately started when performing automation tests.

• In Selenium 4, Hub and Node (s) are packed in a single jar file, which means once the server starts, it acts as both Hub and Node.

• The Grid also supports IPV6 addresses, allowing its users to communicate with the Grid using the HTTPS protocol with support for TLS connections.

• Selenium Grid has a more scalable and traceable infrastructure that supports four processes: Router, Session Map, Distributor, and Node.

• The new Selenium Grid comes with Docker support, allowing testers and developers to spin up containers rather than setting up heavy virtual machines.

The above feature gives users the flexibility of deploying Selenium Grid on Kubernetes. Selenium Grid 4 can be beneficial and can result in the DevOps process as it supports tools like AWS, Azure, and more.

3. Selenium 4 IDE upgraded:

Selenium 4 IDE

• Selenium IDE is a record and playback tool that was available as an add-on for Firefox in the earlier Selenium versions but got deprecated as the latest Firefox versions were standardized under the Web Extension Mechanism.

• Selenium 4 version has it as an add-on for major web browsers such as Firefox, Chrome, MS Edge, etc.

• The latest update has a user interface to deliver an intuitive user experience, and it also comes with a SIDE tool, i.e., Selenium IDE runner, that allows QAs to run projects on a node.js platform.

• This feature enables QA teams to run cross-browser tests on local or Cloud Selenium Grid. It has an improved control flow mechanism that allows testers to write better “while” and “if” conditions.

• Another feature includes the code for test cases recorded using updated Selenium IDE can be exported to the desired programming language like Java, C#, Python, .NET, and JavaScript, thus giving more flexibility to testers.

4. Relative Locators for automation scripts

automation scripts selenium 4

• Selenium 4 brought an easy way of locating elements with the inclusion of relative locators.

• Relative locators, also referred to as Friendly locators, help locate WebElements near to, left of, right of, above, and below a specified element.

• It supports the usage of withTagName (in Selenium 4 Java) or with_tag_name (in Selenium 4 Python). It helps locate web elements based on the visual location relative to other DOM elements.

5. Chrome Debugging Protocol (CDP)

Selenium 4 Features

• Selenium 4 provides native support for Chrome DevTools Protocol (CDP) through the DevTools interface.

• It allows QAs to use Chrome development properties like Fetch, Network, Profiler, Performance, Application cache, and more.

• This feature helps developers and QAs to test and resolve critical bugs for specific web pages faster and on the fly.

• QA teams can also leverage the APIs offered by Chrome DevTools to simulate poor network conditions and perform geolocation testing.

• This feature also allows testers to check how the product performs under varying network conditions such as 3G, 4G, 5G, etc.

6. Multiple Windows and Tabs Management

Selenium 4 testing feature

• While testing the software testers have to switch across multiple windows, tabs, or applications in a single test flow.

• In the earlier versions on Selenium, it was not easy to manage multiple windows or tabs as it required testers to create a new Web Driver object. Post which used to switch to the new window (or tab) using the unique WindowHandle to perform subsequent actions in that window (or tab).

• But this has improved in Selenium 4. The latest version of Selenium comes with a new API – newWindow that allows testers to create and switch to a new window/tab without creating a new WebDriver object in a single test flow or session.

7. Telemetry and GraphQL:

Selenium 4.0  New Features

A framework called Open Telemetry has been added to Selenium Grid. This feature brings more observability into Grid as it allows testers to see what’s happening inside the Grid, especially when something goes wrong while running the test.

Also, the Grid now has a new front-end console, which is powered by a GraphQL endpoint. It allows testers to run a GraphQL query against the Selenium grid, either distributed or on the local machine. This feature helps testers extract useful metrics and information from the Grid to fulfill the monitoring needs.

Joe Colantonio in his latest article on “What is Selenium 4? The latest in Automated Browser Testing” has in detail explained about all these above features and the importance of Selenium 4.

8. Improved Documentation:

Selenium 4 New Feature

With the earlier versions of Selenium, users use to face a lot of difficulties with the documentation part as there were some lackings in the documentation capabilities of Selenium.

This has significantly improved in the latest versions of Selenium. Selenium 4.0 provides better documentation capabilities.

• Its documentation part has been completely revamped with a neat UI that allows users to easily navigate to the desired section of the page and covers all information about tools and APIs that comes under the Selenium umbrella.

• This will help testers gain information about all the features required to get started with selenium testing.

What is deprecated and changed in Selenium 4?

Selenium 4 automation testing

1. Deprecation of Desired Capabilities

Desired capabilities were primarily used in the test script for defining the test environment (browser name, version, operating system) for executing tests on Selenium Grid. This has now been replaced with Options. It means testers now have to create an Options object, set test requirements, and pass the object to the Driver constructor. Below listed are the Options objects that have been included in Selenium 4.0

Firefox – FirefoxOptions

Chrome – ChromeOptions

Internet Explorer (IE) – InternetExplorerOptions

Microsoft Edge – EdgeOptions

Safari – SafariOptions

2. Changes in the Action Class

Action class is used to simulate input actions from a keyboard or mouse on specific web elements. For e.g, Left-click, Right-click, Double-click, etc.

Following changes have been made to Action Class in Selenium 4.0

• click(WebElement) has replaced moveToElement(onElement).click() {}

• clickAndHold(WebElement) has replaced moveToElement(onElement).clickAndHold()

• contextClick(WebElement) has replaced moveToElement(onElement).contextClick()

• doubleClick(WebElement) has replaced moveToElement(element).doubleClick()

• release() which was ealier a part of org.openqa.selenium.interactions.ButtonReleaseAction class has now been moved to Action class as per new update of Selenium 4.0

3. Deprecation of FindsBy

In the older version of Selenium, FindsBy interfaces were a part of org.openqa.selenium.internal package. It contains findElement(By) and findElements(By) methods, implemented by the RemoteWebDriver class. However, these have now been deprecated in Selenium 4.0.

4. Changes in FluentWait

In Selenium 4.0, the methods withTimeout() and pollingEvery() that are a part of the FluentWait class have been modified. The pollingEvery() method only accepts one parameter – Duration that can be in Seconds, MilliSeconds, NanoSeconds, Hours, Days, etc. Similarly, the withTimeOut() method also accepts only one parameter – Duration.

How can TestingXperts (Tx) help businesses with their Selenium Automation Testing need?

Selenium testing - TestingXperts

Enterprises must note that Selenium testing should be done by experienced selenium test automation engineers. To get the complete benefits of selenium testing, businesses can partner with an experienced automation engineer from an independent testing services provider.

TestingXperts (Tx) is a NextGen QA and Software testing company that has dedicated teams with core expertise on all industry-leading tools like Selenium, HP UFT, Coded UI, TestComplete, Ranorex, Appium, etc. We have a global presence with offices in the USA, Canada, UK, Netherlands, Singapore, and test labs strategically placed in multiple locations in India (Chandigarh, Hyderabad, and Bangalore).

Conclusion

Today, almost every business has realized the importance of automation testing. And to fulfil this growing demand for automation testing numerous test automation tools and frameworks are made available in the market today. Out of all the available automation testing frameworks and tools, one tool that is widely used by testers all across the globe is Selenium. Recently a new update of Selenium was rolled out in the market that gained a lot of attraction from the audience. The latest Selenium version i.e., Selenium 4.0 has several additional benefits like seamless integration, parallel testing, cross-browser testing, better documentation, etc. that make Selenium testing much easier. Businesses must read all the features and differentiators of Selenium 4.0 as mentioned in this blog before investing in any automation testing framework or tool.

Get in touch

During your visit on our website, we collect personal information including but not limited to name, email address, contact number, etc. TestingXperts will collect and use your personal information for marketing, discussing the service offerings and provisioning the services you request. By clicking on the check box you are providing your consent on the same. In the future, if you wish to unsubscribe to our emails, you may indicate your preference by clicking on the “Unsubscribe” link in the email.