0
Hello, I started to study Python a little bit and I’m doing some tests with Lenium and I came across an error in which I am not able to solve. I’m trying to click a button on a website but the following error appears:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/div[2]/div[1]/div[1]/div/a"}
(Session info: chrome=87.0.4280.88)
Follows code below:
from selenium import webdriver
chromedriver = "chromedriver"
driver = webdriver.Chrome(chromedriver)
url = '/'
driver.get(url)
driver.find_element_by_xpath("/html/body/div[3]/div[2]/div[1]/div[1]/div/a").click()
the problem is the xpath, not the click. How did you get this xpath? Are you sure it’s right?
– Lucas
I copied it straight from the inspection.
– Gustavo Gonçalves
Since Lucas said the problem is not the click but the xpath. Could you print out which element of the page you’re trying to get the xpath? Hug!
– lmonferrari
best use
find_element_by_id
. Is it possible in this case?– Paulo Marques