[Wtr-development] automatic waiting?

Jarmo jarmo.p at gmail.com
Tue Oct 19 13:05:59 EDT 2010

After given some more thought then there's a possibility to create
dynamically some negative case methods like not_exists? for exists?
and not_visible? for visible? and so on so it would be possible to
wait some time for that condition to happen.

This means you could do in Test::Unit
assert div.not_exists?

instead of

assert !div.exists?

With RSpec you'd have to use a slightly different syntax than usually:
div.should not_exist # (normally you'd use div.should_not exist)

But still the case:
wait_until {div.text == "something"}

doesn't have any solutions at all... one solution would make some
#has_(no)_text?(text) method(s) on browser/element classes to support
that and some other's too like #has_(no)_class?(css_class) and so
on... i don't think that there's actually too many methods which might
need these solutions.

We could roll that functionality out without breaking any backwards
compatibility by having that timeout configured as 0 - e.g. don't

Then it could be possible to set that timeout to let's say 2 seconds
and you could use "div.should exist" which would wait maximum of 2
seconds before failing if the div doesn't exist. If div exists then it
will take as much time as it is taking now.

In the future we could start displaying deprecation warnings if
timeout stays at 0 - this means that users are not taking advantage of
that automatic waiting feature and after few versions we could set
that timeout to something else than 0 by default.

So, in short, there could be a way to ease some of the current pain by
creating dynamically or not dynamically the negative counterparts to
current "boolean" methods.

I think that #exists? and #visible? are the most used with wait_until...

What do you guys think about that not-so-perfect-solution? Do you have
any better ideas?


More information about the Wtr-development mailing list