You may have a situation where you are getting a value from a table cell for example that renders like:
But in the DOM is:
If you then were checking the textContent of such a cell to compare if it is equal to something:
That will not work, because the string will have the 's corresponding character code of 160, so you need to santize the value before comparing:
Now the string comparison will work.
Code:
Hello World
But in the DOM is:
HTML:
<td>Hello World</td>
If you then were checking the textContent of such a cell to compare if it is equal to something:
Typescript:
if (locator.textContent() === 'Hello World') {
// do something
}
That will not work, because the string will have the 's corresponding character code of 160, so you need to santize the value before comparing:
Typescript:
let cell = (await headerCells.nth(i).textContent());
cell = cell.trim().toLowerCase().replace(/\u00a0/g, ' ')
Now the string comparison will work.
Last edited: