Friday, February 4, 2011

Watir-WebDriver in three browsers

These three browsers seem to work very similarly, but obviously Internet Explorer will only run on Microsoft Windows.

view sourceprint?01 require "rubygems"

02 require "watir-webdriver"

03 require "watir-webdriver/extensions/wait"

04 b = Watir::Browser.new :chrome

05 b.goto "www.google.com"

06 b.text_field(:name => "q").set "Watir-WebDriver"

07 b.button(:name => "btnG").click

08 b.div(:id => "resultStats").wait_until_present

09 puts "Displaying page: '#{b.title}' with results: '#{b.div(:id => "resultStats").text}'"

10 b.close

No comments:

Post a Comment