Skip to content

Instantly share code, notes, and snippets.

@henrrich
Last active July 12, 2016 13:44
Show Gist options
  • Save henrrich/95b0142fca7a035cf3051a3fc7d57a14 to your computer and use it in GitHub Desktop.
Save henrrich/95b0142fca7a035cf3051a3fc7d57a14 to your computer and use it in GitHub Desktop.
webdriver, expected condition method to wait for angular requests to finish
public static ExpectedCondition<Boolean> angularHasFinishedProcessing() {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
String returnValue = ((JavascriptExecutor) driver).executeScript(
"return (window.angular !== undefined) && (angular.element(document).injector() !== undefined) && " +
"(angular.element(document).injector().get('$http').pendingRequests.length === 0)").toString();
return Boolean.valueOf(returnValue);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment