Reputation: 3591
I am currently using Testcafe
for en-to-end
testing, and I needed to assert if a text is correctly displayed. the code is written as shown below:
await t
.expect(Selector('div:nth-child(5) > div > table:nth-child(3) > tbody > tr:nth-child(1)
td:nth-child(1)').filterVisible().innerText).contains('FOR LEASE')
.expect(Selector('div:nth-child(5) > div > table:nth-child(5) > tbody > tr:nth-child(1) >
td:nth-child(1)').filterVisible().innerText).contains('200 Granville Street')
but to my surprise, I got the error below on the console:
DEBUGGER PAUSE ON FAILED TEST:
AssertionError: expected 'FOR LEASE' to include 'FOR LEASE'
From the console error, the text on the element was the same as my assertion. Hence I am confused as to why this is failing. kindly help with some suggestions.
In addition, I first tried
.eql()
before reducing the strict equality by using.contains()
. however, I got the same error on both.
Upvotes: 0
Views: 618
Reputation: 3591
After thoroughly debugging this issue, I discovered that
when the document is edited, the website encodes
the string
(while converting it to PDF
) before saving. Hence, when I tried to assert the change after the text has been saved, It failed (although the words looked alike visually). This error was particularly due to the space encoding.
what got the job done was to assert sections of the string without spaces
Now the question is: In a future scenario like this, how can I normalize the encoded space before asserting, so I wouldn't always find an easy way out as I did above
Upvotes: 1