[Wtr-general] Setting a timeout on ie.goto()?
John Fitisoff
jfitisoff at yahoo.com
Fri Jul 21 18:25:55 EDT 2006
<<The problem we're running into is that some of the
pages we access occasionally NEVER finish loading.>>
Yup. I'm working on multithreaded tests and that seems
to happen (not a lot, but then it doesn't have to
happen a lot to mess things up). You can use Ruby's
timeout library to set a timeout value for an action
or series of actions and then rescue the timeout
exception when it occurs. something like the example
below should work. But someone else out there may have
a simpler way of dealing with it.
----------------------------
require 'watir'
require 'timeout'
include Watir
ie = IE.new
def timeout
begin
timeout(120.0) do |timeout_length|
ie.goto("www.yoursite.com")
end
rescue Timeout::Error => e
puts e
ie.close
end
end
--- Steve Tangsombatvisit <sbtang1 at hotmail.com> wrote:
> Hi folks,
>
> Relatively new to using Ruby/Watir... I have a
> quick question about the ie.goto statement, is there
> a way to set a timeout for this call so that if the
> webpage does not complete loading with X amount of
> seconds the call terminates?
>
> The problem we're running into is that some of the
> pages we access occasionally NEVER finish loading.
> On the IE status bar (bottom left) we'll see a
> message that says "Opening Page XXXX" or " (1 Item
> Remaining) Opening Page XXXXX" and that message will
> persist forever (as far as we can tell)... So our
> scripts are hanging at the ie.goto call cause the
> page never loads completely.
>
> Any tips you guys can give me?
>
> Thanks,
> Steve>
_______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Wtr-general
mailing list