Selenium WebDriver
The primary new feature in Selenium 2.0 is the integration of the WebDriver API. Selenium WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API. It was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
How Does WebDriver ‘Drive’
It makes direct calls to the browser using each browser’s native support for automation. How these direct calls are made, and the features they support depends on the browser you are using. Information on each ‘browser driver’ is provided later in this chapter.
For those familiar with Selenium-RC, this is quite different from what you are used to. Selenium-RC worked the same way for each supported browser. It ‘injected’ javascript functions into the browser when the browser was loaded and then used its javascript to drive the AUT within the browser. WebDriver does not use this technique. Again, it drives the browser directly using the browser’s built-in support for automation
WebDriver and the Selenium-Server
You may, or may not, need the Selenium Server, depending on how you intend to use it. If you will be only using the WebDriver API you do not need the Selenium-Server. If browser and tests will all run on the same machine, and tests only use the WebDriver API, then you do not need to run the Selenium-Server; WebDriver will run the browser directly.
There are some reasons though to use the Selenium-Server as
- You are using Selenium-Grid to distribute tests over multiple machines or virtual machines (VMs).
- You want to connect to a remote machine that has a particular browser version that is not on current machine.
- You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver
This module covers the following topics: