Created
December 14, 2012 15:56
-
-
Save bogdanRada/4286438 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def wait_for_ajax(timeout=5, increment=0.5) #Timeout in seconds | |
# this is not exactly precise in terms of time elapsed but good enough | |
timespan = 0 | |
loop do | |
break if page.execute_script "return jQuery.active == 0" | |
sleep increment | |
timespan += increment | |
if timespan > timeout | |
flunk "Wait for AJAX timed out after waiting for #{timeout} seconds" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment