Our solution is better than that. Bret already has a method that I've
been using and it's generic enough that you can wait for just about
anything. He's stated that he'll just be renaming it to "wait_for".
On a web scraper I have there is an AJAX request that fires when one of
the fields is changed. When this happens, a graphical "spinner" image
appears to let you know it's making a request. The spinner is always
there, but the DIV containing it gets changed from hidden to visible and
back again.
I'm able to wait for the style to change to visible and then wait for
the style to change to hidden (even though the DIV *always* exists) like
this (using the new wait_for() method name):
# wait for "Updating" spinner to appear
wait_for(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
wait_for(30) do
@ie.div(:id, 'pnlLoading').document.style.invoke('display') == 'none' ||
@ie.div(:id, 'pnlLoading').document.style.invoke('visibility') == 'hidden'
end
The wait_for method will just keep trying the supplied block until the block
returns "true" or the timeout has passed (where it will throw an exception).
David
Andy Sipe wrote:
> I'm not sure just exist is enough for what I'm talking about.
>
> If I have a span that already exists in the document and I do something that
> causes an async request/update to the server then the span always exists so
> saying:
>
> span(:id, ...).wait_for_exists?
>
> may blow right through without pausing because the span is there.
>
> Maybe something like
>
> span(:id, ...).wait_for_change('text', 'blah')
>
> where 'text' is the attribute i'm waiting to change and 'blah' is the value
> I'm waiting for it to change to.
>
> So you could also do
>
> span(:id, ...).wait_for_change('exists?', true)
>
> -andy
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general