[英]What is the correct way to perform TestCafe assertions
I am basically stuck between a rock and sort of a hard place.我基本上被困在岩石和坚硬的地方之间。 I'm writing some automation scripts using TestCafe and I need some help on best practices.
我正在使用 TestCafe 编写一些自动化脚本,我需要一些最佳实践方面的帮助。 Basically I would like to know the best way to create an assertion that waits a brief period of time until an element appears before executing.
基本上我想知道创建一个断言的最佳方法,该断言在执行之前等待一小段时间直到元素出现。
My Current implementation:我目前的实现:
const setTimeout = 5000;
await t
.expect(this.papernote.exists, { timeout: setTimeout })
.ok('The trail is not visible');
When the test executes, it seems like the timeout does not get respected.当测试执行时,似乎超时没有得到遵守。 Meaning TestCafe will wait the default time (3 seconds I believe) then the assertion will fail
这意味着 TestCafe 将等待默认时间(我相信 3 秒)然后断言将失败
I hope you want to increase the selector timeout.我希望你想增加选择器超时。 Try using this flag
尝试使用此标志
--selector-timeout 500000
and you can also try你也可以试试
--assertion-timeout 10000
or you can try waiting for the element,或者你可以尝试等待元素,
await element.with({ visibilityCheck: true }).with({timeout: 10000});
https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html
If you need to define a timeout for a particular assertion, pass the options object to the ok
method:如果需要为特定断言定义超时,请将选项对象传递给
ok
方法:
await t
.expect(this.papernote.exists)
.ok('The trail is not visible', { timeout: setTimeout });
See the documentation article for details: https://devexpress.github.io/testcafe/documentation/test-api/assertions/assertion-api.html#ok详见文档文章: https : //devexpress.github.io/testcafe/documentation/test-api/assertions/assertion-api.html#ok
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.