Selenium WebDriver Architecture (Selenium 4)
1. Components of Selenium WebDriver Architecture
1.1 Selenium Client Libraries:
- Supports multiple languages: Java, Python, C#, Ruby, JavaScript.
- Used to write automation test scripts.
1.2 JSON Wire Protocol / W3C WebDriver Protocol:
- Selenium 4 uses W3C WebDriver Protocol (replacing JSON Wire Protocol).
- Enables communication between client libraries and browser drivers.
1.3 Browser Drivers:
- Acts as a bridge between Selenium scripts and browsers.
- Examples: chromedriver, geckodriver, msedgedriver, safaridriver.
1.4 Real Browsers:
- The actual browser (e.g., Chrome, Firefox) where tests are executed.
- Controlled by WebDriver to simulate real user actions.
2. Selenium WebDriver Architecture Flow
1. Tester writes test script using Selenium client libraries.
2. Selenium sends commands via W3C protocol as HTTP requests.
3. Browser driver receives these and controls the real browser.
4. Browser executes the action (e.g., open URL, click).
5. Browser sends response to the driver.
6. Driver returns the response to Selenium client.
3. Selenium 3 vs Selenium 4 (Key Architecture Differences)
Selenium WebDriver Architecture (Selenium 4)
Feature | Selenium 3 | Selenium 4
---------------------|-----------------------------------|-----------------------------------
Protocol | JSON Wire Protocol | W3C WebDriver Protocol (native)
Browser Compatibility| Minor issues due to translation | Improved compatibility
Performance | Slightly slower | More stable and faster
4. Text Diagram of Architecture
Test Script (Java/Python/etc)
->
Selenium Client Library
->
W3C Protocol (HTTP Requests)
->
Browser Driver (e.g., ChromeDriver)
->
Real Browser (e.g., Chrome)