What is Selenium Webdriver?

Webdriver is known to be the latest version of Selenium i.e. Selenium 2.x. More powerful than the primitive Selenium rc 1.x and comes with lots and lots of libraries and new features to work with. It's not mandatory to know Selenium RC to work with Webdriver. You can directly learn webdriver and start working on it. There is no need of selenium server if you are working with Webdriver API

What makes it different from Selenium RC?

  • More object oriented as compare to Selenium RC.
  • Has wider range of APIs
  • Interacts natively with browser where as Selenium RC is Javascript based.
  • Can test Iphone and Andriod based application which is not supported by Selenium RC.
  • Implements HTMLUnit driver which makes test execution really fast.
  • Unlike Selenium RC there is no server in Webdriver.
  • Supports almost all lastest web browsers where as Selenium RC does not works on latest versions on Firefox and IE.

WebDriver Architecture

Selenium WebDriver architecture

How to configure Selenium Webdriver?

Pre Requisite:

Getting Started:
Open Elipse and create a new Java project. Create a new class and import the downloaded Selenium Webdriver libraries

Writing the first Selenium Webdriver code:
Create a new class file and copy paste the above code. Now run it as a Java application.

Basic Webdriver methods:

  • driver.get() - Takes you to the provied URL/Website address.
  • driver.getTitle() - Get the title of the current browser window.
  • driver.getPageSource() - Get the page source code of the current window.
  • driver.close() - Closes the current window.
  • driver.quit() - Close all associated windows.
  • driver.getCurrentUrl() - Get the URL of the current webpage.
More webdriver methods