Reputation: 501
I have the following two buttons on a form I need to test:
<div class="ef-buttons">
<button value="next" name="action" type="submit">
Continue
</button>
<button id="modify_button" value="previous" name="action" type="submit">
Go Back
</button>
</div>
I want to click the Continue Button, for which I wrote the next piece of code:
By chain = new ByChained(By.className("ef-buttons"),(By.xpath("//*[@value='next']")));
driver.findElement(chain).click();
However, everytime I get the message Cannot locate an element. What am I doing wrong?
Upvotes: 0
Views: 1027
Reputation: 29032
I'd recommend consolidating your By
, and just using CSS. It's faster and easier. This is how you'd select your element:
driver.findElement(By.cssSelector("div.ef-buttons button[name='action']")).click();
FYI, it's better practice to use the name
attribute over value
since name
is more unique.
Upvotes: 2