0
driver.find_element(By.XPATH, "/html/body/div/div[2]/main/div[2]/div/section/div[2]/div/form/input")

gives the following message>

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div/div[2]/main/div[2]/div/section/div[2]/div/form/

The website (URL) is:

https://sede.administracionespublicas.gob.es/pagina/index/directorio/icpplus

4
  • Please share your url or relevant html?
    – KunduK
    Oct 10, 2022 at 13:01
  • I shared the url. Many thanks @KunduK Oct 10, 2022 at 13:07
  • Where is this element you want to locate ?
    – Akzy
    Oct 10, 2022 at 13:23
  • Acceder al Procedimiento button. Oct 10, 2022 at 13:31

2 Answers 2

1

It seems that the element you wanted to click is not clickable you can use the same locator with below code or use the code as is.

from selenium.webdriver.common.by
import By
from selenium.webdriver.support.ui
import WebDriverWait
from selenium.webdriver.support
import expected_conditions as EC

element = WebDriverWait(driver, 20).until(
   EC.element_to_be_clickable((By.ID, "submit")))  # if you want to click on the button Acceder al Procedimiento

element.click();
0
0

Use WebDriverWait() and wait for element to be clickable and following xpath to click on the element.

absolute xpath is always fragile, you should use relative xpath to identify the element. You can learn form here Xpath cheatsheet

WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, "//input[@value='Acceder al Procedimiento']"))).click()

Import below libarries

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
2
  • 1
    Works like a charm. But to understand how did you get this "//input[@value='Acceder al Procedimiento']" ? Many thanks that is amazing. So each click line should include WebDriverWait because it takes time. Oct 10, 2022 at 13:53
  • @user19562955 : I have given a reference link. you can check the link.
    – KunduK
    Oct 10, 2022 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.