使用selenium在python中打开chrome中的链接

问题描述 投票:0回答:1

从此链接https://bancadatistatisticaoas.inail.it/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FBDS%2F_portal%2FINF_Definiti_Industria_e_Servizi我需要单击“F Costruzioni”,然后单击F 41 COSTRUZIONI ED EDIFICI。这是我的代码,但它不起作用。我做错了什么?

# Initialize the WebDriver

driver = webdriver.Chrome(选项=chrome_options) driver.maximize_window()

try:
    # Navigate to the page
    driver.get(
        "https://bancadatistatisticaoas.inail.it/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FBDS%2F_portal%2FINF_Definiti_Industria_e_Servizi"
    )
    wait = WebDriverWait(driver, 90)

    # f_costruzioni_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='F COSTRUZIONI']")))
    # f_costruzioni_button.click()

    wait.until(EC.element_to_be_clickable((By.XPATH, "//table/tbody/tr/td[text()='F COSTRUZIONI']"))).click()

    # This is a simple sleep; for a more robust solution, check the download directory for a new file
    import time

    time.sleep(10)


finally:
    # Clean up by closing the browser
    driver.quit()
python selenium-webdriver
1个回答
0
投票

看起来 x 路径不正确。请尝试以下xpath。

//table/tbody/tr/td/a[text()='F COSTRUZIONI']
© www.soinside.com 2019 - 2024. All rights reserved.