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:
//E[text() = 'Displayed text']
//E[contains(text(), 'Displayed text')]
Examine your knowledge and play the ‘locator game‘.