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:
Follow by Email
Facebook
Google+
http://www.seleniuminaction.com/locating-web-elements-by-text-matching/
Twitter
LinkedIn
Locating Web Elements by label matching
Locating Web Elements by attribute/wildcard matching

Leave a Reply

Your email address will not be published. Required fields are marked *