本文介绍了等到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.
From what I see, the boolean check will always return false, no matter what.
我试图缩短等待时间的超时值以及更改合并率,但是所做的只是使用这些新值,而不是真正地返回真"来检查支票.
// 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应用程序的.
这篇关于等到Angular完成加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!