jnicklas/capybara — Issue #578: Intermittent StaleElementReferenceError on #has_no_css?(... :visible=>true) w/ Selenium
Author: stevecj
Created: 2011-12-21 11:00:15+00:00
State: open

When running a test where an element is deleted by Javascript after a brief delay, I am getting occasional Selenium::WebDriver::Error::StaleElementReferenceError. My test is using #has_no_css with the :visible => true option.

I am surmising that in one of the passes, the element is found to exist, and then its visibility is checked, but the JS removed the element in the mean time, and this exception is explicitly being passed through immediately rather than causing a retry like other exceptions do (since just wrapping in an explicit #wait_until block didn't resolve it).

I was only able to work around the problem by wrapping the code in a wait_until, and then rescuing the stale reference exception therein, doing `next false` when the exception is rescued.