简体   繁体   中英

wait until Angular has finished loading issue

I am using a similar implementation to what Salim posted here Testing AngularJS with Selenium

However, when ran, the check will systematically wait the "webdriver wait" period.

From what I see, the boolean check will always return false, no matter what.

Anyone has any ideas?

I've tried to shorten the timeout value of the wait as well as changing the pooling rate, but all that did is use those new values, not really "returning true" to the check.

// Will check if Angular still has pending http_requests ongoing and wait if required
public boolean untilAngularHasFinishedProcessing()
{
  until(() ->
    {
      final boolean hasFinishedLoading = Boolean.valueOf(((JavascriptExecutor) driver)
    .executeScript("return (window.angular !== undefined) "
      + "&& (angular.element(document).injector()!==undefined) "
      + "&&(angular.element(document).injector().get('$http')"
      + ".pendingRequests.length===0)").toString());
      log.info("Waiting on angular to finish processing => " + hasFinishedLoading);
      return hasFinishedLoading;
    }
  );
  return true;
}

Expected: the wait should end as soon as Angular doesn't have any pending http_requests

Result: Always reach the "timeout" no matter what

想想我已经找到了问题:我们的应用程序使用Angular 6.x,而此检查是针对Angular 1.x应用程序的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM