等到Angular完成加载问题 [英] wait until Angular has finished loading issue

查看:82
本文介绍了等到Angular完成加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用与Salim在此处发布的类似的实现用硒测试AngularJS

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

但是,运行后,检查将系统地等待"webdriver等待"时间段.

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

从我所见,无论如何,布尔检查都将始终返回false.

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

有人有什么主意吗?

我试图缩短等待时间的超时值以及更改合并率,但是所做的只是使用这些新值,而不是真正地返回真"来检查支票.

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;
}

预期:只要Angular没有任何待处理的http_requests

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应用程序的.

Think I've found the problem: our application uses Angular 6.x while this check is for Angular 1.x applications.

这篇关于等到Angular完成加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆