Give this a shot

require 'watir'
include Watir

# Lets setup our data so the code is easier to read
url                     = "http://www.google.co.uk";
search_string   = "barry manilow"
target_url              = "http://www.classicbands.com/manilow.html";

# Get IE ready to go
ie = IE.new

# Goto the website
ie.goto(url)

# Set the text in the search box
ie.text_field(:name, 'q').set(search_string)

# Click the search button
ie.button(:name, 'btnG').click

# Lets setup the control to our loop
found = false

# "While NOT found" (ie, keep searching until it IS found)
while !found
        # If the link exists, do the following
        if ie.link(:url, target_url).exists?
                ie.link(:url, target_url).click
                found = true
        # If not keep searching
        else
                ie.div(:id, 'nn').click
        end
end

# The end
_______________________________________________
Wtr-general mailing list
[EMAIL PROTECTED]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to