Reputation: 543
I have the below piece of HTML.
HTML Code:
<a id="pINumber" href="csf.ajax?et=p.preparationinsurance">PASS170XX</a>
XPATH to identify the above element
//*[@id="pINumber"]
I'm trying to build an XPATH which can validate the Text 'PASS' is always present as Text in the beginning . What would be the XPATH in such cases.
After few searches about the XPATH, i could see that "substring-after"
can be used to do this. But couldn't prepare the right XPATH. Any help to build an XPATH for the above HTML with a text 'PASS' as part of verification that would be appreciated.
Upvotes: 0
Views: 1198
Reputation: 29042
Use this XPath:
starts-with(a/text(),'PASS')
It checks if the text()
of the link a
does start with the char-sequence PASS
. In your case this evaluates to true
.
And in a whole expression this can be
//a[starts-with(text(),'PASS')]
Upvotes: 1