【问题标题】:Is there a way to chain an assertion in testcafe?有没有办法在 testcafe 中链接断言?
【发布时间】:2019-04-10 15:50:17
【问题描述】:

我有一个场景,根据之前的条件,结果可能是“这个”或“那个”。

例如,如果我希望 .contains 断言查找 foobar,我将如何编写期望?

await t.expect('foo bar').contains('bar')

【问题讨论】:

  • 您可以使用await t.expect('foo bar').contains('bar') 代码检查字符串的“包含”条件。如果您想检查其他数据类型(例如 DOM 节点)的“包含”条件,那么最好选择不同的方式。您能否提供有关您的方案的更多详细信息?
  • 我有一个场景,当用户点击提交按钮时,结果可能是“A”或“B”。
  • 你可以在断言中使用正则表达式devexpress.github.io/testcafe/documentation/test-api/assertions/…await t.expect('foo').match(/foo|bar/);

标签: automated-tests e2e-testing assertion web-testing testcafe


【解决方案1】:

另一种方法:

if (await Selector('div').withText('testee@tester.com').exists)
    {
        console.log("PASS")
    }
else if (await Selector('div').withText('testeetwo@tester.com').exists)
    {
        console.log("PASS")
    }
else
    {
        console.log("FAIL")
    }

【讨论】:

    猜你喜欢
    • 2017-08-21
    • 1970-01-01
    • 2017-01-11
    • 2017-12-25
    • 2013-11-21
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多