Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 626
Miquel Torres Avatar asked May 29 '26 19:05

Miquel Torres


1 Answers

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

buttons = driver.find_elements_by_css_selector("input.button");
buttons[2].click()
like image 146
JeffC Avatar answered Jun 01 '26 09:06

JeffC