【问题标题】:Testcafe Wait until an element has a specific textTestcafe 等到一个元素有特定的文本
【发布时间】:2019-05-29 09:11:52
【问题描述】:

使用 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:被测对象必须是数组、映射、对象、集合、字符串或弱集,但给定了函数”,但我不知道为什么。

有解决此问题的建议吗?

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-11-16
      • 1970-01-01
      • 2019-05-23
      • 1970-01-01
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多