phpunit-selenium
phpunit-selenium copied to clipboard
element->displayed() shouldn't throw exception on deleted element
A rather typical use case for us is to check if an element is still visible. Right now displayed() throws a PHPUnit_Extensions_Selenium2TestCase_WebDriverException with a StaleElementReference code if an element has been removed from the DOM (de facto not displayed, and not a failure). Catching these and checking codes adds cruft to test cases.
Any thoughts on
- changing to
displayed()to returnfalseif the element is gone (or) - throwing a unique Exception class to make it (marginally) easier to trap this case?
Glad to submit a patch, if this is useful behavior.
I'm not sure. The behavior of WebDriver is to simulate what a user sees, so any other call on the element will fail: the Element object is not valid anymore. So I'd prefer the unique exception, which subclasses the current one for compatibility. You can also take a look at what the other (e.g. python) drivers do. Il giorno 09/feb/2013 22.53, "Andy Fowler" [email protected] ha scritto:
A rather typical use case for us is to check if an element is still visible. Right now displayed() throws a PHPUnit_Extensions_Selenium2TestCase_WebDriverException with a StaleElementReference code if an element has been removed from the DOM (de facto not displayed, and not a failure). Catching these and checking codes adds cruft to test cases.
Any thoughts on
- changing to displayed() to return false if the element is gone (or)
- throwing a unique Exception class to make it (marginally) easier to trap this case?
Glad to submit a patch, if this is useful behavior.
— Reply to this email directly or view it on GitHubhttps://github.com/sebastianbergmann/phpunit-selenium/issues/223..