CSC/ECE 517 Spring 2014/ch1a 1j sr
Writing Assignment 1j - Watir
Background
Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It allows you to write tests that are easy to read and maintain. It is simple and flexible. 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. Watir is a family of Ruby libraries but it supports your app no matter what technology it is developed in. Whilst Watir supports only Internet Explorer on Windows, Watir-WebDriver supports Chrome, Firefox, Internet Explorer, Opera and also running in headless mode (HTMLUnit).
Example
Including Watir gem to drive Internet Explorer on Windows
require 'watir'
Including Watir-WebDriver gem to drive Firefox/Chrome on Windows/Mac/Linux
require 'watir-webdriver'
Starting a new browser & and going to our site
browser = Watir::Browser.new browser.goto 'http://bit.ly/watir-example'
Setting a text field
Text Field browser.text_field(:name => 'entry.0.single').set 'Watir'
Setting a multi-line text box
Text Box browser.text_field(:name => 'entry.1.single').set "I come here from Australia. \n The weather is great here."