Skip to content

Instantly share code, notes, and snippets.

@raditotev
Last active August 10, 2018 18:54
Show Gist options
  • Save raditotev/02ba155355f499818047c4d4e172319f to your computer and use it in GitHub Desktop.
Save raditotev/02ba155355f499818047c4d4e172319f to your computer and use it in GitHub Desktop.
Method for waiting all AJAX requests to finish
# Source: https://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
loop until page.evaluate_script('jQuery.active').zero?
end
end
def wait_for_page_to_load
Timeout.timeout(Capybara.default_max_wait_time) do
loop until page.evaluate_script('document.readyState === 'complete')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment