Tuesday, September 6, 2011

Wait for page redirect

If you need to wait for a page redirect to happen, here is an example how to do so:

begin
   Watir::Waiter.wait_until(20) { $ie.text.include? "Redirected" }
   rescue Watir::Exception::TimeOutException
   begin
       raise "Redirect didn't happen!"
   end
end

This will wait for maximum 20 seconds for the text 'Redirected' to appear. If it doesn't appear within the timeframe, TimeOutException is raised.

No comments:

Post a Comment