繁体   English   中英

执行 TestCafe 断言的正确方法是什么

[英]What is the correct way to perform TestCafe assertions

我基本上被困在岩石和坚硬的地方之间。 我正在使用 TestCafe 编写一些自动化脚本,我需要一些最佳实践方面的帮助。 基本上我想知道创建一个断言的最佳方法,该断言在执行之前等待一小段时间直到元素出现。

我目前的实现:

const setTimeout = 5000;

await t
    .expect(this.papernote.exists, { timeout: setTimeout })
    .ok('The trail is not visible');

当测试执行时,似乎超时没有得到遵守。 这意味着 TestCafe 将等待默认时间(我相信 3 秒)然后断言将失败

我希望你想增加选择器超时。 尝试使用此标志

--selector-timeout 500000

你也可以试试

--assertion-timeout 10000

或者你可以尝试等待元素,

await element.with({ visibilityCheck: true }).with({timeout: 10000});

https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html

如果需要为特定断言定义超时,请将选项对象传递给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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM