问题
I'm trying to download a couple of files in a test that are randomly generated on the back-end with a unique name
I use this preferences that I pass to the chrome driver both directly or in a selenium hub
CHROME_PREFERENCES = {
"profile.default_content_settings.popups": 0,
"download.prompt_for_download": "false",
"download.directory_upgrade": "true",
"download.default_directory": "/mnt/hgfs/down/",
"profile.default_content_setting_values.notifications": 2,
"profile.default_content_setting_values.automatic_downloads": 1
}
But Chrome keeps asking me for the download location every time that I make the get call to the download URL from the driver, rendering the automation useless...
I also tried, using bool values as True / False instead of "true" / "false"
回答1:
This works for me:
options = Options()
prefs = {'download.prompt_for_download': False,
'download.default_directory': download_dir,
'download.directory_upgrage': True,
'profile.default_content_settings.popups': 0,
}
options.add_experimental_option('prefs', prefs)
p.s. Sorry, i couldn't comment, so I ask here: How do you pass your preferences?
来源:https://stackoverflow.com/questions/49053624/chrome-keep-asking-me-for-a-download-location-on-selenium-hub-driver-on-python