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

Testcafe Wait until an element has a specific text

用 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: object tested must be an array, a map, an object, a set, a string, or a weakset, but function given" 但我不知道为什么。

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

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

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