简体   繁体   中英

Selenium Chrome Headless download file

I use headless chrome and selenium but i have problem in downloading file. Using options:

prefs = {"download.default_directory": dr,
         "download.prompt_for_download": False,
         "download.directory_upgrade": True,
         "safebrowsing.enabled": True
         }
options.add_experimental_option("prefs", prefs)

If headless chrome not used then file download successfully but if headless works then nothing actions. How i can solve it?

Your question is already answered at https://stackoverflow.com/a/42583255/6304901

It's not a bug it's a feature :

We most likely want to this to be something you need to either control or enable via DevTools to avoid letting random websites drop files on your disk just because you're running in headless mode.

please see https://bugs.chromium.org/p/chromium/issues/detail?id=696481 for further details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM