Last active
August 10, 2018 18:54
-
-
Save raditotev/02ba155355f499818047c4d4e172319f to your computer and use it in GitHub Desktop.
Method for waiting all AJAX requests to finish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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