Selenium WebDriver alias Selenium 2 is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website.
Selenium WebDriver is the latest and most popular flavor of Selenium which allows the test developers to write tests using their favorite language to test on different browsers.
Pre-requisites for Selenium WebDriver:
What is Selenium WebDriver ?
How Selenium WebDriver works ?
In order to know how Selenium Web Driver works:
- First you have to understand how the Selenium RC works by going through the Selenium RC Post # 1
- Next find out what is the difference between Selenium RC and Selenium WebDriver by going through the below content.
Difference between Selenium WebDriver and Selenium RC:
In Selenium RC we have to use Selenium RC Server as mediator between the Automation Code and the Browser. Generally Browsers wont allow any external code to get executed on any Website they are holding. Since our Selenium Automation code is treated as external code by the Browsers, we required a kind of mediator who can communicate with the browsers, so that the browser can allow the execution of Selenium Automation code on the website they are holding. Hence Selenium RC Server acts as a proxy to allow the Selenium Automation Code to get executed on the Application Under Test in Browsers. So in Selenium RC we have to make Selenium command calls to the browsers via Selenium RC Server.
But in Selenium WebDriver, we don't require any Server which acts as a mediator. We can make direct Selenium command calls to the browsers.This is possible because of the Browser drivers used in the Selenium Automation code. There is a separate driver for each browser. Suppose if we want to run our Selenium Automation code on Internet Explorer browser, we have to the use the Internet Explorer
WebDriver. Here WebDriver of browser will communicate with the browser. We use WebDriver API (Application Programming Interface) code in the our Selenium Automation Code and hence our Final Automation Tests containing the WebDriver API code can directly communicate with the browsers.
If your browser and automation tests will all run on the same machine, then your tests only use the WebDriver API, you do not need to run the Selenium-Server ( i.e. WebDriver will run the browser directly).
Are there any cases where you have to use Selenium-Server with Selenium-WebDriver ?
Yes. As we have to use Selenium-Grid concept for distributing our tests over multiple machines and run. In order to run the browser on a remote machine, we have to use Selenium-Server for communicating with the browsers on remote machines and running the tests on remote machines.