How to click on links with Selenium Python

Asked

Viewed 2,254 times

0

I have this tag <a href="!!!!!!">carro</a> I use the following code do = driver.find_element_by_link_text('carro') do.click()

I cannot access, returns the following error: selenium.common.exceptions.NoSuchElementException: Message: Unable to find element with xpath == carro

Anyone can help?

1 answer

1


You can click through the Xpath of the element. For this, just follow the template:

Taking the xpath of an element:

To catch the xpath, using the Google Chorme, just click with the right click on the widget -> Inspect -> Right click on illuminated part -> Copy -> Copy Xpath

inserir a descrição da imagem aqui

Then, to click, use the code below:

driver.find_element_by_xpath('//*[@id="tsf"]/div[2]/div/div[3]/center/input[2]').click()

Where //*[@id="tsf"]/div[2]/div/div[3]/center/input[2] is the Xpath of the element in your clipboard.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.