Locating Web Elements by text matching

1 vote

Although it is not the best solution, sometimes we need to locate elements based on the text displayed. It’s not the best solution if you have to test a multilingual website, because the text is different in every language.

Using XPath we have the following options:

Text equals

//E[text() = 'Displayed text']

Text contains

//E[contains(text(), 'Displayed text')]


Examine your knowledge and play the ‘locator game‘.

Please follow and like us:
Locating Web Elements by label matching
Locating Web Elements by attribute/wildcard matching