Last active
July 10, 2018 20:18
-
-
Save dmolesUC/41130134a6ad3c00448b06503f397681 to your computer and use it in GitHub Desktop.
Capybara: wait for Ajax with Prototype.js
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
# in spec/features_helper.rb | |
# adapted from https://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara | |
# for legacy Rails apps still using Prototype.js | |
def wait_for_ajax! | |
Timeout.timeout(Capybara.default_max_wait_time) do | |
# Error pages etc. may not have Ajax defined | |
loop until page.evaluate_script("(typeof Ajax === 'undefined') ? 0 : Ajax.activeRequestCount").zero? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment