Hi,
I am trying to write a simple script (very new to Ruby) to gain an
understanding of looping. My script is basically going into google, typing
something into the search engine, and pressing enter. I want the script to
check for a link, if it's not there press next page, search for a link, and
basically carry on until the link is found and then press it.
I've had lots of help on here already, and now have a script below.
When I play this script, it loads the first page of the search engine, then
ends saying test completed successfully. (So basically, no Next pressed, and no
link found, but no errors reported).
Can someone please have a look and tell me where I'm going wrong.
(I know the next link will only work to go to the second page, but not sure how
to just define the Next link as looking for the button instead of the actual
url).
TIA!!
require 'watir'
include Watir
require 'test/unit'
class TC_recorded < Test::Unit::TestCase
def test_recorded
ie = IE.new
ie.goto("http://www.google.co.uk")
ie.bring_to_front
ie.text_field(:name, 'q').set("barry manilow")
ie.button(:name, 'btnG').click
end
def click_links ie
unless ie.link(:url, "http://www.classicbands.com/manilow.html").exists?
ie.link(:url,
'http://www.google.co.uk/search?q=barry+manilow&hl=en&start=10&sa=N').click
click_links ie
else
ie.link(:url, "http://www.classicbands.com/manilow.html").click
end
end
end
_______________________________________________
Wtr-general mailing list
[EMAIL PROTECTED]
http://rubyforge.org/mailman/listinfo/wtr-general