Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath for all elements with any attribute with specific value?

I am using Selenium to identify any HTML element that may have a specified value in any of its attributes. I was hoping that there would be some way in XPath to do this, but I haven't been able to find any answers yet.

like image 647
Golden Griffin Avatar asked Mar 10 '16 21:03

Golden Griffin


People also ask

What is XPath by attribute?

Definition of XPath attribute. For finding an XPath node in an XML document, use the XPath Attribute expression location path. We can use XPath to generate attribute expressions to locate nodes in an XML document.


1 Answers

First, you have to transform HTML into xhtml if you want to apply xpath selections on it.

The xpath for selecting an (x)html element having a specified value in one of its attributes is:

//*[@*="specified value"]
like image 119
Pierre François Avatar answered Oct 19 '22 22:10

Pierre François