【发布时间】:2017-12-21 05:01:12
【问题描述】:
我想试试 headless chrome,但我遇到了这个问题,我无法在 headless 模式下启动驱动程序。我在关注google documentation。我错过了什么吗?代码执行卡在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版本是什么? -
我的版本是2.30.0。从 NuGet 得到它
-
BinaryLocation应该指向 Chrome(浏览器)的exe,而不是chromedriver.exe -
是的,你是对的。但还是没有解决问题
标签: c# selenium selenium-chromedriver