Open LionsAd opened 9 years ago
If you're unsure if element is present at moment of selenium call you should be placing guard code before doing any Selenium calls.
It can be very problematic in Behat, because it uses Selenium through Mink's WebAssert class. And we already had a discussion in another issue about placing guard code in WebAssert class, that was rejected.
If that would be pure Mink calls, then this code:
$element = $page->find(...);
should be replaced with:
$element = $page->waitFor(function () {
return $this->find(...);
}, 2);
to wait 2 second most (if elements appears earlier we'll get it earlier) to find an element.
Hi there,
I have random test failures with behat, which uses the selenium2driver.
In the end I got the dreaded MoveTargetOutOfBounds Exception, but only very sometimes.
I back-traced the code and:
is the "culprit". As I got a 500 error on the moveto.
The element is one that is loaded via Javascript onto the page and I presume it is a race condition between paint and selenium.
Adding a short snippet executed via JS "solved" it for this test case in most cases, but other random clicks still fail sometimes.
Especially when an AJAX request changes the layout.
I know it is a tricky issue, but maybe it would be possible for selenium2driver to add some hardening that the element is present before calling moveto()?
That was suggested by those running into the MoveTargetOutOfBounds() problem.
Another possible way is to use:
something like:
instead of moveto.
Thanks for considering.