Miquel Torres Miquel Torres - 5 months ago 13
Python Question

Click on second button (identical buttons) Selenium python

I have 2 buttons with the same value and class, they are identical.

<input class="button" value="Ir" type="submit">


I want to click the second one, that it is in
<div class="smallfont">


How can i do that with python Selenium? Thanks ;D

INPUT CODE <------- IMAGE

Answer

You can grab references to both elements and just click the second one.

buttons = driver.find_elements_by_css_selector("input.button");
buttons[1].click()