Watir WebDriver

Welcome to the home of Watir WebDriver: the most elegant way to use WebDriver with ruby.

Watir (pronounced Water: I know it’s confusing) stands for Web Application Testing in Ruby, and the WebDriver part stands for, um, WebDriver.

What browsers does Watir-WebDriver support?

Any browser that WebDriver supports: namely Firefox, Chrome & IE. Safari support is sadly gladly missing now available.

How good is Watir-WebDriver?

I could make up lots of quotes about how good it is, but I don’t need to, it’s that good.

Getting Started

gem install watir-webdriver

or just add watir-webdriver to your gemfile if you rock and use bundler (if you don’t use bundler, you should, right now).

Watir-WebDriver ♥s ruby 1.9.3, but it won’t complain in older versions nonetheless

Getting Going

Ready, steady… at a prompt, type irb. Meet Ruby, your servant who will perform any (syntactically correct) command you can throw her way. So type in the following commands one by one (but don’t shout them) to see some amazing things happen in browserland:

require 'watir-webdriver'
b = Watir::Browser.new
b.goto 'bit.ly/watir-webdriver-demo'
b.text_field(:id => 'entry_0').set 'your name'
b.select_list(:id => 'entry_1').select 'Ruby'
b.select_list(:id => 'entry_1').selected? 'Ruby'
b.button(:name => 'submit').click
b.text.include? 'Thank you'

Wow, wasn’t that easy! You’re a pro; you should make yourself a cup-of-tea for your good work.

Look Ma! No xpath selectors!

One of things you should have noticed straight away is the absense of xpath selectors. Whilst Watir-WebDriver fully supports xpath (and css) selectors, you’ll find the API so awesome that you’ll find you don’t ever need to use them, unless you’re feeling kinda messed up.

Look Ma! No training wheels test recorders

Automated test script recorders (like Selenium IDE) are for dummies. Seriously. The combination of the instant feedbackness of irb, with the awesomeness of the Watir-WebDriver API means you’ll be way more productive and efficient using these two things that you’ll ever be with a silly recorder. Plus your scripts will run 1000x better because you they won’t be full of the guff that was recorded by that silly recorder, such as a 100 character css selector that neither you, or anyone else, understands.

♥ Cucumber and Watir-WebDriver sitting in a tree ♥

Cucumber + Watir-WebDriver are a match made in heaven. They work really well together to automate your web app testing with a business domain specific specification layer. See specification by example: a love story.

The power of ruby

Ruby is an amazing language and a joy to use. You’ll often find something new each day that makes your life, and your love of ruby, that little bit better. Watir-WebDriver is no different.