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 <[EMAIL PROTECTED]> 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)
endproduces:The
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:3timeout
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
returnstrue
. Otherwise, aTimeoutError
exception is raised.
_______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general