Watir, Selenium & WebDriver

Please also see my new ‘Watir-WebDriver: a detailed introduction‘ post.


Of all the open source automated web testing tools available, Watir and Selenium have been the two most popular ones. Traditionally there has been advantages and disadvantages of each. Selenium’s most useful features have been its support for multiple programming languages, and is support for testing a wide variety of browsers. This is because Selenium uses JavaScript to interact with the browser, and all modern browsers support JavaScript.


Watir was originally designed to support Internet Explorer only, and was originally designed as a ruby library, meaning you had to use ruby. Watir’s most useful feature was, and is, its neat API, most likely that way because it was designed by testers. Also Watir has been traditionally had more functionality than Selenium, because it was designed to interact directly with IE instead of using JavaScript, as there are limits to what you can do with JavaScript, ie. you can’t script uploading a file.

The limitations of Watir have been addressed over time, for example, by creating new versions that support other browsers (FireWatir, SafariWatir and ChromeWatir for example), but the task of porting Watir to a new browser isn’t an easy one, and the task of keeping every port of Watir in sync, with the same API, is difficult. Because of Watir’s power, there has been lots of interest in it as a tool, particularly from developers who use other languages. Understandably, they have wanted to use the language they are accustomed to, and use for production code, and hence numerous language ports of Watir have also been created: Watij and WatiN to name two.

Selenium & WebDriver

Selenium has had its challenges also. Whilst it has traditionally been flexible in language choice, it has technical limitations because of its JavaScript architecture. It also hasn’t offered a way to control a headless browser. Late last year WebDriver was announced. WebDriver is a common browser automation tool that uses what ever is the most appropriate mechanism to control a browser, but with a common API. WebDriver supports not only real browsers (IE, Chrome & Firefox) but also headless ones (using HtmlUnit). Watir uses have had access to a headless browser by using Celerity. WebDriver was quickly merged with Selenium, to become Selenium 2.0.

Watir & WebDriver

So, what does WebDriver mean to Watir? Some people in the Watir project see an opportunity to leverage the effort put into WebDriver, but to continue to offer the clean neat API that Watir does. Jari Bakken has released an early version of Watir-WebDriver, essentially Watir’s ruby API utilising the WebDriver engine. By using WebDriver, Watir can support any browser that WebDriver does, including a headless HtmlUnit browser, without using Celerity.

What does this mean for the future of Watir?

If you’re a Watir user, it doesn’t really make that much difference. If you think of automated web testing as a car, Watir is the steering wheel and dashboard, which interact with the engine. Allowing Watir users to use WebDriver is like providing an additional engine choice, but keeping the steering wheel and dash the same.

Ultimately, I think that Watir will remain a very popular automated web testing tool, one that has been designed by testers for testers. I can see the usage of WatiN and Watij reducing as more developers move to Selenium 2.0/WebDriver which will offer the same functionality as Watir using a different API and multiple programming languages. If WebDriver can focus on the detail of controlling browsers, ultimately Watir will be a better tool as more effort can be spent on improving the Watir API, upgrading the steering wheel and dash, so to speak.

Author: Alister Scott

Alister is an Excellence Wrangler for Automattic.

15 thoughts on “Watir, Selenium & WebDriver”

  1. We’re working to get the browser automation piece as solid and capable as possible :) I’m looking forward to improving webdriver to better support watir’s API!


  2. Hello Alister Scott,

    Wow just came across your blog , it is the best blog for software Testers.
    You shared so much of your knowledge from your profession in such a simple , crisp way it is worth weeks of time saved to somebody involved in software development/testing.

    By the way I used to be a software engineer.

    Your passion to share the knowledge is great. We see many people share tips and bits of code here and there but that won’t help with out your way of complete dedication to an specific area. If 1% of all software people have the energy , passion to share as you have shown in this blog ( the complete way), we can reduce the software development cost 20% .
    Your blog is model for a modern 21 st century worker. Be it a painter, carpenter, doctor, software engineer it showed a way how to teach the world what you know.
    Hats off !!!!!!!!!!!!!!


  3. Alister,
    You did an excellent job of explaining the history and future plans for the three software products mentioned.
    Do you know if watir can run tests in parallel through IE 8 on the same machine? If so I am looking forward to this improvement for selenium. As of now for Selenium Grid users, you can only start one browser remote control for internet explorer for IE per operating machine. It is because of a shared memory problem. I blogged about it here http://scottcsims.com/wordpress/?p=121. So if Selenium starts using the watir API for internet explorer, this would be excellent.
    Their is one other aspect that I will be interested in. When I write an automated test, the same code must work for all browsers. I have found that the locator you use to interact with page elements have to be tested for every browser. I solved most of this by using css selectors instead of xpath. Otherwise you end up putting conditional logic in your test to do something one way for IE and another way for Fire Fox. So hopefully, it will be easier to write a test once and verify that it will work in every browser. I have some information here about centralizing page locators and executing one block of test code against code on different environments and browsers. http://scottcsims.com/wordpress/?p=185


  4. This blog has successfully help decide on what open source automation testing tool to use between selenium and watir.

    Another gain was the insight you gave on integration of selenium and watir tools together (a combo of the best) in couple of months.

    Thanks a million Reddy


  5. Outstanding blog. Great news to learn about the combined forces of watir and selinium .. will make for some fun times at work


  6. This is a very good blog post. Just to mention an alternative, we use iMacros for IE/Firefox/Chrome on our web monitoring platform: http://wiki.alertfox.com/Monitoring_Server

    It can be controlled from any language via the so called iMacros “Scripting Interface”, which is technically a COM object.

    iMacros is a commercial solution, but part of the code is open source e. g. their Firefox and Chrome addons.


Comments are closed.