I'm new to Selenium. Below is my code.
<input type="submit" id="button" value="Edit"/>
I have 3 buttons with the same type, id and value. How do I click on each of the buttons? Can anyone help me with the XPath?
I resolved such problem in the following way:
String cssSelectorOfSameElements="input[type='submit'][id='button']";
List<WebElement> a=driver.findElements(By.cssSelector(cssSelectorOfSameElements)) ;
a.get(0).click();
//a.get(1).click();
//a.get(2).click();
depends upon what button you need to click on. Hope this works for you.
use index based xpath like //input[1] and //input[2] and so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With