【问题标题】:What is the correct way to perform TestCafe assertions执行 TestCafe 断言的正确方法是什么
【发布时间】:2020-06-28 02:03:26
【问题描述】:

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

我当前的实现:

const setTimeout = 5000;

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

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

【问题讨论】:

    标签: javascript automated-tests e2e-testing testcafe browser-automation


    【解决方案1】:

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

    【讨论】:

    • 甜蜜。谢谢你的建议。这似乎工作得更好。
    【解决方案2】:

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

    --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

    【讨论】:

      猜你喜欢
      • 2018-12-31
      • 2023-03-07
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-01
      相关资源
      最近更新 更多