I’m trying to download the following PDF from a browser’s PDF viewer by clicking the download button.
I tried the following code using ID, CSS_SELECTOR, and XPATH locators, but it seems not to be working.
What could be the issue? Can someone help me with this?
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
download_url = "https://www.npci.org.in/PDF/nach/circular/2015-16/Circular-No.135.pdf"
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
driver.get(download_url)
WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#icon')))
driver.find_element(By.ID, '#icon').click()
time.sleep(5)
driver.quit()