1

Script.py

profile = {"plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF 
Viewer"}], # Disable Chrome's PDF Viewer
           "download.default_directory": source_dir, 
"download.extensions_to_open": "applications/pdf"}
ChromeOptions.add_argument('--headless')
chromeOptions.add_argument('--disable-gpu')
chromeOptions.add_argument('--kiosk-printing')
chromeOptions.add_argument('--test-type')
chromeOptions.add_argument("--disable-infobars")
a835file = 
 driver.find_element_by_xpath('/html/body/a')
a835file.click()

Issue

The script runs fine and i can see the file is found but it doesn't download it.

  • I used to achieve this in java using robot class by passing ctrl+s and using the same we can pass download directory as well. – srshma Jun 12 '18 at 11:50
  • but as the script runs headless i dont think ctrl+s would work. – Dimple Mathew Jun 13 '18 at 3:50
  • Is it a must requirement to download on click or you can use urllib to fetch the source of pdf? – Artur Korobeynyk Jun 13 '18 at 5:38
  • this is how i am downloading : profile = {"plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF Viewer"}], # Disable Chrome's PDF Viewer "download.default_directory": source_dir, "download.extensions_to_open": "applications/pdf"}. but on running headless this download doesnt work – Dimple Mathew Jun 13 '18 at 6:02
1

This issue is currently being looked at on GitHub (contains a possible solution too).

This is actually seen as a feature and its functionality is intended. There is a work around in Java on stackoverflow and a python version here.

  • i was trying to find a resource in python.. – Dimple Mathew Jun 13 '18 at 3:48
  • @DimpleMathew have edited the response to include python workaround – Jonnyboy Jun 13 '18 at 7:14
  • yea... i did do thru that.. but it dint work for me – Dimple Mathew Jun 13 '18 at 9:25
  • What error are you seeing? Can you update your question with what you have tried? – Jonnyboy Jun 13 '18 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.