Selenium Webdriver is a framework that allows automation testing. It allows testing across various browsers. It can execute multiple tests over multiple browsers on multiple OS. Web Driver makes it possible to write a test script in Linux and run it in Windows. There are multiple programming languages that are supported by Web Driver such as Java, Python, Ruby, .Net, PHP to create test scripts.
Selenium Web driver is derived from −
In Selenium2, integration of Web Driver was considered which was designed to address a few limitations of Selenium RC.
Selenium was introduced with the following new features −
It can test dynamic websites where the content of pages changes by a mouse click.
By Web Driver, mobile automation is also feasible.
Web driver comes with another advantage which is its use on HTMLUnit browsers(HTMLUnit browser are headless browsers which means these are invisible to the user, in simple words they have no GUI), due to these testing on HTMLUnit browser is faster as these browsers save the time needed to load the page elements. This results in less execution time for test cases.
Browser vendors will ship their own WebDriver implementation, hence are tightly coupled to the browser giving a better testing experience. Modern Browsers such as Edge, Safari are introduced with the WebDrivers shipped by their vendors
Let's have a look at how Selenium WebDriver work −
WebDriver makes direct calls to the browser using each browser’s native support for automation. It uses browser driver for this communication
WebDriver contributes its object-oriented API for Document Object Model (DOM) interaction and browser control.
When any Automated Script is executed, for every Selenium command, HTTP Request is created and sent to the browser to the driver. The browser driver uses an HTTP Server for getting HTTP Requests. This HTTP Server determines the steps needed for the implementation of the Selenium command. The execution status which is run on the browser is sent back to HTTP Server, which sends the status back to the automation script.