开发者

Xpath and innerHTML

开发者 https://www.devze.com 2022-12-30 04:11 出处:网络
What Xpat开发者_开发百科h expression can I use to find all the anchor (just \'a\') elements whose actual text (the innerHTML) is Logout.

What Xpat开发者_开发百科h 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?


No, it would be incorrect. innerHTML is a property, part of the object model, while XPath operates on tags and attributes. Unless your a tag actually has an attribute named innerHTML, 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:

a[.='Logout']

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号