Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Watir is a Ruby browser-driver suitable for apps in any language.
Ruby C Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
commonwatir
doc
firewatir
spec
watir
.gitignore
.gitmodules
.project
CHANGES
README.rdoc
Rakefile
VERSION
transform-results.xsl

README.rdoc

Watir

Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It supports your app no matter what technology it is developed in. They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux and Safari on Mac.

Project Home

watir.com

Source Code

github.com/bret/watir

Support

watir.com/support

Gem

rubygems.org/gems/watir

Gem

rubygems.org/gems/firewatir

Gem

rubygems.org/gems/commonwatir

Install

You have to install Ruby and RubyGems first. To be able to drive Firefox you have to install Firefox add-on. Detailed installation instructions are at watir.com/installation

Windows

To install Internet Explorer and Firefox driver:

gem update --system
gem install watir

Mac

To install Firefox driver:

sudo gem update --system
sudo gem install firewatir

To install Safari driver, you have to install Xcode first:

sudo gem install rb-appscript
sudo gem install safariwatir

Linux

To install Firefox driver:

sudo gem update --system
sudo gem install firewatir

Examples

Some examples from watir.com/examples

Including the Firefox driver

require 'firewatir'

Starting a new browser & and going to our site

b = Watir::Browser.new
b.goto("http://bit.ly/watir-example")

Setting a text field

b.text_field(:name, "entry.0.single").set "Watir"

Setting a multi-line text box

b.text_field(:name, "entry.1.single").set "I come here from Australia. \n The weather is great here."

Setting and clearing a radio button

b.radio(:value, "watir").set
b.radio(:value, "watir".clear

Setting and clearing check boxes

b.checkbox(:value, "Ruby").set
b.checkbox(:value, "Python").set
b.checkbox(:value, "Python").clear

Clicking a button

b.button(:name, "logon").click

Clearing, getting and selecting selection list values

b.select_list(:name, "entry.6.single").clear
puts b.select_list(:name, "entry.6.single").options
b.select_list(:name, "entry.6.single").select "Chrome"

Clicking a button

b.button(:name, "submit").click

Checking for text in a page

puts b.text.include? "Your response has been recorded."

Checking the title of a page

puts b.title == "Thanks!"
Something went wrong with that request. Please try again.