如何解决为什么在使用带有waitForAngularEnabledtrue的量角器运行e2e测试时出现错误
我正在使用量角器进行我的角度应用程序的e2e测试。对于登录页面,我设置了waitForAngularEnabled(false),然后将其设置为waitForAngularEnabled(true)。但是我的测试失败并显示以下错误:
Failed: script timeout
(Session info: chrome=85.0.4183.83)
(Driver info: chromedriver=85.0.4183.38 (9047dbc2c693f044042bbec5c91401c708c7c26a-refs/branch-heads/4183@{#779}),platform=Windows NT 10.0.18362 x86_64)
(Session info: chrome=85.0.4183.83)
(Driver info: chromedriver=85.0.4183.38 (9047dbc2c693f044042bbec5c91401c708c7c26a-refs/branch-heads/4183@{#779}),platform=Windows NT 10.0.18362 x86_64)
at Object.checkLegacyResponse (....node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (....node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (....node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: Protractor.waitForAngular() - Locator: By(css selector,body)
当我用google搜索它时,我发现很多帖子建议我应该关闭同步或将waitForAngularEnabled设置为false。但是后来我松开了这个功能。
有人知道如何解决此问题?
解决方法
由于帖子(https://christianliebel.com/2016/11/angular-2-protractor-timeout-heres-fix/),我发现它是由应用程序中使用的超时引起的。我用建议的解决方案替换了它们,现在它就像一个魅力。
为此,您可以搜索setInterval和setTimeout并将其替换为:
ngZone.runOutsideAngular(() => {
setInterval(() => {
ngZone.run(() => {
// async operation
});
},2500);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。