我一直在寻找这一整天,似乎没有解决方案目前从python的chromedriver实现可用。设置chrome.prefs与python绑定硒在chromedriver
如何使用webdriver.Chrome()方法设置特定的chrome.prefs(例如profile.managed_default_content_settings.images = 2等配置文件设置)?
我已经通过webdriver.ChromeOptions()试过了,但没有成功。在Java中,有适当的功能可以实现这一点。
但是Python?这是我在做什么目前...
options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--disable-web-security')
options.add_argument('--disk-cache-dir=/var/www/cake2.2.4/app/tmp/cache/selenium-chrome-cache')
options.add_argument('--no-referrers')
options.add_argument('--window-size=1003,719')
options.add_argument('--proxy-server=localhost:8118')
options.add_argument("'chrome.prefs': {'profile.managed_default_content_settings.images': 2}")
self.selenium = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=options)
类似的问题在这里(我试图改变Chrome的下载文件夹)。尝试了你的代码,但不知何故,它不适合我。我的webdriver.py文件中的desired_capabilities.update(options.to_capabilities())行没有被注释掉。有什么想法吗?你有没有遇到过其他解决方案? – Parzival 2013-08-03 00:22:20
不,这只是。你觉得这行吗? desired_capabilities.update(options.to_capabilities()) – Jabb 2013-08-26 14:19:12
我做过。它没有被注释掉,所以它应该有效,但不知道它没有。最后,我完全放弃了Chrome。 – Parzival 2013-08-26 15:33:53