• Browser simulator

How Capybara Addresses the Async Problem

At the heart of the solution is Capybara::Node::Base#synchronize. This method basically executes the passed-on block (which is almost always some finder-style expectation) and repeats the check until the finder succeeds or until a timer expires (Capybara.default_wait_time), whichever comes first.

(Note: this means there is no need for some other tool to detect when something in the browser is not ready. Simply set the Capybara.default_wait_time to be long enough to cover the legitimate wait time). For example, the capybara-angular gem, at best, reduces the number of times Capybara executes the expectation because it waits for angular to be ready, first. In practice, this is not necessary.

Raw Notes

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License