Selenium WebDriver Communication
Let’s understand the communication flow of Selenium WebDriver and how it interacts with the browser using the JSON Wire Protocol.
The main component of Selenium, which is used in automation, is the Selenium WebDriver.
- The Client bindings/libraries are available in different programming languages.
- JSON Wire Protocol over HTTP for communication to send commands from the client to the server
- Driver for every browser
- Browsers: Chrome, Firefox, Edge, Opera, IE, etc.
Test Script
The automation tester writes an automation test script using the Selenium client library in their preferred programming language.[ Python, Java, Ruby, etc.]
The test script sends commands through the client library to interact with the browser (e.g., clicking a button, filling out a form, etc.)
JSON Wire Protocol
- The client library converts these commands into JSON format.
- HTTP Request: The converted JSON commands are sent over an HTTP request to the browser driver.
- Driver—Browser Interaction: The browser driver decodes the JSON commands. It interacts with the web browser, executing the necessary steps (e.g., simulating a click, navigating to a URL, etc.).
Automation Script Feedback
The execution status (success or failure) is returned to the HTTP server. Finally, the HTTP server relays the status back to the automation script.
Selenium WebDriver communicates with the browser by creating HTTP requests, converting commands to JSON, and using the JSON Wire Protocol.