What is WebDriver?
Selenium WebDriver is a web framework that permits you to execute cross-browser tests. It is an interface to write instruction sets that can be run interchangeably in many browsers.
WebDriver is made up of following components:
– Language Bindings: Selenium provides support to multiple libraries such as Ruby, Python, Java, etc as language bindings.
– Browser Drivers: Selenium provides drivers specific to each browser and without revealing the internal logic of browser functionality, the browser driver interacts with the respective browser by establishing a secure connection. These browser drivers are also specific to the language which is used for test case automation like C#, Python, Java, etc.
– Real Browsers: Selenium provides support for multiple browsers like Chrome, Firefox, Safari, Internet Explorer etc.
When a test script is executed with the help of WebDriver, the following tasks are performed in the background:
- An HTTP request is generated and it is delivered to the browser driver for every Selenium Command.
- The HTTP request is received by the driver through an HTTP server.
- All the steps/instructions to be executed on the browser is decided by an HTTP server.
- The HTTP server then receives the execution status and in turn sends it back to the automation scripts.
Scenario – Navigate to https://qascript.com
WebDriver driver = new ChromeDriver(); driver.get("https://qascript.com");
When you execute this script, every statement is converted as a URL, with the help of JSON Wire Protocol over HTTP. The URL’s is passed to the Browser Drivers (Chrome Driver in the above example). Once the URL reaches the Browser Driver, then it will pass that request to the real browser over HTTP. Once done, the commands in the script will be executed on the browser.
If the request is POST request, then there will be an action on the browser. If the request is a GET request then the corresponding response will be generated at the browser end. It will be then sent over HTTP to the browser driver and the Browser Driver over JSON Wire Protocol and sends it to the UI (IDE).