TestProject Forum
Powered by leading experts in the test automation community

Find element by attribute?

So selenium doesn’t have a method for finding elements by attribute name/value ?

Is there a way to locate elements by a given attribute ?

for example if I would want to get the email input element by the ‘value’ attribute

<input value="email"></input> <input value="password"></input>

You could find it with xpath locator:

WebElement input1 = driver.findElement(By.xpath("//div[contains(@value, 'email')]));