How can I select an element that has exactly the same name as another element with selenium?


My university’s system for checking my kardex is old and poorly constructed. That is why it has fragmented the html, elements with the same name, etc.

I want to click the SELECCIONAR button, but there are two.

I want to do is choose an element because two elements with the same name but that do two different things.

How can I select for example button 2 that has the plain text AC?


You can differentiate based on text like EG and AC

xpath for AC- SELECCIONAR button would be :-


you can write the same for EG.

You can click on it like below (in case you want to)

wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.XPATH, "//td[text()='AC']/following-sibling::td/input"))).click()

Imports :

from import WebDriverWait
from import By
from import expected_conditions as EC

Answered By – cruisepandey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published