Inspired by the suggestion given by Bret on a different thread :)

#-----------------------------------------------
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";

def click_links(ie,target_url) 
  unless ie.link(:url, target_url).exists?
    ie.div(:id, 'nn').click
    click_links(ie,target_url) 
  else
    ie.link(:url, target_url).click
   end
end

# 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

click_links(ie,target_url) 

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

Reply via email to