我有时会使用“预期条件”功能量角器 1.7 中引入。
Use case:
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(header.displayName), 10000);
where header
是一个页面对象。
If header.displayName
如果 10 秒内不可见,则会抛出错误:
[firefox #4] 2) Describe description here
[firefox #4] Message:
[firefox #4] Error: Wait timed out after 10082ms
[firefox #4] Stacktrace:
[firefox #4] Error: Wait timed out after 10082ms
[firefox #4] ==== async task ====
[firefox #4] at [object Object].<anonymous> (/Path/to/project/test/e2e/my.spec.js:38:17)
这不太可读,需要一些时间来理解和一些研究。
问题:
是否可以自定义这种等待超时错误?
仅供参考,我们可以提供定制expect
失败消息如下所述:
我相信browser.wait()
采用 3 个参数:条件、可选超时和可选描述消息。 (我很确定这是文档:http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.wait,但我很难验证 WebDriver 是否显示为browser
在量角器中)。所以你应该能够做到:
var EC = protractor.ExpectedConditions;
var timeoutMS = 10 * 1000;
var timeoutMsg = "Waiting for header displayName";
browser.wait(EC.visibilityOf(header.displayName), timeoutMS, timeoutMsg);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)