不支持的命令行标志:——ignore-certificate-errors



使用Python 2.7.5, Python模块selenium(2.41.0)和chromedriver(2.9)。

当Chrome启动时,它在一个黄色的弹出栏中显示一条消息:"您正在使用不支持的命令行标志:——ignore-certificate-errors。稳定和安全将受到影响。"这个简单的例子再现了这个问题。

from selenium import webdriver
browser = webdriver.Chrome()
browser.get("http://google.com/")

如何在python selenium中删除此命令行标志?

这段额外的代码为我删除了——ignore-certificate-errors命令行标志。在我看来,可以添加到webdriver.Chrome()的论据可以(也应该)更好地记录在某个地方,我在chromedriver问题页面的评论中找到了这个解决方案(见post #25)。

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
browser = webdriver.Chrome(chrome_options=options)
browser.get("http://google.com/")

此问题已在Chromedriver 2.11(2014年10月发布)中解决。

您可以使用以下标志——test-type

            var options = new ChromeOptions();
            options.AddArguments(new[] {
                "--start-maximized",
                "allow-running-insecure-content", 
                "--test-type" });
            return new ChromeDriver(options);

这是我目前在Java中使用的解决这个问题的方法,但我不知道Python是如何工作的,但无论如何值得一试

ChromeOptions chrome = new ChromeOptions();
chrome.addArguments("test-type");
        capabilities.setCapability(ChromeOptions.CAPABILITY, chrome);
        capabilities.setCapability("chrome.binary",
                "C:\set path to driver here\chromedriver.exe");
    options = webdriver.ChromeOptions()
    options.add_argument('test-type')
    chromedriver = 'resources/chromedriver.exe'

    os.environ["webdriver.chrome.driver"] = chromedriver
    self.driver = webdriver.Chrome(chromedriver,chrome_options=options)

我在Mac上使用Selenium2和Robot时遇到了这个问题。问题最终是我在系统上安装了错误的chromedriver版本…

$ chromedriver
Starting ChromeDriver (v2.9.248307) on port 9515    <<Version 2.9 was the problem

我在/usr/local/bin中找到了它,只是将它从官方下载页面中删除并替换了它,似乎已经清除了一切…

$ chromedriver
Starting ChromeDriver 2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1) on port 9515
Only local connections are allowed.

最新更新