BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Selenium 2 (a.k.a Selenium WebDriver) Is Released

Selenium 2 (a.k.a Selenium WebDriver) Is Released

Leia em Português

This item in japanese

Bookmarks

The Selenium team has recently released Selenium 2 (a.k.a. Selenium WebDriver). Selenium is a popular test framework for web applications, which runs on multiple browsers and can be developed using multiple programming languages. The primary new feature of Selenium 2 is the integration of WebDriver, a rival web application testing framework to Selenium 1 (a.k.a. Selenium RC). While Selenium RC runs a JavaScript application within the browser, WebDriver controls the browser directly using native browser support or browser extensions.

As can be read from the Brief History of The Selenium Project, both the Selenium and WebDriver developers agreed that both tools have advantages, and that merging the two would create a more powerful web testing framework. Selenium 1 is a popular and well established testing framework that provides an interface that works with a large number of browsers because of its JavaScript implementation, and allows users to write tests in many programming languages (from Java or C# to PHP to Erlang). WebDriver addresses the shortcomings of Selenium 1, mainly the ability to step outside the JavaScript sandbox and the ability to provide a fast, lightweight, headless browser emulator. Simon Stewart, the creator of WebDriver, explained why the projects were merging in a joint email to the WebDriver and Selenium community back in August 2009.

Why are the projects merging? Partly because WebDriver addresses some shortcomings in Selenium (by being able to bypass the JS sandbox, for example. And we've got a gorgeous API), partly because Selenium addresses some shortcomings in WebDriver (such as supporting a broader range of browsers) and partly because the main Selenium contributors and I felt that it was the best way to offer users the best possible framework.

Selenium 2 also includes Selenium Server, which supports distributed testing via Selenium Grid. The new Selenium Grid supports testing using both the original Selenium RC API and the new WebDriver API. Selenium IDE 1.1.0 will also support the new WebDriver API, including the ability to export to all the programming languages (Ruby, Python, C# and Java) supported by WebDriver. Unfortunately, this also means that Selenium IDE is officially deprecating inclusion of the Groovy, Perl and PHP plugins in the main release branch.

WebDriver is developed for each browser and replaces the JavaScript that was embedded on web applications being tested. This tighter integration with the browser allows for the creation of more advanced tests, and removes the restrictions placed by the JavaScript security model. Besides support from browser vendors, WebDriver also provides emulation of user inputs using OS level calls. WebDriver is supported on Firefox (FirefoxDriver), IE (InternetExplorerDriver), Opera (OperaDriver) and Chrome (ChromeDriver). Support for Safari is not included in this release due to technical constraints, but can be emulated using the SeleneseCommandExecutor. It also works on Android (AndroidDriver) and iPhone (IPhoneDriver) for mobile web application testing. It also has a headless implementation based on HtmlUnit called HtmlUnitDriver. The WebDriver APIs can be accessed from Python, Ruby, Java and C#, allowing developers to create tests using their preferred programming language.

The previous stable release of Selenium was Selenium 1.0.3, released in February 2010. Selenium 2 is backwards compatible with Selenium 1, although new Selenium users should use the new WebDriver API. Selenium 2 supports both the Selenium RC API, and the Selenium RC technology underneath the WebDriver API. Selenium 1 is still actively supported and provides some features that are not currently available in Selenium 2. This includes support for other languages like JavaScript, PHP, and Perl, and support for every other browser with JavaScript support. For help in upgrading your current Selenium tests, please read Migrating from Selenium RC to Selenium WebDriver.

When InfoQ asked Simon Stewart why it took almost two years to release Selenium 2 after the decision was taken to combine Selenium 1 and WebDriver, he said:

It's a good question. There's lots of possible different reasons, but I think that the key one is that we released 2.0 when we thought it was ready. Until recently the WebDriver API was still not quite fully baked: you'll have seen in the RCs that certain methods were deprecated and then deleted. There were also a pile of open issues to sort through and validate. A large part of my work for the past months has been stabilizing WebDriver and fixing issues rather than working on new issues. Although we knew that 2.0 wouldn't be bug free, we did want it to be as stable, efficient and pleasant as possible.

For more information on Selenium 2 and WebDriver, please read the Selenium documentation on Selenium 2.0 and WebDriver and the WebDriver FAQ.

Rate this Article

Adoption
Style

BT