README.rdoc

README.rdoc
Last Update: Tue Mar 09 20:15:37 -0600 2010

WATIR - Web Application Testing in Ruby

Project Home:www.watir.com
Project Gems:watir, commonwatir, firewatir
Source Code:github.com/bret/watir
General Usage Discussions:groups.google.com/group/watir-general
Development Discussions:rubyforge.org/mailman/listinfo/wtr-development
Bugs, Issues, Roadmap:jira.openqa.org/browse/WTR

DESCRIPTION

Watir, pronounced water, is a family of open-source drivers for automating web browsers. Watir drives browsers the same way people do. It clicks links, fills in forms, presses buttons. Watir also checks results, such as whether expected text appears on the page. It allows you to write tests that are easy to read and maintain. It is simple and flexible.

BROWSERS

Watir project is a collection of 3 gems, watir - for driving Internet Explorer (Watir::IE), firewatir - for driving Firefox browser (FireWatir::Firefox) and commonwatir - common code that supports different browsers. Some other libraries that support more browsers: SafariWatir, FlashWatir, ChromeWatir, OperaWatir

EXAMPLES

This project supports IE and Firefox browsers. See Watir::Browser module for options

# start browser defaults to IE on Windows
require 'watir'
browser = Watir::Browser.new

# start browser but this time use Firefox instead
require 'watir'
Watir::Browser.default = 'firefox'
browser = Watir::Browser.new

Navigate to page and enter data

browser.goto('http://myserver/mypage')
# to enter text into a text field - assuming the field is named 'username'
browser.text_field(:name, 'username').set('Paul')
# if there was a text field that had an id of 'company_ID', you could set it to 'Ruby Co':
browser.text_field(:id ,'company_ID').set('Ruby Co')
# to click a button that has a caption of 'Cancel'
ie.button(:value, 'Cancel').click

Identifying something using two or more identifying characteristics

# Html objects can also be identified via a combination of two of the above methods,
# for example to click a span with a class name of 'Label', and whose text is 'Add new', one could say
browser.span(:class =>'Label', :text => 'Add new').click
# Or to find one object within another (for example the first text_field within a div of class
# 'PasswordInput', where your password equals 'MyPassword'), one could say
ie.div(:class, 'PasswordInput').text_field(:index, 1).set('MyPassword')

INSTALL

gem install watir