0

How to download PDF file using Selenium on Python

I have tried

options = webdriver.ChromeOptions()
            prefs = {
                "download.prompt_for_download": False, # To auto download the file
                "plugins.always_open_pdf_externally": True # It will not show PDF directly in chrome
                    }
            options.add_experimental_option("prefs", prefs)

But it does not work for me, the pdf file on the bottom tab is "Failed - Download Error" I'm using version:

  • Python: 3.8.12
  • Selenium: 4.1.0
  • Chromedriver: 97.0.4692 google-chrome (using webdriver-manager for auto detecting Chrome version)

Please help!

ShanN
  • 831
  • 1
  • 9
  • 20
  • This might of help to you [SO Archive Link](https://stackoverflow.com/questions/43149534/selenium-webdriver-how-to-download-a-pdf-file-with-python) – Anand Gautam Jan 26 '22 at 04:32
  • Please share all your relevant code, not only driver options settings. Including the link to the page you are working on – Prophet Jan 26 '22 at 07:38

0 Answers0