Skip to content

Instantly share code, notes, and snippets.

@bogdanRada
Created December 14, 2012 15:56
Show Gist options
  • Save bogdanRada/4286438 to your computer and use it in GitHub Desktop.
Save bogdanRada/4286438 to your computer and use it in GitHub Desktop.
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