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.

4
  • 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, 2018 at 11:50
  • but as the script runs headless i dont think ctrl+s would work. Jun 13, 2018 at 3:50
  • Is it a must requirement to download on click or you can use urllib to fetch the source of pdf? Jun 13, 2018 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 Jun 13, 2018 at 6:02

1 Answer 1

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.

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

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .