如何解决“您使用的是不受支持的命令行标志:--ignore-certificate-errors,稳定性和安全性将受到损害".在HeadlessChrome中 [英] How to address "You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer" in HeadlessChrome

查看:1623
本文介绍了如何解决“您使用的是不受支持的命令行标志:--ignore-certificate-errors,稳定性和安全性将受到损害".在HeadlessChrome中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在C#中使用硒无头运行chrome,但我不断收到此错误:

I'm trying to run chrome headless using selenium in C# but I keep getting this error:

您正在使用不受支持的命令行标志: --ignore-certificate-errors,稳定性和安全性将受到损害.

You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer.

我正在使用

  • Chrome浏览器:61
  • ChromeDriver:2.3
  • 硒:3.6
  • .Net 4.5

我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace MyApp {
public partial class Form1: Form {
    public Form1() {
        InitializeComponent();
    }

    private void StartBtn_Click(object sender, EventArgs e) {
        string appPath = AppDomain.CurrentDomain.BaseDirectory;

        IWebDriver driver;
        ChromeOptions options = new ChromeOptions();
        options.AddArguments("--headless", "--disable-gpu", "--remote-debugging-port=9222", "--window-size=1440,900");
        driver = new ChromeDriver(options);
    }
}
}

我的WinForm应用程序只有一个名为"StartBtn"的按钮.

My WinForm application just has one button with name "StartBtn".

推荐答案

要摆脱以下错误:

您使用的命令行标志不受支持:--ignore-certificate-errors,稳定性和安全性会受到损害

You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer

Chrome: 61 一起使用 Selenium: 3.6 时,请考虑使用最新版本的 chromedriver v2.3 ,而不要使用 chromedriver v2.3 . chromedriver.exe ,即 v2.33

As you are using Selenium: 3.6 along with Chrome: 61, instead of using chromedriver v2.3 consider using the latest version of the chromedriver.exe i.e. v2.33

此外,连同您现有的参数一起,添加以下参数: disable-infobars --disable-extensions

Additionally, along with your existing arguments add the following arguments as well: disable-infobars, --disable-extensions

因此,代码行如下:

options.AddArguments("headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1440,900", "disable-infobars", "--disable-extensions")

这篇关于如何解决“您使用的是不受支持的命令行标志:--ignore-certificate-errors,稳定性和安全性将受到损害".在HeadlessChrome中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆