1

I am trying to download pdf files from website using selenium but i am able to open file but its not auto downloadable using code.

Code:

chrome_profile = webdriver.ChromeOptions()
profile = {"download.default_directory": "C:\Users\Downloads",
   "download.prompt_for_download": False,
   "download.directory_upgrade": True,
   "plugins.plugins_disabled": ["Chrome PDF Viewer"]}
chrome_profile.add_experimental_option("prefs", profile)

Please suggest. Thank you in advance

2
  • which browser are you using ? Commented Jun 4, 2018 at 10:52
  • @Prany, google Chrome Commented Jun 4, 2018 at 10:53

2 Answers 2

6

By doing this problem will be solved:

prefs = {"plugins.always_open_pdf_externally": True}
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "\path\chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
Sign up to request clarification or add additional context in comments.

Comments

0

Put this in your profile section of the code, it is disabling chrome PDF viewer and will trigger auto download

"plugins.plugins_disabled": ["Chrome PDF Viewer"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.