我正在尝试使用xUnit、Selenium和Chrome Canary(无头模式)运行浏览器测试,但是我一直收到这个错误:
OpenQA.Selenium.WebDriverException
The HTTP request to the remote WebDriver server for URL
http://localhost:58692/session timed out after 60 seconds.
这是我的代码:
var chromeOptions = new ChromeOptions
{
BinaryLocation = @"C:\Users\<USERNAME>\AppData\Local\Google\Chrome SxS\Application\chrome.exe",
DebuggerAddress = "127.0.0.1:9222"
};
chromeOptions.AddArguments("no-sandbox", "headless", "disable-gpu");
_driver = new ChromeDriver(chromeOptions) {Url = Url};
我对C#还很陌生,所以我不确定我是否做错了什么,或者我是否错过了某些设置。通过谷歌上述错误信息,我发现需要设置调试器地址并使用no-sandbox
标志,但是这两种方法似乎都没有帮助。
使用以下版本:
selenium 3.4
chromedriver 2.29
xunit 2.2