Facebook

Selenium 4 is released! What must every QA know?

Back in August of 2018, the whole Test-automation community had been struck by the big news: Simon Stewart, the founding member of Selenium, had officially confirmed the release date and some of the major updates for Selenium 4 at the Selenium Conference in Bangalore.

Finally, On October 13, 2021, Selenium 4.0 was officially released. You can download Selenium 4.0 from the official website or GitHub. It is available for Java, .Net, Python, Ruby, and Javascript.

Why Selenium 4.0 is important

If you think that Test automation engineers are the only people in the world who should care about the major update of Selenium, you’re wrong. Of course, Selenium has become the industry standard for implementing custom automated tests and is considered to be the first go-to solution for every web application that has grown out of an approach where manual testing could have solved the majority of the problems. But what is often left out of the picture is that businesses that heavily rely on Selenium are not the only ones that have automation QA engineers on their team but also the ones that have integrated codeless automation testing tools based on Selenium.
Selenium-based codeless testing has become a real lifesaver for every business that realizes the importance of automation but doesn’t have in-house QA experts who would be able to implement it. Such tools not only make the deployment possible for anyone with a basic understanding of web browsers but also make it possible to run regression tests, do synthetic monitoring and load testing without any knowledge of the Selenium framework at all.

A perfect example of such codeless automation software is CloudQA. On top of Selenium, we’ve developed a tool that requires zero effort from the team, integrates with the third-party applications, makes building test cases easier than ever before, monitors your web page performance 24/7, and costs less than hiring a junior manual tester.

If you want to learn more about the benefits of Selenium-based codeless automation tools, get a free demo.

Now, Let’s look at some of the new and exciting features Selenium 4.0 has to offer.

Selenium 4 major changes

W3C Web Driver Standardization

First of all, Selenium 4 WebDriver is completely W3C Standardized. The WebDriver API has grown to be relevant outside of Selenium and has been used in multiple tools for automation. For example, such mobile testing tools as Appium and iOS Driver heavily rely on it. The W3C standard will also encourage the compatibility across different software implementations of the WebDriver API.

Here’s how Selenium Grid communicates with the Driver executables in previous versions:

Adopting-New-Protocol

A test in Selenium 3.0 communicates with the browser at the End node through the JSON wire protocol at the local end. This approach requires encoding and decoding of API.

With the updates we’re expecting to see in Selenium 4, the test will directly communicate without any encoding and decoding of API requests through W3C Protocol. Although JAVA bindings will be backward compatible, the focus will remain more on the W3C Protocol. The JSON wire protocol will no longer be used.

There are multiple contributors to the W3C WebDriver specs, and the whole process can be seen on GitHub.

Selenium 4 IDE TNG

Selenium-4-IDE-TNG

The Selenium IDE support for Chrome is available now. You can download it from- https://selenium.dev/selenium-ide/ 

As we all know that Selenium IDE is a record and playback tool. It will now be available with the following, much richer and advanced features:

  • New plug-in system. Any browser vendor will now be able to easily plug into the new Selenium IDE. You’ll be able to have your own locator strategy and Selenium IDE plug-in.
  • New CLI runner. It will be completely based on NodeJS, not the old HTML-based runner, and will have the following capabilities:
    • WebDriver Playback. The new Selenium IDE runner will be based entirely on the WebDriver.
    • Parallel execution. The new CLI runner will also support parallel test case execution and will provide useful information like time taken, and the number of test cases passed and failed.

 

Looking for the best Selenium IDE Alternative? Checkout CloudQA!

Improved Selenium Grid

Anyone who has ever worked with Selenium Grid knows how difficult it is to set up and configure. Selenium Grid supports test case execution on different browsers, operating systems, and machines providing parallel execution capability.

There are two main elements of the Selenium Grid: Hub and Node.

Hub acts as a server, a central point to control all the test machines in the network. In Selenium Grid there is only one hub that allocates the test execution to a particular node based on capability matches.

Node, in simple words, is a test machine where test cases actually run.

Selenium-Node-Container

Until now, the setup process of the Selenium Grid has often caused testers difficulties with connecting a node to the hub.

In Selenium 4, the grid experience has become smooth and easy since there will no longer be any need to set up and start hubs and nodes separately. Once you start a Selenium server, the grid will act as both a hub and node. It also supports a fully distributed mode, for use in modern infrastructure running Kubernetes. The new Selenium grid comes with improved security as part of the infrastructure.

The Selenium grid has an updated UI placed on top of a GraphQL model that is accessible to everyone. VNC previews are now available so that you can get a feel of what’s happening inside a running session. OpenTelemetry support has also been integrated into the Grid, so now you can find out exactly what’s going on, where, and when.
For more details on Selenium Grid, we suggest checking out the selenium grid.

Selenium provides three types of grid-

  1. Standalone Mode
  2. Hub and Node
  3. Fully Distributed

The new selenium server jar contains everything which is required to run a grid. It has all the dependencies. The new grid also comes with Docker Support. For now, the docker integration doesn’t make use of UNIX domain sockets, so ensure your docker daemon is listening on port 2375.

For more details, refer to- https://github.com/SeleniumHQ/seleniumhq.github.io/commit/82a548054e6ce3c486b98929ff6e4e4fa205d71a

Better Observability

“Passive observability is the ability to do descriptive tracing.”  
– Simon Stewart

Observability, logging, and debugging are no more confined to DevOps now. As part of the release, the request tracing and logging with hooks is improved to provide automation engineers a hold on debugging.

Refreshed Documentation

Documentation plays a key role in the success of any project. Selenium docs have not been updated since the release of Selenium 2.0. Meaning, that anyone trying to learn Selenium in the past several years, had to use the old tutorials.

So, naturally, the renewed and up-to-date documentation, which SeleniumHQ provides us along with the 4.0 version, has become one of the most important Selenium updates within the testing automation community.

Improvements in Selenium 4.0 

ChromiumDriver and DevTools:

In Selenium 3, EdgeDriver and ChromeDriver have their own implementation inherited from RemoteWebDriver class. In Selenium 4 Chromedriver and EdgeDriver are inherited from ChromiumDriver. ChromiumDriver class has predefined methods to access the dev tools. Consider the below code snippet-

ChromeDriver Script

The above code creates a session to the given URL and executes javascript to print a message. DevTools is a class that has methods to get a handle on developer options.

DevTools can also be used for performance measurement and to get page load time.

Better Window and Tab Management

Selenium 4 now has given the capability to work on two different windows at the same time. This is particularly useful when we want to navigate to a new window(or tab) and open a different URL there and perform some action.
Tab Management Script

newWindow() method opens a new window or tab based on the WindowType given in its parameter.

Relative Locators

In Selenium 4, there are “relative locators“. that can allow users to specify where on-page elements are found near a specified element with a more human-friendly language.
As an example, “above that element” can be used for specifying an element that is placed on top of the specified element.

  • toLeftOf-toLeftOf() : Element located to the left of specified element.
  • toRightOf-toRightOf() : Element located to the right of the specified element.
  • above-above() : Element located above the specified element.
  • below-below() : Element located below the specified element.
  • near-near() : Element is at most 50 pixels far away from the specified element. The pixel value can be modified.

Full-Screen Snapshot

Now we can take full page screenshots with getFullPageScreenshotAs() method in Firefox. But instead of typecasting it to the ‘TakesScreenshot’ interface, we need to typecast it to the FirefoxDriver instance.

File src = ((FirefoxDriver) driver).getFullPageScreenshotAs(OutputType.FILE);

Firefox and Chromium Users

For people using Firefox or a browser that is derived from Chromium, A good deal of new capabilities have been added. These include ways of handling “basic” and “digest” authentication, Network Interception (Are you an HTTP 418?), and also performing commonly requested tasks, like waiting for a change in the DOM or providing a way to look at Javascript errors.

There might be some more interesting features and improvements, so go ahead and explore!

Speed Up Your Automation By 10X

Faster Test Automation with Codeless Selenium

RECENT POSTS

Guides

Price-Performance-Leader-Automated-Testing

Switching from Manual to Automated QA Testing

Do you or your team currently test manually and trying to break into test automation? In this article, we outline how can small QA teams make transition from manual to codeless testing to full fledged automated testing.

Agile Project Planing

Why you can’t ignore test planning in agile?

An agile development process seems too dynamic to have a test plan. Most organisations with agile, specially startups, don’t take the documented approach for testing. So, are they losing on something?

Testing SPA

Challenges of testing Single Page Applications with Selenium

Single-page web applications are popular for their ability to improve the user experience. Except, test automation for Single-page apps can be difficult and time-consuming. We’ll discuss how you can have a steady quality control without burning time and effort.

Like this post share it with your friends

See how you can create your 1st automated test in less than 5 minutes

Receive the latest news

Subscribe To Our Newsletter

Get notified about new articles