本文介绍了Python Selenium设置多个Chrome偏好设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在chrome浏览器中设置多个chrome选项.这是我目前拥有的:
I am trying to set multiple chrome options in my chrome browser. This is what I currently have:
prefs = {"download.default_directory" : "Download/Path"}
moreprefs = {'safebrowsing.enabled': 'false'}
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("prefs", prefs)
chromeOptions.add_experimental_option("prefs", moreprefs)
self.driver = webdriver.Chrome(chrome_options=chromeOptions)
问题是它仅考虑了chromeOptions.add_experimental中的1个,我需要两者
The probblem is it only takes in to account the 1 of the chromeOptions.add_experimental and I need both
推荐答案
更新prefs词典.然后设置首选项.
update the prefs dictionary. and then set the preference.
prefs = {"download.default_directory" : "Download/Path"}
moreprefs = {'safebrowsing.enabled': 'false'}
chromeOptions = webdriver.ChromeOptions()
prefs.update(moreprefs)
chromeOptions.add_experimental_option("prefs", prefs)
self.driver = webdriver.Chrome(chrome_options=chromeOptions)
这篇关于Python Selenium设置多个Chrome偏好设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!