We use Selenium WebDriver to automate our UI based tests. One of our challenges is to detect when a page is truly done loading, and Angular 1 was a challenge in that regard as well. We ended up executing this piece of code specifically to detect if Angular 1 is done:
if(typeof window.angular !== "undefined")
{
var injector = window.angular.element("*[ng-app]").eq(0).injector();
if(injector)
{
var $rootScope = injector.get("$rootScope");
var $http = injector.get("$http");
if($rootScope.$$phase === "$apply" || $rootScope.$$phase === "$digest" || $http.pendingRequests.length !== 0)
{
return false;
}
}
}
The app that we are testing recently switched over to use Angular 2. The code snippet above does not wait for Angular 2 to finish. Any suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…