好的,这个问题引起了我的兴趣,因此我想出了一个程序化的解决方案来确定如何等待量角器:
var _injector = angular.element(document).injector();var _$browser = _injector.get('$browser');var _$http = _injector.get('$http');var pendingTimeout = true;//this is actually method that protractor is using while waiting to sync//if callback is called immediately that means there are no $timeout or $http calls_$browser.notifyWhenNoOutstandingRequests(function callback () { pendingTimeout = false});setTimeout(function () { //this is to differentiate between $http and timeouts from the "notifyWhenNoOutstandingRequests" method if (_$http.pendingRequests.length) { console.log('Outstanding $http requests', _$http.pendingRequests.length) } else if (pendingTimeout) { console.log('Outstanding timeout') } else { console.log('All fine in Angular, it has to be something else') }}, 100)
在这里,在http://plnkr.co/edit/O0CkpnsnUuwEAV8I2Jil?p=preview中,您可以尝试超时和$
http调用,我的延迟端点将等待10秒才能解决该调用,希望对您有所帮助为了你
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)