user3364652
user3364652

Reputation: 510

Selenium - how to find elements by attribute with any value in Java?

I know this way I can find element by attribute and value:

webDriver.findElements(By.xpath("//element[@someAttribute='someValue']"))

How can I find all elements that has the attribute someAttribute no matter what the value is?

Thanks

Upvotes: 4

Views: 9068

Answers (1)

Markus
Markus

Reputation: 3397

Just use //element[@someAttribute] for your XPath expression.

Upvotes: 7

Related Questions