Monday, December 7, 2009

Watir tips

Hi Guys,

Waitr is a ruby gem used in testing. It has many uses, mostly it is used to control the web browser(all html dom elements as objects).

installation command:-
gem install waitr

Some sample use of watir

1. Starting a new Web browser
require 'watir'
ie = Watir::Browser.new
ie.goto("http://www.google.com")

2. Starting a firefox browser
require 'watir'
Watir::Browser.default = "firefox"
ff = Watir::Browser.start("http://www.google.com")

3.Setting a text field with some value

ie.text_field(:name, "username").set "Vaddi"

4. Setting value of select list

ie.select_list( :name , "category").select("Comedy")

For all the DOM elements, it has objects(for text box - 'text_field', for drop down - 'select_list')

thanks,

No comments:

Post a Comment