Selenium WebDriver API enables interaction between browsers and browser drivers.
This architecture consists of four layers namely:
a. Selenium Client Library,
b. JSON Wire Protocol,
c. Browser Drivers
The below figure explains the interaction between:
Selenium Client & WebDriver language bindings:
So when you type
WebDriver driver = new ChromeDriver();
Each browser has a specific browser driver. Browser drivers interact with its respective browsers and execute the commands by interpreting Json which they received. As the browser driver gets the URL, it passes the request to its browser via HTTP. It will trigger the event of executing the Selenium instructions on the browser. Then the response is given back in the form of HTTP response.
Now if the request is that of POST, it will trigger an action on the browser. If it’s a GET request, then the response will be produced at the browser end. Finally it will be passed over HTTP to the browser driver. The browser driver will in turn send it to the UI via JSON Wire Protocol.
For successful request it will return 200, In case of failure it will return 500, different response codes will be returned. On the editor response will be interpreted accordingly, say 500 — Element not found exception.