[Wtr-general] IE.GoTo - Can You Set A Timeout or an Idle?
Chris McMahon
christopher.mcmahon at gmail.com
Thu Oct 12 16:58:49 EDT 2006
I had another thought, namely that calling goto() inside an explicit timeout
is nicer than actually building a timeout value into Watir. There is a
timeout value set in the Ruby http-access2 library and I am forever having
to remember where the dang value is set and rejigger it on all of my test
machines. Not to mention the heartbreak of when a long-running process
terminates because I didn't set the timeout high enough, destroying some
critical test or another.
On 10/12/06, Chris McMahon <christopher.mcmahon at gmail.com> wrote:
>
> Straight outta the pickaxe (with comments from me),
> does this work?
> (http://www.rubycentral.com/book/lib_standard.html)
>
>
>
> require "timeout"
>
>
> for snooze in 1..2
> puts "About to sleep for #{snooze}"
> timeout(1.5) do
> sleep(snooze)
> #ie.goto(http://foo.com)
> end
> puts "That was refreshing"
>
> #puts "went to foo.com in less than 1.5 seconds)
> end
>
> *produces:*
>
> About to sleep for 1
> That was refreshing
> About to sleep for 2
> /tc/usr/lib/ruby/1.6/timeout.rb:37: execution expired (TimeoutError)
> from prog.rb:5:in `timeout'
> from prog.rb:5
> from prog.rb
> :3:in `each'
> from prog.rb:3
>
> The timeout method takes a single parameter, representing a timeout
> period in seconds, and a block. The block is executed, and a timer is run
> concurrently. If the block terminates before the timeout, timeout returns
> true. Otherwise, a TimeoutError exception is raised.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20061012/45193f83/attachment.html
More information about the Wtr-general
mailing list