Facebook

Selenium 4.0 & Beyond: Key Features You Missed

Last Updated: January 27th 2026

Still writing Selenium 3 style code in a Selenium 4 world? Upgrade your skills and your stack. See how CloudQA leverages Selenium 4’s advanced protocols or talk to our architects about modernizing your pipeline.

It has been some time since the release of Selenium 4.0, yet a surprising number of QA teams are still using it exactly like they used Selenium 3. They updated the JAR file dependency in their pom.xml, patted themselves on the back, and went back to writing the same old brittle XPaths.

If this sounds like your team, you are driving a Ferrari like it is a Corolla.

Selenium 4 wasn’t just a version bump; it was a complete architectural rewrite. It standardized the protocol, opened the door to the browser’s internal tools (DevTools), and laid the foundation for the AI-driven future we are seeing today with tools like Vibium AI.

This article goes beyond the changelog. We explore the powerful features of Selenium 4 that you are probably not using but should be.

Table of Contents

W3C Standardization: The Stability Upgrade

The most significant change in Selenium 4 is invisible to the coder but critical for the execution.

The Old Way (Selenium 3):

It relied on the JSON Wire Protocol. When you sent a command (e.g., click()), the client libraries (Java/Python) had to encode it into JSON and send it to the Browser Driver, which then decoded it. This “game of telephone” was a frequent source of flakiness.  

The New Way (Selenium 4):

Selenium 4 is fully W3C Compliant. The WebDriver interacts directly with the browser using the standard W3C protocol. There is no encoding/decoding middleman.  

  • The Benefit: Your tests are inherently more stable and slightly faster.  
  • The Action: You don’t need to change your code, but you do need to ensure your Browser Drivers (ChromeDriver, GeckoDriver) are strictly version-matched to your browsers.

Relative Locators: Finding Elements Human-Style

Finding elements has always been the hardest part of starting with Selenium. Writing complex XPaths like //div[@id=’user-table’]//tr[3]//td[2] is painful and brittle.

Selenium 4 introduced Relative Locators (originally called “Friendly Locators”). They allow you to locate elements based on their visual position relative to others.  

The Code:

import static org.openqa.selenium.support.locators.RelativeLocator.with;

WebElement passwordField = driver.findElement(By.id(“password”));

// Find the “Submit” button that is BELOW the password field

driver.findElement(with(By.tagName(“button”)).below(passwordField)).click();

The Benefit: This makes scripts much more readable. Instead of decoding a complex CSS selector, anyone reading the code understands “Click the button below the password field.”

Chrome DevTools Protocol (CDP): The Superpower

This is the feature that allows Selenium to compete with newer tools mentioned in Selenium alternatives discussions (like Cypress or Playwright).

Selenium 4 allows you to tap directly into the Chrome DevTools Protocol. This gives you control over the browser’s network and performance layers, not just the UI.  

Use Case A: Simulating Network Conditions

You can now test how your app behaves on 3G or offline without external proxies.

DevTools devTools = ((ChromeDriver) driver).getDevTools();

devTools.createSession();

devTools.send(Network.emulateNetworkConditions(

    false, 100, 20000, 10000, Optional.of(ConnectionType.CELLULAR3G)

));

Use Case B: Mocking Geo-Location

Test your “Store Finder” feature by telling the browser it is in Tokyo, even if your server is in Texas.

devTools.send(Emulation.setGeolocationOverride(

    Optional.of(35.6895), Optional.of(139.6917), Optional.of(100)

));

Use Case C: Intercepting Network Requests

You can spy on API calls or mock responses to test edge cases (like a 500 Server Error) without actually crashing your backend.  

The Self-Healing Foundation (BiDi API)

While Selenium 4 itself doesn’t offer “Magic AI Self-Healing,” it introduced the Bi-Directional (BiDi) API.  

In the past, Selenium was uni-directional. It sent a command and waited. With BiDi, the browser can send events back to the script in real-time (e.g., “A console error just happened” or “The DOM just mutated”).  

This architectural shift is what enables modern AI tools like Vibium AI and CloudQA to exist. These tools listen to these real-time events to detect when a selector fails and “heal” it on the fly.

Better Window and Tab Management

In Selenium 3, opening a new tab and switching to it was a clumsy multi-step process involving Window Handles. Selenium 4 simplifies this with a dedicated API.

The Code:

// Opens a new tab and switches focus automatically

driver.switchTo().newWindow(WindowType.TAB);

// Opens a new window

driver.switchTo().newWindow(WindowType.WINDOW);

This is a small quality-of-life improvement that makes working with multi-tab applications significantly cleaner.

Why This Matters for Engineering Leaders

For Software Engineering Leaders, upgrading to Selenium 4 is not just a technical task; it is a strategic one.

  1. Observability: The new Selenium Grid 4 comes with built-in observability (OpenTelemetry), allowing you to trace a test request from the client to the node and back. This makes debugging infrastructure issues much easier.  
  2. Future-Proofing: The W3C standard is the future. Browser vendors are optimizing for it. Staying on Selenium 3 is investing in a depreciating asset.

How CloudQA Uses Selenium 4

At CloudQA, we have fully embraced the Selenium 4 architecture.

  • We use CDP to capture deep performance metrics and console logs for every test step, giving you rich debugging data without writing extra code.
  • We use Relative Locators logic in our low-code recorder to suggest better, more human-readable selectors.
  • We use the BiDi protocols to power our self-healing AI, ensuring your tests don’t break when the UI shifts.

Conclusion

Selenium 4 is a powerhouse. It bridges the gap between the “Classic Automation” of the past and the “Modern, Event-Driven Automation” of the future.

If you are not using features like CDP and Relative Locators, you are leaving massive efficiency gains on the table. It is time to look at your framework code and ask: “Am I using Selenium 4, or am I just using Selenium 3 with a new version number?”

Frequently Asked Questions

Q: Is migrating from Selenium 3 to 4 difficult?

A: For most projects, it is seamless. You update the dependency, and it works. However, if you were using the legacy JSON Wire Protocol capabilities or complex DesiredCapabilities objects, you might need some minor refactoring.

Q: Can I use Chrome DevTools features with Firefox?

A: Yes, mostly. While it is called the “Chrome” DevTools Protocol, Firefox has implemented a significant portion of it to ensure compatibility, though Chrome/Edge support remains the most robust.

Q: Do Relative Locators replace XPaths?

A: No. They are a supplement. They are great for forms and grids where visual layout is consistent. For complex, nested dynamic elements, robust CSS selectors or XPaths (or AI-based locators) are still necessary.

Related Articles

Share this post if it helps!

Benefits of Automation Testing with CloudQA
Fast track your testing process
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.