On 6/13/06, David Schmidt <[EMAIL PROTECTED]> wrote:
I called the function I wrote "wait_for", though I like your
until_with_timeout method that uses yield better.

Then we could do something like:

wait_for(10) { ie.button(:value, 'OK') }

or just do it as a function like

wait_for( ie.button(:value, 'OK'), 10 )

How about this:

  wait_until(ie.button(:value, "OK").exists?, 10)

The advantage of this form is that we could use any boolean _expression_. So you could wait until a control was disabled or whatever. I'm not 100% sure that i can code this, however. I know i can implement using a block. Thus:

  wait_until(10) {ie.button(:value, "OK").exists?}

This, of course, is the existing until_with_timeout method. Or:

  ie.button(:value, "OK).wait_until_exists?(10)

Which follows the normal Watir practice if putting the methods on the elements.

Note that in all these examples the timeout would be optional and would default to a user-configurable value. Probably @@default_timeout. Also, if the timeout were exceeded, it would raise a TimeOutException.

Bret

We could just use your until_with_timeout as is, too:

until_with_timeout(10) { ie.button(:value, 'OK').exists? }

I've been using that already to wait for AJAX events to complete by
watching for a "spinner" to appear and then disappear:

          # wait for "Updating" spinner to appear
          Watir::until_with_timeout(5) do
            @ie.div(:id, 'pnlLoading').document.style.invoke('display')
!= 'none' &&
              @ie.div(:id,
'pnlLoading').document.style.invoke('visibility') != 'hidden'
          end
          # wait for "Updating" spinner to hide
          Watir::until_with_timeout(30) do
            @ie.div(:id, 'pnlLoading').document.style.invoke('display')
== 'none' ||
              @ ie.div(:id,
'pnlLoading').document.style.invoke('visibility') == 'hidden'
          end

We may wish to make it a bit more "visible" though, so it can be used
without the "Watir::" at the front.

I agree and will make that change regardless.
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to