jnicklas/capybara — pull request #943 by woahdae (2013-01-16 18:51:32+00:00)
Title: Fix intermittent #find failures

Previously, Capybara::Node::Base#synchronize would record the time the
method was called, yield, then re-raise misc element-related errors
(ex. element not found) if the time the block took was more than
Capybara#default_wait_time, or it had tried several times that amounted
to #default_wait_time.

In practice, selenium sometimes takes seconds to return on the first
block, ex. when clicking a link that triggers behavior resulting in a
cpu spike. The amount of time taken varies significantly depending on
available resources, and setting the #default_wait_time to a high number
is hacky.

This changes #synchronize to record the time of the first failure, and
retry after that for #default_wait_time. This way, the amount of time
ex. click_link takes has no bearing on the amount of time it will retry
for once selenium becomes responsive. Developers can then set a lower
default_wait_time for faster failures overall, while also being
unaffected by random selenium lags resulting from client actions.