gpt4 book ai didi

c# - 如何在 HeadlessChrome 中解决 "You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer"

转载 作者:太空宇宙 更新时间:2023-11-03 12:21:55 35 4
gpt4 key购买 nike

我尝试在 C# 中使用 selenium headless 运行 chrome,但我一直收到此错误:

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

我正在使用

  • Chrome :61
  • Chrome 驱动程序:2.3
  • Selenium :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”的按钮。

最佳答案

要消除以下错误:

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

当您使用 Selenium: 3.6Chrome: 61 时,而不是使用 chromedriver v2.3 考虑使用最新版本的 chromedriver.exev2.33

此外,除了您现有的参数外,还要添加以下参数:disable-infobars--disable-extensions

所以,代码行如下:

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

关于c# - 如何在 HeadlessChrome 中解决 "You are using an unsupported command-line flag: --ignore-certificate-errors, Stability and security will suffer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46789261/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com