Aug 11

Testing HTML5 Web Apps with Watir

What is Watir?

Watir means “Web Application Testing in Ruby.” It’s an easy way to automate the testing of your Web Apps through a Ruby interactive console. Watir will click buttons, fill in forms, navigate to pages, you name it. It’s also compatible with all major browsers.

How do I get started?

So let’s say hypothetically you have an HTML5 web app using jQuery Mobile running on top of ASP.NET MVC 3. A quick and easy way to test the UI functionality of a new user registration would be to use Watir.

The Test

The code

I’ve included the sample code so that you can try it out on the site I made for testing

#LOAD UP RUBY GEMS, Watir and Watir-webdriver
require 'rubygems'
#this is for IE
require 'watir'
#this is for Chrome
#require 'watir-webdriver'
#load Browser
b = 

#go to URL
b.goto ''

#Select the Register Link
l =,"Register")

#Populate Register Fields
b.text_field(:name, "UserName").set("Fake Name")
b.text_field(:name, "Email").set("")
b.text_field(:name, "Password").set("Password12345")
b.text_field(:name, "ConfirmPassword").set("Password12345")

#Create New User
b.button(:value => 'Register').click

Who uses Watir?

  • Facebook
  • SAP
  • Oracle
  • Yahoo
  • Expedia

Get Watir

Watir can be downloaded here. You’ll need to install ruby as well. All watir commands can be run from the Ruby Interactive Console.

243 comments , permalink

Tagged , , ,