以下当我使用以下配置protractor.net进行c#nunit
的测试时,会引发异常。 1. "NUnit" version="3.11.0"
2. "NUnit3TestAdapter" version="3.12.0"
3. "Protractor" version="0.12.0"
4. "Selenium.WebDriver" version="3.141.0"
5. "Selenium.WebDriver.ChromeDriver" version="2.36.0"
6. Chromebrowser Version : 65.0.3325.162
Angular.version{完整:1.6.9&quot',专业:1,次要:6,点:9,代号:'fiery-basilisk"}
以下我用于测试的示例代码,它在ngby.repeater上失败
private IWebDriver driver;
driver = new ChromeDriver();
driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);
public void uitest()
{
try {
ngDriver.Navigate().GoToUrl("");
ngDriver.FindElement(By.Id("userNameInput")).SendKeys("");
ngDriver.FindElement(By.Id("passwordInput")).SendKeys("");
ngDriver.FindElement(By.Id("submitButton")).Click();
string text=ngDriver.FindElements(NgBy.Repeater(""))[0].Text;
Assert.AreEqual("Dashboard", text);
}catch(Exception e)
{
Console.WriteLine("Exception :"+e.ToString());
Assert.True(false);
}
driver.Quit();
}
例外:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:61649/session/f5f68e3d39a9e0e5adee0c5d76acd9d1/execute_async timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteAsyncScript(String script, Object[] args)
at Protractor.NgWebDriver.WaitForAngular() in c:UsersBrunoProjetsGitHubbbaiaprotractor-netsrcProtractorNgWebDriver.cs:line 359
at Protractor.NgWebDriver.FindElements(By by) in c:UsersBrunoProjetsGitHubbbaiaprotractor-netsrcProtractorNgWebDriver.cs:line 299
您需要将IgnoreSynchronization
设置为true
并调用WaitForAngular()
Angular Page的方法
ngDriver.IgnoreSynchronization = true;
ngDriver.WaitForAngular();
在SetUp()
方法中添加此方法或尝试在面对问题的线路上使用