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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24168407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:07:40  来源:igfitidea点击:

Unsupported command-line flag: --ignore-certificate-errors

pythonseleniumselenium-chromedriver

提问by Loknar

Using Python 2.7.5, python module selenium (2.41.0) and chromedriver (2.9).

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

When Chrome starts it displays a message in a yellow popup bar: "You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer." This simple example reproduces the problem.

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

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

How do I remove this command-line flag in python selenium?

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

采纳答案by Shawn Erquhart

This issue is resolved as of Chromedriver 2.11(released Oct 2014). Updating will now do the trick.

此问题自 Chromedriver 2.11(2014 年 10 月发布)起已解决。更新现在可以解决问题。

回答by Loknar

This extra code removes the --ignore-certificate-errors command-line flag for me. In my opinion the arguments that can be added to webdriver.Chrome() could (and should) be better documented somewhere, I found this solution in a comment on the chromedriver issues page(see post #25).

这个额外的代码为我删除了 --ignore-certificate-errors 命令行标志。在我看来,可以(并且应该)在某个地方更好地记录可以添加到 webdriver.Chrome() 的参数,我在chromedriver 问题页面上的评论中找到了这个解决方案(参见帖子 #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/")

回答by Byron

you can use the following flag --test-type

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

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

            return new ChromeDriver(options);

回答by frass

This is what I'm currently using in Java to get around this issue but I don't know how Python works but worth a try anyway

这是我目前在 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");

回答by Nagarjun

    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)

回答by cchapman

I was having this problem using Selenium2 with Robot on a Mac. The problem ended up being that I had the wrong version of chromedriverinstalled on my system...

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

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

I found it in /usr/local/binand just removed it and replaced it from the official download pageand it seems to have cleared it all up...

我在里面找到了它,/usr/local/bin然后将它删除并从官方下载页面替换它,它似乎已经清除了所有内容......

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