我刚开始使用 testcafe,到目前为止,我发现文档有助于我进行测试和自动化 E2E。
我想像这样断言 td 中是否存在一个值:
async checkBankAccount(accountNumber, currencyCode){
const formatedAccount = formatBankAccount(accountNumber, currencyCode);
console.log(formatedAccount);
await t
.expect(Selector('td').withText(formatedAccount).innerText).eql(formatBankAccount);
}
我有以下错误:
An assertion method is not specified.
我想断言它是否存在于我的 HTML 中,其中包含来自 formatedAccount 的文本。
谢谢
最佳答案
使用 exists检查元素是否可用的属性。
async checkBankAccount(accountNumber, currencyCode){
const formatedAccount = formatBankAccount(accountNumber, currencyCode);
console.log(formatedAccount);
await t
.expect(Selector('td').withText(formatedAccount).exists).ok();
}
关于javascript - 断言 testcafe 中是否存在带有特定文本的 td DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57492313/