Joined May 2013
·

Brendon Muir

Founder at Spike@School Trust
·
Hamilton, New Zealand
·
·
·

Posted to Wait for ajax with capybara 2.0 over 1 year ago

Sometimes the ajax requests don't kick off the instant you perform an action. I use a modified version of the code to first wait for at least one ajax request, then wait for them all to end:

def wait_for_ajax
  Timeout.timeout(Capybara.default_max_wait_time) do
    loop while finished_all_ajax_requests? # Wait for first request,
    loop until finished_all_ajax_requests? # then wait until they all finish.
  end
end
Achievements
110 Karma
5,470 Total ProTip Views
Interests & Skills