Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 682
user3364652 Avatar asked Mar 10 '23 16:03

user3364652


1 Answers

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

like image 103
Markus Avatar answered Apr 25 '23 19:04

Markus