Chrome不断询问我在Python上的Selenium Hub/Driver上的下载位置 [英] Chrome keep asking me for a download location on Selenium Hub/Driver on Python
问题描述
我正在尝试在测试中下载几个在后端随机生成的具有唯一名称的文件
I'm trying to download a couple of files in a test that are randomly generated on the back-end with a unique name
我使用直接或在硒鼓中传递给chrome驱动程序的首选项
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
}
但是,每次我从驱动程序对下载URL进行get调用时,Chrome都会不断询问我下载位置,从而使自动化无用...
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...
我也尝试过,使用布尔值作为True/False而不是"true"/"false"
I also tried, using bool values as True / False instead of "true" / "false"
推荐答案
这对我有用:
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.抱歉,我无法发表评论,所以我在这里问:您如何通过您的偏好设置?
p.s. Sorry, i couldn't comment, so I ask here: How do you pass your preferences?
这篇关于Chrome不断询问我在Python上的Selenium Hub/Driver上的下载位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!