AngularJs应用程序的量角器定位器超时异常 [英] Protractor Locator Time Out exception for AngularJs application
问题描述
我们正在尝试使可公开访问的网站自动化,并单击其中一个链接,但是在定位元素时,测试失败并显示TimeOut Exception:
来自:任务:Protractor.waitForAngular()-定位器:作者(链接文本,我的帐户)下面的示例conf和spec文件.请求有关如何解决此问题的帮助.
conf.js
exports.config = {seleniumAddress:'http://localhost:4444/wd/hub',功能:{'browserName':'chrome'},规格:['test.js']};test.jsdescribe('test',function(){它(应该导航",功能(完成){browser.get('https://ww2.tracfone.com');element(by.linkText('MY ACCOUNT')).click();完毕();});};
找到了您在网页中看到的问题的根本原因.看来您的网站持续轮询$ timeout或$ http,Protractor将无限期等待并超时.
我已经监视了下面的http流量,发现您的应用程序频繁轮询,而Protractor只是在等待.检出下面的屏幕抓取.(时间轴中的绿色标记表示$ http呼叫--
有关为什么会出现此错误的更多详细信息,请参见此处
Interval.js :我不是这方面的专家,但是您可以探索更多这里
对于连续轮询的任何事物,都应使用$ interval(在Angular 1.2rc3中引入).
-
尝试使用不同的timeout配置,看看一段时间后您的应用程序轮询是否停止
allScriptsTimeout:120000,getPageTimeout:120000,jasmineNodeOpts:{defaultTimeoutInterval:120000}
We are trying to automate a publicly accessible website and click on one of the links, but the test fails with TimeOut Exception while locating the element as below:
From: Task: Protractor.waitForAngular() - Locator: By(link text, MY ACCOUNT) Sample conf and spec file below. Requesting help on how to solve this issue.
conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome'
},
specs: ['test.js']
};
test.js
describe('test', function() {
it('should navigate', function(done) {
browser.get('https://ww2.tracfone.com');
element(by.linkText('MY ACCOUNT')).click();
done();
});
};
Found the root cause for the issue you were seeing for your webPage. Looks like your site continuously polls $timeout or $http, Protractor will wait indefinitely and time out.
I have monitored the http traffic below and see that your app polls at frequent intervals and Protractor just waits. Checkout the screen grab below.(The green marks in the timeline indicating $http calls to - https://ww2.tracfone.com/cgi-bin/tealeaf.pl )
More details on why you are seeing this error is documented here. ok. Coming to the different solutions for this, there are multiple work-arounds for this. I will just talk in brief about the alternatives and leave it to you to choose the best one.
IgnoreSynchronization: Turn this flag -
browser.ignoreSynchronization
to false before thebrowser.get()
and continue with the test flow and set the flag to true again for other pages Check hereInterval.js : I am no expert on this but you can explore more here
You should use the $interval for anything that polls continuously (introduced in Angular 1.2rc3).
Try with different timeOut configurations and see if your app polling stops after some time
allScriptsTimeout: 120000, getPageTimeout: 120000, jasmineNodeOpts: { defaultTimeoutInterval: 120000 }
这篇关于AngularJs应用程序的量角器定位器超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!