我想尝试无头浏览器,但我遇到了这个问题,即无法在无头模式下启动驱动程序。我正在遵循谷歌文档。我错过了什么吗?代码执行卡在var browser = new ChromeDriver();
这一行。
这是我的代码:
var chromeOptions = new ChromeOptions
{
BinaryLocation = @"C:\Users\2-as Aukstas\Documents\Visual Studio 2017\Projects\ChromeTest\ChromeTest\bin\Debug\chromedriver.exe",
DebuggerAddress = "localhost:9222"
};
chromeOptions.AddArguments(new List<string>() {"headless", "disable-gpu" });
var browser = new ChromeDriver(chromeOptions);
browser.Navigate().GoToUrl("https://stackoverflow.com/");
Console.WriteLine(browser.FindElement(By.CssSelector("#h-top-questions")).Text);
chromedriver.exe
版本是多少? - haim770BinaryLocation
should point to theexe
of Chrome (the browser), notchromedriver.exe
- haim770