I have the below sample code that clicks on all the download buttons on a page and downloads xml files.
If I add it at the end, it immediately closes the download and does not download all the files.
import os
import urllib.parse
import requests
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from
selenium.webdriver.common.by import By
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=options)
driver.get("
https://www.rna.gov.it/RegistroNazionaleTrasparenza/faces/pages/OpenDataMisura.jspx")
driver.implicitly_wait(10)
links = driver.find_elements(By.XPATH, "(//a[span[contains(text(),'Download') and @class='xfv']])")
for link in links:
link. Click()