testing - Testcafe 等到一个元素有一个特定的文本

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

用 TestCafe 上传图片后,服务器会做一些处理。而这次网站上的标签将带有“Inprogress”标签。服务器准备就绪后,它将更改为最新。但是,我想告诉 Testcafe 脚本等到标签不再是“Inporgress”。 为此我做了:

    const DeliveryStatus = {
        element: Selector('div.cl-asset-published').with({timeout: 70000}),
        delivered: 'Inprogress'
    };

在我的脚本中

await t
     .expect(DeliveryStatus.element).notContains(DeliveryStatus.delivered, { timeout: 70000 })

但这一步失败了。我收到的消息是“AssertionError:测试的对象必须是数组、映射、对象、集合、字符串或弱集,但函数给定”,但我不知道为什么。

有什么解决这个问题的建议吗?

最佳答案

您将返回元素而非字符串的元素选择器传递给 expect 函数。尝试使用元素的 innerText 属性,如下所示:

await t
 .expect(DeliveryStatus.element.innerText)
 .notContains(DeliveryStatus.delivered, { timeout: 70000 })

关于testing - Testcafe 等到一个元素有一个特定的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56356979/

相关文章:

python - 如何让 pytest 运行 doctests 以及正常的测试目录?

android - 无法使用 Appium 移动 Android SeekBar

javascript - TestCafe - 点击链接后等待页面加载

javascript - 这是什么错误 ERROR Cannot prepare tests due to an error.类型错误 : Cannot read property 'Date' of undefined?

angularjs - Protractor Jasmine适配能否正确等待protractor.promise.defer().promise?

testing - 如何在具有相同浏览器 session 的相同夹具下运行多个测试

testing - 检测不会失败的测试的自动化方法, checkin 以获得最小代码覆盖率?

unit-testing - 如何在不引入风险的情况下测试遗留应用程序(并采用测试驱动开发)?

scala - 在同一规范文件中测试 akka-http 和 akka actor 时,如何解决冲突的 actor 系统?

perl - 使用 Perl 进行测试自动化