← Back to list

Selenium 4 Architecture and why its superior to Selenium 3.

In Selenium 3, the Architecture was like this.

Sameera De Silva · 2025-04-21 15:55 · 0 claps · 3.2 min read
#selenium-4 #webdriver
Open on Medium ↗
Wiki topics: 🏛️ · Architecture

Selenium 4 Architecture and why its superior to Selenium 3.

In Selenium 3, the Architecture was like this.

❌ Why JSON Wire Protocol Was Slower in Selenium 3:

1. Extra Translation Layer:

  • Selenium WebDriver commands had to be converted into JSON format, sent over HTTP to the browser driver, and then translated again into native browser commands.

The response also same.

the response from the browser driver also had to go through JSON serialization and deserialization:

Browser executes the command, like finding an element or clicking.

Browser driver sends the result back as a JSON response over HTTP.

Selenium client (your test script) parses that JSON and converts it into a native object (e.g., WebElement, String, etc.).

➡️ So the process was bi-directional:

  • Command → JSON → Browser
  • Response ← JSON ← Browser

This added latency both ways, especially when handling large or complex responses (like lists of elements, DOM trees, or error messages).

  • This extra serialization/deserialization added latency.

2. Verbose Communication:

  • Every WebDriver call (like click, findElement, etc.) had to make a separate HTTP request.
  • For complex operations (e.g., clicking a deeply nested element), this created a high number of back-and-forth HTTP calls, slowing down execution.

3. No Native Support for Complex Actions:

  • JSON Wire Protocol had limited support for advanced actions (like multi-key presses or touch gestures). These had to be emulated or implemented in a browser-specific way, causing inconsistencies and delays.

4. Compatibility Issues:

  • Different browsers interpreted the JSON commands differently. So, the same script could behave differently across browsers.
  • This often forced developers to add browser-specific handling, which slowed down development and execution.

5. Error-Prone Communication:

  • Because JSON Wire Protocol wasn’t fully aligned with browser vendors’ native implementations, errors or unexpected behavior were more common — especially when browser updates rolled out.

In Selenium4 its like below this is the latest.

Selenium 4 introduced a W3C WebDriver standard-compliant architecture, which improved reliability, stability, and speed compared to earlier versions.

W3C stands for Wold Wide Web Consortium. W3C is an internal community which develops standards for the web, so that every web developer in the world follows these same standards while developing their applications/software. Consortium means agreement.

✅ Benefits of Selenium W3C Standardization

1. Unified Communication (Standardization): Selenium now uses the same W3C WebDriver protocol as browsers and drivers, making communication smoother and more consistent — like everyone speaking the same language.

2. Cross-Browser Stability: Before, scripts that worked in one browser might fail in another. With W3C compliance, automation scripts are more reliable and consistent across all major browsers.

3. Support for Advanced Actions: Selenium can now handle more complex interactions (e.g., pressing multiple keys at once using the Actions class) thanks to better browser support via the W3C protocol.

4. Reduced Latency (Better Performance): With direct communication and no JSON Wire Protocol translation, command execution is faster and more efficient.

5. Improved Debugging & DevTools Support: Selenium 4 adds Chrome DevTools Protocol (CDP) support, enabling advanced features like network interception, performance monitoring, geolocation, and console logs.

6. Vendor Compatibility & Future Proofing: Since browser vendors (Chrome, Firefox, etc.) now build their drivers based on W3C, future Selenium versions will be more compatible and less likely to break due to updates.

7. Cleaner & More Predictable API Behavior: Commands behave more consistently across different browsers, reducing unexpected behavior in scripts.

🔑 Key Components of Selenium 4 Architecture:

  1. Selenium Client (Test Script):
  • Written in supported languages like Java, Python, C#, etc.
  • Uses WebDriver API to send commands.
  1. WebDriver Protocol (W3C Standard):
  • Selenium 4 communicates directly with browser drivers using the W3C WebDriver Protocol.
  • No more JSON Wire Protocol conversions (used in Selenium 3).
  1. Browser Drivers:
  • Examples: chromedriver, geckodriver, msedgedriver.
  • Drivers act as a bridge between Selenium scripts and actual browsers.
  • Each browser vendor maintains its own driver.
  1. Real Browsers:
  • Actual browsers (Chrome, Firefox, Edge) that execute the commands received from the driver.

🚀 How Selenium 4 Speeds Up Execution:

  • Direct W3C Communication: No need to translate between JSON Wire Protocol and WebDriver API. This reduces the overhead and potential misinterpretation of commands.
  • Optimized Driver Communication: More stable and faster interaction with browser drivers, especially for actions like navigation, clicking, or fetching elements.
  • Better Support for Modern Browsers: Since browsers are aligned with the W3C standard, it results in fewer compatibility issues.
  • Improved Debugging Tools: DevTools Protocol support (e.g., for Chrome) allows for faster debugging, logging, network mocking, and capturing performance metrics.

Image credits and further readings- https://www.qafox.com/selenium-4-w3c-standardization/


메타데이터
post_id
2a82b30db00c
slug
selenium-4-architecture-and-why-its-superior-to-selenium-3-2a82b30db00c
url
https://medium.com/@samedesilva/selenium-4-architecture-and-why-its-superior-to-selenium-3-2a82b30db00c
canonical_url
https://medium.com/@samedesilva/selenium-4-architecture-and-why-its-superior-to-selenium-3-2a82b30db00c
author_url
https://medium.com/@samedesilva
status
ok
fetched_at
2026-07-15 04:21:51