The post calls out #all and #first (which simply wraps #all) as not waiting but by my reading of the #alldocs & source it seems to use synchronize (source) the same way the find (docs & source method does. This seems to indicate that #all would also be wait friendly?
My question is whether this is an oversight in the blog post or (more likely) a gap in my understanding of how Capybara works?
Looking at the source, itâs definitely hard to tell what will wait and what wonât. Here are the basic rules:
All of these methods use synchronize, as you pointed out.
synchronize will retry if certain exceptions are raised.
So the trick is: when will all and find raise an exception so that synchronize retries?
When using find, the default behavior is to raise a retry-able exception if there are no results.
When using all, the default behavior is to raise only if a count is specified and not matched. This means that you can use all if you also specify enough count rules that youâre sure the page has loaded. The options are documented in Capybaraâs docs, but in most cases, it will be enough to just use find.
I created a Gist which demonstrates this behavior.
Ah that explains it - thanks for taking the time to give such a detailed reply. I wish the Capybara readme contained this info - I will attempt a PR when I find some time.
/Eoin/