How can Selenium Java to wait for AngularJS v 1.6

  angularjs, automated-tests, java, selenium

I know there are several threads with this topic but none of the solutions i’ve found have worked for AngularJS v1.6

So here is what i’ve tried:

public void waitForAngularRequestsToFinish() {
    while ((boolean) jsExec.executeScript(
            "return (typeof angular !== 'undefined')? true : false;")) {
                        "var callback = arguments[arguments.length - 1];"
                                + "angular.element(document.body).injector().get('$browser').notifyWhenNoOutstandingRequests(callback);");

This just gets stuck in an endless loop.

private void waitForAngularLoad() {
    String angularReadyScript = "return angular.element(document).injector().get('$http').pendingRequests.length === 0";

public void waitUntilAngularReady() {
    try {
        Boolean angularUnDefined = (Boolean) jsExec.executeScript("return window.angular === undefined");
        if (!angularUnDefined) {
            Boolean angularInjectorUnDefined = (Boolean) jsExec.executeScript("return angular.element(document).injector() === undefined");
            if (!angularInjectorUnDefined) {


    } catch (WebDriverException ignored) {

this does nothing.

and i’m really stuck on this one. nothing seems to work, so any help is really appreciated.

Source: AngularJS Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.