相关疑难解决方法(0)

使用python绑定为chromedriver中的selenium设置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)
Run Code Online (Sandbox Code Playgroud)

python selenium selenium-chromedriver

11
推荐指数
3
解决办法
2万
查看次数

标签 统计

python ×1

selenium ×1

selenium-chromedriver ×1