from this link https://bancadatistatisticaoas.inail.it/analytics/saw.dll?Dashboard&PortalPath=%2Fshared%2FBDS%2F_portal%2FINF_Definiti_Industria_e_Servizi I need to click on “F Costruzioni” and then F 41 COSTRUZIONI ED EDIFICI. This is my code but it doesn’t work. What I’m doing wrong?
# Initialize the WebDriver
driver = webdriver.Chrome(options=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()
It looks like the x-path is incorrect. please try the following xpath.
//table/tbody/tr/td/a[text()='F COSTRUZIONI']
Can you please incude what error code/ issue is your code generating.
Also please do check have you included the required headers/librearies
Also check if the website you have choosen still has the same element names for your choosen elements (I couldn’t understand the meanings of those words so I have assumed that those are the correct names of the required elements)
I’m attaching a sample code which you can try out.
from datetime import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
chrome_options = Options() #add what ever options you want
driver = webdriver.Chrome(options=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)
wait.until(EC.element_to_be_clickable((By.XPATH, "//table/tbody/tr/td/a[text()='F COSTRUZIONI']
“))).click()
time.sleep(10)
finally:
driver.quit()
Shoaib Sadiq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.