[英]Why I get an error when I run an e2e test using protractor with waitForAngularEnabled(true)
我正在使用量角器進行 e2e 測試我的 angular 應用程序。 對於登錄頁面,我設置了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)
當我用谷歌搜索它時,我發現很多帖子建議我應該關閉同步或將 waitForAngularEnabled 設置為 false。 但后來我失去了這個功能。
有人知道如何解決這個問題嗎?
感謝這篇文章( https://christianliebel.com/2016/11/angular-2-protractor-timeout-heres-fix/ ),我發現它是由應用程序中使用的超時引起的。 我用建議的解決方案替換了它們,現在它就像一個魅力。
因此,為此,您可以搜索 setInterval 和 setTimeout 並將它們替換為:
ngZone.runOutsideAngular(() => {
setInterval(() => {
ngZone.run(() => {
// async operation
});
}, 2500);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.