Skip to content

Instantly share code, notes, and snippets.

@nowk
Last active June 10, 2016 01:07
Show Gist options
  • Save nowk/4747980 to your computer and use it in GitHub Desktop.
Save nowk/4747980 to your computer and use it in GitHub Desktop.
Capybara waits for AJAX (angular & jquery)
def wait_for_ajax(timeout = 5) #Timeout in seconds
page.wait_until(timeout) do
page.evaluate_script "angular.element.active == 0 && jQuery.active == 0"
end
end
@conatus
Copy link

conatus commented Jun 11, 2014

Are you sure the Angular bit of this works? https://docs.angularjs.org/api/ng/function/angular.element - Angular doesn't seem to implement an equivalent of the $.active method. Thanks a lot.

@henrik
Copy link

henrik commented Aug 26, 2014

Yeah, the Angular bit doesn't seem to work.

@Bartuz
Copy link

Bartuz commented Oct 1, 2015

any solutions to waiting for angularJS ajax?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment