TestProject Forum
Powered by leading experts in the test automation community

Find elements by text

Can I locate an element (p, h3, span, div) with given text e.g. “Hello World” ?

I’m not talking about FindElementByLinkText method, I’m referring to an element that contains said text.

It is possible with an XPath locator.

//div[contains(., 'Hello World')]

This will find any div that contains “Hello World”.