我想尝试无头Chrome浏览器,但是我遇到了这个问题,我无法在无头模式下启动驱动程序。我正在关注google documentation。我错过了什么吗?该代码执行陷在var browser = new ChromeDriver();
线如何在无头模式下启动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'版本? – haim770
我的版本是2.30.0。 NuGet –
'BinaryLocation'应该指向Chrome(浏览器)的'exe',而不是'chromedriver.exe'。 – haim770