我基本上被困在一块岩石和一个困难的地方之间。我正在使用TestCafe编写一些自动化脚本,并且需要一些有关最佳做法的帮助。基本上,我想知道创建断言的最佳方法,该断言要等待一小段时间,直到某个元素出现后再执行。
我当前的实现:
const setTimeout = 5000;
await t
.expect(this.papernote.exists, { timeout: setTimeout })
.ok('The trail is not visible');
当执行测试时,似乎没有遵守超时。这意味着TestCafe将等待默认时间(我相信3秒),然后声明将失败
最佳答案
如果需要为特定的断言定义超时,请将options对象传递给ok
方法:
await t
.expect(this.papernote.exists)
.ok('The trail is not visible', { timeout: setTimeout });
有关详细信息,请参见文档文章:https://devexpress.github.io/testcafe/documentation/test-api/assertions/assertion-api.html#ok