1

I have the next code that asserts if I can find a bank account in a cell. I found out that it's not working when the text in the cell contains a space after the text.

    this.bankAccounts = Selector('td[data-cy="listAccountNumber"]');

async checkBankAccount(accountNumber, currencyCode, name){
    const formatedAccount = formatBankAccount(accountNumber, currencyCode);
    const bankCell = Selector(this.bankAccounts).withText(formatedAccount);

    await t
        .expect(bankCell.exists).ok("Should create: " + name +
            " bank. Could not find bank: " + formatedAccount);
}

For example, the previous method won't find the next cell if given accountNumber "CY25 7121 9716 3791 8645 3263 6242"

<td data-cy="listAccountNumber">CY25 7121 9716 3791 8645 3263 6242 </td>

But it will find it if my cell was like:

<td data-cy="listAccountNumber">CY25 7121 9716 3791 8645 3263 6242</td>
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Patrick Vibild
  • 405
  • 1
  • 3
  • 16
  • The [withText](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors/functional-style-selectors.html#withtext) method filters elements, which **contain** the specified string. In your case, the space at the end of the cell text should not lead to the behavior you described. Your code and html snippets work correctly on my side. Could you please clarify how you format the account number and whether the `` element contains the `formatedAccount`? – Dmitry Ostashev Aug 15 '19 at 14:21

0 Answers0