我正在尝试在 C# 中使用 selenium 运行 chrome headless,但我不断收到此错误:
您正在使用不受支持的命令行标志:
--ignore-certificate-errors,稳定性和安全性将受到影响。
我在用着
- 铬:61
- Chrome 驱动程序:2.3
- 硒: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);
}
}
}
我的 WinForm 应用程序只有一个名为“StartBtn”的按钮。
要消除以下错误:
您正在使用不受支持的命令行标志:--ignore-certificate-errors,稳定性和安全性将受到影响
当你正在使用Selenium: 3.6
随着Chrome: 61
,而不是使用chromedriver v2.3
考虑使用最新版本的chromedriver.exe
i.e. v2.33
此外,除了现有参数之外,还添加以下参数:disable-infobars
, --disable-extensions
因此,该行代码将如下所示:
options.AddArguments("headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1440,900", "disable-infobars", "--disable-extensions")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)