[Python] Selenium NoSuchElementError on Handelsregister.de after clicking "Normale Suche"

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    Title: Selenium NoSuchElementError in headless Firefox on handelsregister.de after clicking "Normale Suche"

    Body: I'm using Selenium (Firefox in headless mode) to automate a document search on https://www.handelsregister.de/rp_web/welcome.xhtml.

    The script loads the page and clicks "Normale Suche" successfully, but fails when trying to fill the form with the following error:

    NoSuchElementError: Unable to locate element:
    /html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/form/div[3]/div[2]/textarea


    I confirmed the XPath is valid using browser dev tools. The same code works in non-headless mode.

    What I tried:

    • WebDriverWait for page and form
    • Confirmed XPath manually
    • Headless vs non-headless tests (works in visible mode only)

    Expected behavior:** After clicking "Normale Suche", the input fields should appear and be fillable, but in headless mode Selenium fails to find them.

    Code snippet:

    driver.get("https://www.handelsregister.de/rp_web/welcome.xhtml")
    wait.until(EC.presence_of_element_located((By.TAG_NAME, "body")))
    driver.find_element(By.ID, "naviForm:normaleSucheLink").click()

    wait.until(EC.presence_of_element_located((By.ID, "mainForm")))
    driver.find_element(By.XPATH, "/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/form/div[3]/div[2]/textarea").send_keys("WGO Grundstücks GmbH")

    Continue reading...

Compartilhe esta Página