断言 testcafe 中是否存在包含特定文本的 td DOM

Pat*_*ild 3 javascript testing dom assertion testcafe

我刚刚开始使用 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);
     }
Run Code Online (Sandbox Code Playgroud)

我遇到以下错误:

未指定断言方法。

我想断言我的 HTML 中是否存在包含 formatedAccount 文本的 td。

谢谢

mlo*_*sev 6

\xc2\xa0使用\xc2\xa0存在\xc2\xa0属性来检查元素是否可用。

\n\n
async checkBankAccount(accountNumber, currencyCode){\n    const formatedAccount = formatBankAccount(accountNumber, currencyCode);\n    console.log(formatedAccount);\n\n    await t\n         .expect(Selector(\'td\').withText(formatedAccount).exists).ok();\n}\n
Run Code Online (Sandbox Code Playgroud)\n