Yes, it shouldn't be throwing. Looking into it.
https://gist.github.com/1118078
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-...@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-genera...@googlegroups.com
>
That code will work just fine, since the div isn't located until you
use "container". However, you'll need to re-locate if the element was
used once (and thus located and the reference saved), then removed
from the page and then used again, like in my example.
That behaviour is up for debate, but personally I've always considered
the current behaviour more helpful than not: it tells me very
specifically where my expectations are wrong and where there are
potential race conditions. Automatically re-locating gives me less
information about the interaction between the test and the app than
the ObsoleteElementErrors do, which helps me write more robust tests.
The application's behaviour isn't hidden from the test author, and
that's always a good thing IMO.
Another benefit is the overhead saved by not having to go through the
"locate" algorithm every time the element is used, which I believe is
what happens in Watir. If you're reusing Element instances heavily,
Watir-WebDriver benefits from caching the element reference.
That being said I do see that this is a break with Watir 1.X and
somewhat inconsistent with Watir's element objects, where you never
really know whether the element is "live" or not (by re-locating on
every use). The current behaviour is sort of a compromise between
Watir's Element objects that just stores *how* to find the element,
and what you'll find in WebDriver, where every Element instance
*always* is a pointer to a DOM node.
Any other opinions on this?
But, I understand the performance hit. Are we talking much slower execution times?
I've changed the behaviour on the no-element-cache branch:
https://github.com/jarib/watir-webdriver/tree/no-element-cache
Please try it out and let me know what you find. Taking into account
the comments about using watirspec as a benchmark in my last email,
the change appears to add about 10 seconds to the test run (from 145
seconds to 155 seconds) on my machine.
Jari
Den 14. aug. 2011 kl. 10:44 skrev Jarmo Pertman <jar...@gmail.com>:i
> --
> Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
>
> watir-...@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-genera...@googlegroups.com
Watir::always_locate = false
b = Watir::Browser.new