Selenium遇到的问题记录:“The operation has timed out”

问题如下:

Error converting value \"OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:60428/session/42277796c94c6a00778b4863cf27c37d/url timed out after 60 seconds.
---> System.Net.WebException: The operation has timed out.

解决方法如下:

注意标红的那2行

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("no-sandbox");
chromeOptions.AddArguments("headless");//隐藏google
IWebDriver webDriver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), chromeOptions, TimeSpan.FromMinutes(3));

 

posted @ 2021-01-21 17:26  星星c#  阅读(1211)  评论(0编辑  收藏  举报