SDET Unicorns

Selenium 4.0 — Major Changes

Table of Content

Hey guys, in this article, I will be going over some of the major changes that happened with Selenium 4.0. Let’s get started!

Switch to W3C Protocol

0*TRoWbegdSpBiIU9T
W3C protocol

The Selenium project migrated to an entirely new protocol — W3C protocol and they no longer will be using the JSON wire protocol. 

Why did this happen?

Because all the recent browsers (e.g., Chrome, Firefox, Safari, etc.), including Internet Explorer, are considered W3C compliant. The reason it’s done that way is so that all browsers are developed similar way and theres no compatibility issues. Now this migration will ensure that tests runs consistently across all these browsers.

Stability

As Selenium WebDriver and browsers use the same protocol, flakiness in web automation can be considerably reduced and hence improving stability of the tests.

Actions API support

W3C protocol also has richer Actions API support in comparison to the one in JSON Wire Protocol. It lets you perform — 

  • multi-touch actions
  • zoom-in, zoom-out
  • pressing two keys simultaneously
  • and more…

Selenium Grid 4.0

0*CF8yEE0g6irpcz7u
Selenium Grid 4.0 Architecture

There were also bunch of changes that happened with Selenium Grid 4.0 as well. 

Docker Support 

With Grid 4.0, you now can easily spin up docker containers quickly to run tests in different browsers instead of setting up virtual machines. All steps are well documented in the GitHub repository.

Kubernetes Support

Grid 4.0 has also been redesigned to deploy the grid on Kubernetes for better scaling capabilities. You can take a look at an example here to get Grid 4.0 setup with Kubernetes.

Improved UI

Grid 4.0 Improved UI

Selenium Grid 4.0 also has a fancy UI now which easily lets you see all the running containers, number of sessions and max concurrency. It also has a VNC player plugged in to watch videos of the tests running within the container! ?

IPV6 and HTTPS protocol

Selenium grid also supports IPv6 addresses now along with IPv4 and you can now communicate to HTTPS protocol using Grid 4 as well.


New Locator Strategy

Selenium 4.0 came out with a new Relative locator strategy that’s a bit more friendly as its based on visual representation of the DOM. The available locators are — 

  • below — web element located below the specified element
  • toLeftOf — web element located to the left of the specified element
  • toRightOf — web element located to the right of the specified element
  • above — web element located above the specified element
  • near — web element located near (approx. 50 pixels) the specified element

Here’s an example — 

1*KWAFofQGJizKKTAnVOpdVw
Relative ‘above’ locator strategy

CDP Integration & BiDi APIs

With Selenium 4, you also get access to the Chrome Debugging protocol which has a set of APIs that lets you do things like –

  • viewing console logs
  • intercept network requests
  • perform basic auth
  • throttle network performance 

But since this is with CDP it will only work with Chromium based browsers.

However, Selenium team is working on getting Webdriver BiDirectional Protocol implemented for all the browsers so that you are not limited with a particular browser or a version.


Selenium IDE

0*uMMZmb9lH7LJURGK
Selenium IDE
  • Aside from Selenium 4 changes, we also have a brand new Selenium IDE with improved UI and better user experience.
  • It also comes with its own command line runner to run tests in any browser, parallel or on a grid.
  • IDE also has control flow structure, with available commands like if, while and times in the IDE itself
  • Selenium IDE also records multiple locators for each element it interacts with. If one locator fails during playback, the others will be tried until one is successful.
  • You can also do code export for all the official language bindings such as Java, .Net, Python, Ruby & JavaScript.
  • IDE can be extended through the use of plugins as well

If you would like to see a demo of some of the features listed above, you can checkout the video below — 

With that it’s a wrap of all the major new features of Selenium 4. Hope you enjoyed this article!

My Resources

Thrive Suite: The all-in-one WordPress theme I used to create my blog.
Jasper AI: My favorite AI writing tool.
Surfer SEO:  A tool to help you rank your content on the first page of Google.

Write Content Faster

5/5

Write blog posts that rank for affiliate terms!

Join our mailing list

Unlock the Secrets to Becoming a SDET Pro in the Industry!

Stay ahead of the curve! Join our mailing list for exclusive insights, tips, and the latest industry updates delivered straight to your inbox

Table of Content

Related Post

7 Principles of Software Testing

7 Principles of Software Testing with Examples

Software testing plays a crucial role in the software development life cycle as it helps ensure the quality, reliability, and performance of the final product. Software testing is not just about finding defects; it also provides valuable insights into the overall quality of the software. By conducting effective software testing, it shows how well the application behaves in different scenarios and whether it meets user expectations.

Read More »
Differences Between CI/CD and DevOps

Key Differences Between CI/CD and DevOps

Software development is far from a simple journey that involves merely executing code and launching applications. It often presents challenges, as it’s rare to get everything right from the start. Each time you implement new or frequent code changes, you inadvertently introduce potential issues that can be time-consuming to resolve. This complexity necessitates a structured approach to ensure smooth production.

Read More »