Finding a span with specific content using xpath Finding a span with specific content using xpath selenium selenium

Finding a span with specific content using xpath


You are missing // at the beginning of the XPath.

  • One slash would mean "a span that is a child of a root node".
  • Two slashes mean "find me any span with that text".

//span[text()='thisisatest']


You could try this:

span[span= "thisisatest"] 

All <span> elements that contain at least one <span> element child with the value thisisatest.

Hope it helps!