How to address “You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer” in HeadlessChrome

家住魔仙堡 提交于 2019-12-10 23:38:35

问题


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

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

I'm using

  • Chrome: 61
  • ChromeDriver: 2.3
  • Selenium: 3.6
  • .Net 4.5

My code:

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);
    }
}
}

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


回答1:


To get rid of the following error :

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

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

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

So, the line of code will be as follows:

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


来源:https://stackoverflow.com/questions/46789261/how-to-address-you-are-using-an-unsupported-command-line-flag-ignore-certifi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!