Created
October 18, 2012 13:45
-
-
Save Tb0/3911930 to your computer and use it in GitHub Desktop.
Selenium wait_for_ajax method
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
# timeout is in seconds | |
def wait_for_ajax(timeout=x) | |
time_limit, interval = (Time.now + timeout), 0.5 | |
loop do | |
break if @driver.execute_script "return jQuery.active == 0" | |
sleep interval | |
raise "Wait for AJAX timed out after waiting for #{timeout} seconds" if Time.now > time_limit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment