What Xpath expression can I use to find all the anchor (just ‘a’) elements whose actual text (the innerHTML) is Logout.
something like
//a[@innerHTML='Logout']
Would that be correct?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it would be incorrect.
innerHTMLis a property, part of the object model, while XPath operates on tags and attributes. Unless youratag actually has an attribute namedinnerHTML, this wouldn’t work.If you want to compare the value of the tag itself, you can use the
.(dot) to refer to the tag:However, I must add, just in case you’re using jQuery: I’m not sure if it will work with jQuery. jQuery does not support XPath fully, only basic stuff.