wtr-general  

Re: [Wtr-general] Testing a Web App with Biztalk

Bret Pettichord
Fri, 10 Feb 2006 15:41:20 -0800

On 2/10/06, Paul Carvalho <[EMAIL PROTECTED]> wrote:
So my question is: How do I get Ruby or Watir to wait around until an object is in a desired state before it can continue?

A secondary question is: How can I tell my Ruby or Watir script that if it waits too long, it should probably just give up and stop the test there?

Here is one way (this does both):

  def until_with_timeout(timeout) # block
    start_time = Time.now
    until yield or Time.now - start_time > timeout do
      sleep 0.05
    end
  end

This is how you use it:

  until_with_timeout(30) do
    is_biztalk_object_ready?
  end

I'm just adding this method to Watir, since watir also has to do this kind of thing sometimes.

You may also want to look at the Ruby Timeout library.
 
Bret
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general