Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 执行TestCafe断言的正确方法是什么_Javascript_Automated Tests_E2e Testing_Testcafe_Browser Automation - Fatal编程技术网

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

Javascript 执行TestCafe断言的正确方法是什么,javascript,automated-tests,e2e-testing,testcafe,browser-automation,Javascript,Automated Tests,E2e Testing,Testcafe,Browser Automation,我基本上被困在一块岩石和一个有点硬的地方之间。我正在使用TestCafe编写一些自动化脚本,我需要一些关于最佳实践的帮助。基本上,我想知道创建断言的最佳方法,该断言将在执行之前等待一小段时间,直到元素出现 我目前的执行情况: const setTimeout=5000; 等待 .expect(this.papernote.exists,{timeout:setTimeout}) .ok(“轨迹不可见”); 当测试执行时,超时似乎没有得到尊重。这意味着TestCafe将等待默认时间(我相信是3秒

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

我目前的执行情况:

const setTimeout=5000;
等待
.expect(this.papernote.exists,{timeout:setTimeout})
.ok(“轨迹不可见”);

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

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

--selector-timeout 500000
你也可以试试

--assertion-timeout 10000
或者您可以尝试等待元素

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

如果需要为特定断言定义超时,请将options对象传递给
ok
方法:

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

有关详细信息,请参阅文档文章:

Sweeet。谢谢你的建议。这似乎效果更好。