从此链接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()
看起来 x 路径不正确。请尝试以下xpath。
//table/tbody/tr/td/a[text()='F COSTRUZIONI']