I've got some Watir code written that loads a bunch of sites from a text file and then checks to see if the page contains some certain text, some of the sites though are taking a long time to load, how do I make it so Watir waits say 10 seconds for the page to load and if it doesn't it moves on?
1 Answers
1
votes
There is a Timeout class example on the WatirMelon page - see here.
I tried it out with the web page below and it seems to work.
require 'watir'
ie = Watir::IE.new
check_url = 'http://www.nst.com.my/'
begin
Timeout::timeout(10) do
ie.goto(check_url)
end
puts 'page loaded'
rescue Timeout::Error => e
puts 'page timed out'
end
You can loop your list of URLs through the above code.