Find elements by text

  • 2 Replies
  • 1172 Views
Find elements by text
« on: March 23, 2016, 10:56:48 am »
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.

*

Oren

  • **
  • 59
Re: Find elements by text
« Reply #1 on: March 23, 2016, 16:52:18 pm »
It is possible with an XPath locator.

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

This will find any div that contains "Hello World".

Re: Find elements by text
« Reply #2 on: April 22, 2016, 13:58:25 pm »
//div[text()="Hello World"]

 

Sitemap 1 2 3 4 5 6 7 8