问题
I am trying to select the 3rd button using the css class "btnProceed"
<input type="button" class="btnProceed" value=" " onclick="SecuritySubmit(false,'https://somewebsite.com/key=xxyyzz');return false;">
My code is as follows:
WebElement query_enquirymode = driver.findElement(By.className("btnProceed"));
query_enquirymode.click();
I can only select the 1st element using "btnProceed"
Is there a way to select the 3rd button?
回答1:
Like this:
List<WebElement> buttons = driver.findElements(By.className("btnProceed"));
WebElement query_enquirymode = buttons.get(2);
query_enquirymode.click();
来源:https://stackoverflow.com/questions/14044075/selenium-how-to-select-nth-button-using-the-same-class-name