Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23218

Download a PDF using Selenium in Python

$
0
0

I'm trying to download the following PDF from a browser's PDF viewer by clicking the download button.

image

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 timefrom selenium import webdriverfrom selenium.webdriver.chrome.service import Service as ChromeServicefrom webdriver_manager.chrome import ChromeDriverManagerfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitdownload_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()

Viewing all articles
Browse latest Browse all 23218

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>