Selenium 4.0: Gotta Catch ‘Em All

Selenium 4.0: Gotta Catch ‘Em All

Share this
Selenium, Automation, Selenium 4
Nov 17,2021

All code is guilty until proven innocent. Or at least, that’s what the Quality Assurance department (QA) at your company has told you (They’re right you know). Be it a new feature that was introduced to your system or an unintentional human error, bugs are meant to occur. And it falls down to the QA Engineer to find them.

If you have watched the Matrix trilogy, then you do remember the war between humans and machines, but that’s in the Matrix. In the QA department, we raise a health to our partnership through the automation tools, especially Selenium. And with the release of Selenium 4.0, things are looking more interesting.

United under the slogan “Gotta Catch ’Em All” (Pokémons and Bugs alike), let’s start our trip and see what’s new in Selenium’s latest version.

 

What is Selenium?
Selenium is an open-source tool that automates web browsers. It provides a single interface that lets you write test scripts in programming languages like Ruby, Java, NodeJS, PHP, Perl, Python, and C#, among others.
 

Why Selenium?
Selenium is one of the most used tools in automating the testing process. It’s open-sourced, supports many programming languages, supports multiple operating systems, and works across multiple browsers. Add to that the support of multiple frameworks, the constant updates, reusability, and ease of implementation.

Selenium has also a wide community on the internet making it easier to find a solution for any problem that you might face.

 

Selenium 4.0 Features

Selenium has introduced many new features and enhancements in its latest release. These features are:

  1. Selenium WebDriver W3C Standardization: In Selenium’s earlier versions, The JSON Wire Protocol was responsible for communicating between the web browser and the test code. This caused an additional overhead of encoding and decoding the API requests using the W3C Protocol. Starting from Selenium 4, the web driver will directly communicate with the web browser since major web browsers already follow the W3C standard and this will result in a more stable cross-browser testing. Noting that this will deprecate the JSON Wire Protocol.
     
  2. Improved and Optimized Selenium Grid: The selenium grid which distributes the test execution is a Hub-Node-based architecture. And since the Hubs & the Nodes need to be separately started when performing the automation testing, this will be a hard pass as they are packed in the same JAR file. The Grid in Selenium 4 will be a more scalable and traceable infrastructure, supports four processes; Router, Session Map, Distributor, and Node. In Selenium 4, the Grid will support IPv6 addresses, and the user will be able to communicate with the Grid using the HTTPS protocol. It will also have a user-friendly UI, the support of Docker which makes it easier to use on Virtual Machines, and easy deploying on Kubernetes which makes it extremely useful in DevOps processes. 
     
  3. Enhanced Selenium 4 IDE: Selenium 4 has introduced a more enhanced IDE experience. With a new and shiny interface, plugins to support both Chrome and Fire Fox, Code Export feature supporting multiple languages, control flow mechanism, and the ability to run multiple test recorders using the CLI side-runner feature, you will be taken above and beyond.
     
  4. Relative Locators: It’s not only about finding the elements. Now you can find the elements by specifying their locations using “near”, “left of”, “right of”, “above” and “below” locators.
     

RELATIVE LOCATOR

DESCRIPTION

Above

The Web Element is ‘above’ a specified (or particular) element.

Below

The Web Element is ‘below’ a specified (or particular) element.

to_left_of

The Web Element is ‘to the left of’ a specified (or particular) element.

to_right_of

The Web Element is ‘to the right of’ a specified (or particular) element.

Near

The Web Element is ‘at most 50 pixels’ away from the specified (or particular) element.

 

  1. Window Handling: Not only you can now specify whether to open the window in a tab or as a new window (using a single web driver instance). But also, you can do that within the same session. Using the WindowHandle, you can create a new window or tab and automatically switch to it. Add to that, you can go in full-screen mode during the script execution.

     

  2. Code Deprecation: The code has been cleaned and deprecated to enhance the experience. For example, the FindBy* (ID, CSS...etc) has been deleted. The recommended alternative is to use the ‘By’ instance. You can find all the deprecated APIs here.

     

  3. Enhanced Documentation: The official documentation of Selenium 4 is exhaustive and the content layout makes it easy to find the desired information. The documentation covers all aspects of Selenium 4 (Grid, IDE, and W3C protocol). This allows the automation testers to get acquainted with the new APIs offered by Selenium 4.
     

Conclusion
As Fyodor Dostoevsky said “Right or wrong, it’s very pleasant to break something from time to time” and Selenium has broken all the rules with its latest version. The experience has gotten smoother, the code more structured and cleaner. You can update your Selenium version as explained here and enjoy the experience.

Drupal Company in Jordan
Quality Assurance Engineer

A full-time nerd, a bookworm, an adventurer, a harmonica player, a dancer, and a traveler who seeks what’s ahead.

Tags