Introduction to Selenium WebDriver



This article gives the details about the WebDriver. 
WebDriver is a Web Automation tool which is used to run the Tests across different browsers[Ex: IE, Firefox,Chrome, Opera etc.]. WebDriver is the new feature in Selenium 2.0.WebDriver also allows/enables us to user different programming languages like Java, .Net, Ruby,PHP, Python and Perl in creating our test scripts.
It’s not mandatory to work all the above mentioned programming languages to work on WebDriver. We just need to be knowledgeable on anyone of the programming language.

WebDriver’s Architecuture:
WebDriver has a very very simple architecture. The following picture depicts the WebDriver’s architecture.


WebDriver controls the Browsers from OS level. The main required thing is that the programming language’s IDE should contain the Selenium commands and a browser.

WebDriver Features:
  • WebDriver is faster as it directly speaks to the browser as well as the uses the browser’s engine to control the same.
  • WebDriver interacts with the application’s elements in a realistic way. WebDriver can’t really enter a value in a Textbox/ Text area if it’s disabled on the web page that we’re testing.
  • WebDriver’s API is very simple as well as easy for understanding. Because, it doesn’t contain redundant and confusing commands.
  • WebDriver can drive an invisible browser called HtmlUnit.
HtmlUnit: HtmlUnit browser is called as “Headless” / Invisible browser as it doesn’t have the GUI. Generally it’s very fast as it doesn’t waste the time in loading page elements. It’ll be helpful in executing the Test for n-number of cycles in a quick period of time. HtmlUnit can be controlled via Automation only as it’s invisible.

Limitations:
WebDriver has certain limitations.
  • WebDriver has no built-in command that automatically generates the Test Result Report/File. We need to rely on the IDE’s output window or write our own code to generate the report as per our requirement. For example, we can customize our output in the form of HTML, Excel or Notepad etc.
  • WebDriver can’t readily support the new browsers. As we know that the WebDriver operates on the OS level. We know that the each browser communicate with the OS in different ways.  The new browser may communicate with the OS in a different process than the old process followed by the older version of the same browser. So, the WebDriver team need take a decision and work towards it to support the new version.

Difference between Selenium IDE, Selenium RC, Selenium Webdriver

This articles explains the basic differences between the Selenium IDE,Selenium Remote Control Server and Selenium WebDriver.

S.No Selenium IDE Selenium RC Selenium WebDriver
  1 Only works on Firefox. Works almost on all browsers.(IE,Opera,Firefox,Chrome).But doesn't work on the latest version of IE and Firefox. Works on all versions of IE,Firefox,Chrome,Opera.
  2 Supports Record and Playback. Doesn't support Record and Playback. Doesn't support Record and Playback.
  3 No Server is required to start. RC Server is required to start. No Server is required to start.
  4 JavaScript based Core Engine. JavaScript based Core Engine. Interacts natively with all browsers.
  5 Simple to use. It requires knowledge on JavaScript if User extensions are used,which makes the work little bit tougher. Simple and small API. Complex and a little bit large API when comparing with RC.
  6 Not at all Object Oriented. Less Object Oriented API. Purely Object Oriented API.
 7 Can't move mouse cursor with this. Can't move mouse cursor with this. Can move mouse cursor with this.
 8 No listeners. No listeners. Implementation of listeners are provided.
 9 Full XPath of the elements need to be appended with 'XPath =\\' syntax. Full XPath of the elements need to be appended with 'XPath =\\' syntax. No need to append the full Xpath of the elements.
 10 iPhone Applications can't be tested. iPhone Applications can't be tested. iPhone Applications can be tested.
 11 Android Applications can't be tested. Android Applications can't be tested. Android Applications can be tested.

Please feel free to write your comments as well as please let me know if I missed/misinterpreted on anything :).