I have this HTML
<div >
<a href="" title="" data-original-title="">Validar</a>
<a href="" title="" data-original-title="">Copiar</a>
<a href="" title="" data-original-title="">Convertir en plantilla</a>
<a href="" title="" data-original-title="">Eliminar</a>
</div>
I'm trying to select the Validar link.
driver.find_element(By.LINK_TEXT, "Validar")
but selenium can't find it.
However if I do this:
for link in links:
print(link.text)
I get this:
VALIDAR
COPIAR
CONVERTIR EN PLANTILLA
ELIMINAR
I've checked and the class .butAction
has a text-transform: uppercase;
css.
I swear this 100% used to work just yesterday, why is it not working now? What am I missing?
CodePudding user response:
Instead of By.LINK_TEXT
it's better to use By.XPATH
.
In this case you only need to know what text appears in the web element on the page, not how it presented to user.
This should work:
driver.find_element(By.XPATH, "//a[@class='butAction'][text()='Validar']")