如果我致电通过Windows服务打开新的chromedriver v2.41(Chrome版本为68),它将等待太长时间,并向URL http://localhost:50390/session的远程WebDriver服务器返回 HTTP请求超时60秒后退出。。但是,它可以在控制台应用程序中正常运行
var driver = Browser.GetChromeDriver();
public static class Browser
{
public static ChromeDriver GetChromeDriver()
{
string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
String chromeLocalAppDataPath = localAppDataPath + @"\Google\Chrome\User Data\Auto\";
var options = new ChromeOptions();
options.AddArgument("--no-experiments");
options.AddArgument("disable-infobars");
options.AddArgument("no-sandbox");
options.AddArgument("--disable-bundled-ppapi-flash");
options.AddArguments("user-data-dir=" + chromeLocalAppDataPath);
options.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
return new ChromeDriver(options);
}
}