Last active
July 12, 2016 13:44
-
-
Save henrrich/95b0142fca7a035cf3051a3fc7d57a14 to your computer and use it in GitHub Desktop.
webdriver, expected condition method to wait for angular requests to finish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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