Reputation: 435
I just started using testcafe, so far I found the documentation helpful to do my test and automate my E2E.
I want to assert if a value exists in a td like this:
async checkBankAccount(accountNumber, currencyCode){
const formatedAccount = formatBankAccount(accountNumber, currencyCode);
console.log(formatedAccount);
await t
.expect(Selector('td').withText(formatedAccount).innerText).eql(formatBankAccount);
}
I am having the following error:
An assertion method is not specified.
I want to assert if it exists a td in my HTML that contains the text from formatedAccount.
Thanks
Upvotes: 3
Views: 986
Reputation: 1775
You may use this to assert if your td contains the text coming from formatedAccount as follows:
test ('test..',
async t => {
const field = Selector('td');
const text = field.textContent;
await t
.expect(text).contains(formatedAccount)
});
Upvotes: 0
Reputation: 5227
Use the exists property to check if an element is available.
async checkBankAccount(accountNumber, currencyCode){
const formatedAccount = formatBankAccount(accountNumber, currencyCode);
console.log(formatedAccount);
await t
.expect(Selector('td').withText(formatedAccount).exists).ok();
}
Upvotes: 6