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 })
推荐阅读
- php - Mpdf Kartik上的绝对位置不起作用
- java - Gradle 说我的 java 安装在错误的位置,尽管它找到了正确的文件夹
- docker - docker-compose 设置环境变量不起作用
- c# - xamarin 形式:绑定对象为空
- c# - 将玩家旋转更改为相机旋转
- javascript - 如果 iframe 存在,Javascript onclick,将其删除并创建新的 iframe?
- python - Python从正面展望中获取分组值
- python - 用python说话时将语音转换为文本
- wordpress - 打开我的网站时如何加载我自己的网站文件而不是 WordPress 网站
- r - 垂直对齐单元格以位于底部的柔性表