【发布时间】:2019-08-09 22:56:16
【问题描述】:
我正在尝试使用Protractor 为我的Angular 应用程序编写一些e2e 测试。
我有一个简单的 html 按钮,上面有 id=my-btn,我想点击它,使用:
$('#my-btn').click();
很遗憾,我收到以下错误:
失败:脚本超时:11 秒内未收到结果
来自:任务:Protractor.waitForAngular() - 定位器:By(css selector, #my-btn)
(Session info: chrome=73.0.3683.75) (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.3 x86_64)
如果在点击之前我设置:
browser.waitForAngularEnabled(false);
那么我没有收到任何错误。问题是这样做意味着:
* If set to false, Protractor will not wait for Angular $http and $timeout * tasks to complete before interacting with the browser. This can cause * flaky tests, but should be used if, for instance, your app continuously * polls an API with $timeout.
所以我想知道是什么导致waitForAngular 操作超时。
有没有办法检查 http 或 timeout 仍然挂起?
我想调试我的应用程序以了解发生了什么。
【问题讨论】:
-
添加您的测试脚本和 html 以更好地了解问题。
标签: angular typescript protractor e2e-testing angular-e2e