我正在nunit测试中使用ChromeDriver来测试是否加载了复杂的页面:
public ChromeDriver Driver { get; private set; }
[OneTimeSetUp]
public void Setup()
{
ChromeOptions co = new ChromeOptions{};
co.AddArgument("no-sandbox");
Driver = new ChromeDriver( co) ;
Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
Driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(120);
Driver.Manage().Window.Maximize();
}
如您所见,当我跑步时,我尝试将超时时间增加到所有地方2分钟
Driver.Navigate().GoToUrl(url);
针对我得到的页面
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL timed out after 60 seconds.
该页面的加载时间超过60秒,那么如何增加60秒?
答案 0 :(得分:1)
您需要增加RemoteWebDriver中的DefaultCommandTimeout
。您可以使用ChromeDriver(ChromeDriverService, ChromeOptions, TimeSpan)
或ChromeDriver(string, ChromeOptions, TimeSpan)
重载来实现
ChromeOptions co = new ChromeOptions{};
Driver = new ChromeDriver("path to ChromeDriver.exe", co, TimeSpan.FromSeconds(120));
// or
Driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), co, TimeSpan.FromSeconds(120));