[Python] Selenium NoSuchElementError on Handelsregister.de: company result link not found...

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

  1. Stack

    Stack Membro Participativo

    After filling out the company search form and clicking the "Suchen" button, Selenium throws a NoSuchElementException when trying to click the first company name in the result list.

    Key reason: In headless mode or for some companies, the result table (#resultList) either:


    • doesn't load,


    • is empty,


    • or the page returns a message like “keine Einträge” (no entries).

    Solution: Use a WebDriverWait with a lambda that waits for either the results or a known “no entry” state. Then, safely check if clickable rows exist before attempting .click().

    Fix Code Snippet:

    wait.until(
    lambda d: d.find_elements(By.XPATH, "//table[@id='resultList']//tr[1]/td[2]/a") or
    "keine Einträge" in d.page_source
    )
    result_links = driver.find_elements(By.XPATH, "//table[@id='resultList']//tr[1]/td[2]/a")
    if result_links:
    result_links[0].click()
    else:
    logging.warning("⚠️ No results found for this search.")
    return

    Continue reading...

Compartilhe esta Página