简体   繁体   English

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

[英]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.

相关问题 在 testcafe 中对“.1”关闭的数字执行断言的最佳方法是什么 - What is the best way to perform an assertion for numbers that are off by ".1" in testcafe 使用JavaScript对DOM对象执行算术运算的正确方法是什么? - What is the correct way to use JavaScript to perform arithmetic on a DOM object? TestCafe - 选择器/断言可以并行运行吗? - TestCafe - Can selectors / assertions be run in parallel? 从 Firebase 检索数据、对其执行计算并在 React(挂钩)中显示它的正确方法是什么? - What is the correct way to retrieve data from Firebase, perform computations on it, and display it in React (hooks)? 什么是正确的方法/可以链接两个AngularJs服务调用,然后对返回的数据执行功能? - What is the correct way/can you chain two AngularJs service calls and then perform a function with the returned data? TestCafe - 断言不起作用(测试的对象必须是数组等) - TestCafe - assertions not working (object tested must be an array etc.) 求和循环的正确方法是什么 - what is the correct way to sum loop 捕获错误的正确方法是什么? - What is the correct way of catching an error? 传递回调的正确方法是什么? - What is the correct way of passing a callback? 在jquery中使用“ this”的正确方法是什么? - What is the correct way to use “this” in jquery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM