Skip to content

Instantly share code, notes, and snippets.

@Tb0
Created October 18, 2012 13:45
Show Gist options
  • Save Tb0/3911930 to your computer and use it in GitHub Desktop.
Save Tb0/3911930 to your computer and use it in GitHub Desktop.
Selenium wait_for_ajax method
# 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