What is WebDriver?
WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox, Chrome (unlike Selenium IDE).
WebDriver also enables you to use a programming language in creating your test scripts (not possible in Selenium IDE).
You can now use conditional operations like if-then-else or switch-case. You can also perform looping like do-while.
Introduction to WebDriver & Comparison with Selenium RC
Following programming languages are supported by WebDriver
Java
.Net
PHP
Python
Perl
Ruby
You do not have to know all of them. You just need to be knowledgeable in one. However, in this tutorial, we will be using Java with Eclipse as our IDE.
Difference between Selenium RC and Webdriver
Before the advent of WebDriver in 2006, there was another, automation tool called Selenium Remote Control. Both WebDriver and Selenium RC have following features:
They both allow you to use a programming language in designing your test scripts.
They both allow you to run your tests against different browsers.
So how do they differ? Let us discuss the answers.
1. Architecture
WebDriver's architecture is simpler than Selenium RC's.
It controls the browser from the OS level
All you need are your programming language's IDE (which contains your Selenium commands) and a browser.
Introduction to WebDriver & Comparison with Selenium RC
Selenium RC's architecture is way more complicated.
You first need to launch a separate application called Selenium Remote Control (RC) Server before you can start testing
The Selenium RC Server acts as a "middleman" between your Selenium commands and your browser
When you begin testing, Selenium RC Server "injects" a Javascript program called Selenium Core into the browser.
Once injected, Selenium Core will start receiving instructions relayed by the RC Server from your test program.
When the instructions are received, Selenium Core will execute them as Javascript commands.
The browser will obey the instructions of Selenium Core and will relay its response to the RC Server.
The RC Server will receive the response of the browser and then display the results to you.
RC Server will fetch the next instruction from your test script to repeat the whole cycle.