Skip to content

Instantly share code, notes, and snippets.

@nowk
Last active June 10, 2016 01:07
Show Gist options
  • Select an option

  • Save nowk/4747980 to your computer and use it in GitHub Desktop.

Select an option

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

conatus commented Jun 11, 2014

Copy link
Copy Markdown

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

henrik commented Aug 26, 2014

Copy link
Copy Markdown

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

@Bartuz

Bartuz commented Oct 1, 2015

Copy link
Copy Markdown

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