How to handle css entities in locators and text

Praveen David Mathew
2 min readJan 23, 2023

What are entities in web ?

An HTML entity is a piece of text (“string”) that begins with an ampersand (&) and ends with a semicolon (;). Entities are frequently used to display reserved characters (which would otherwise be interpreted as HTML code), and invisible characters (like non-breaking spaces). You can also use them in place of other characters that are difficult to type with a standard keyboard.

some examples would be :

Problem…..:

Imagine you have a element like:

<div data="Praveen&nbsp;Mathew">Praveen&nbsp;Mathew</div>

how do we detect this element using data attribute and verify the text content ?

  1. can we use the css locator ? [data=”Praveen&nbsp;Mathew”] ?
  2. can we use the css locator ? [data=”Praveen Mathew”] ?

--

--

Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker