Xpath doesn't work for text() for paragraph(
) content but works fine for div. Example:
<div>
<p>
123
123
some_text
</p>
<div>
Xpath:
//*[contains(text(), 'some_text')]
Result:
Nothing has been found
Working example:
<div>
123
123
some_text
<div>
Result:
The element div is founded by xpath
or with changed xpath:
<div>
<p>
123
123
some_text
</p>
<div>
xpath:
//*[contains(., 'some_text')]
Result:
The element p is founded by the changed xpath
Browsers:
The functions contains
expects as it's first argument a single string.
I suppose in your case there can be several text-nodes inside a element. Therefore it fails.
You have two options:
Use the "." notation , that will join all text in a element to one string, like this:
//*[contains(., 'some_text')]
Or use this Xpath:
//*[text()[contains(., 'some_text')]]