【发布时间】:2016-09-08 08:29:06
【问题描述】:
我有下面的代码来点击一个按钮。当我调试它时,它经过 Click() 行,然后单击了按钮(我可以看到一个新窗口按预期弹出)。但是,它会在那里停留一分钟,然后返回超时异常。它不会转到下一行代码。
此外,这似乎只发生在此按钮上,单击后会启动一个新的弹出窗口。页面上的其他按钮似乎没问题。
提前感谢您的任何见解!
var button = DriverFactory.Instance.FindElement(By.Id("ctl07_Customers_OCS_ListForms_btnAddCustomer"));
button.Click(); // A new pop-up window is opened
// Next line of code - It times out before it can hit the following line
DriverFactory.Instance.SwitchTo().Window(DriverFactory.Instance.WindowHandles.Last());
异常详情:
OpenQA.Selenium.WebDriverException 未被用户代码处理 H结果=-2146233088 Message=对 URL http://localhost:7055/hub/session/5e7fc81a-ed31-4310-9419-f1e5cc0d1b35/element/%7B96a49e56-d619-4765-b0a7-222f69da23bf%7D/click 的远程 WebDriver 服务器的 HTTP 请求在 60 秒后超时。 源=WebDriver 堆栈跟踪: 在 OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest 请求) 在 OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(命令 commandToExecute) 在 OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(命令 commandToExecute) 在 OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串 driverCommandToExecute,Dictionary`2 参数) 在 OpenQA.Selenium.Remote.RemoteWebElement.Click() 在 C:\Src\EPSQA\Regression_Portals\OCSPortal\OCSPortalFramework\Pages\BankPortal\ListFormsPage.cs: 25 中的 OCSPortalFramework.Pages.BankPortal.ListFormsPage.ClickAddCustomer() 在 OCSPortalTests.OCS_146710_Add_Customer.OCS_146710_Add_Customer_Test() 在 C:\Src\EPSQA\Regression_Portals\OCSPortal\OCSPortalTests\OCS_146710_Add_Customer.cs:line 52 内部异常: H结果=-2146233079 Message=请求已中止:操作已超时。 源=系统 堆栈跟踪: 在 System.Net.HttpWebRequest.GetResponse() 在 OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest 请求) 内部异常:
【问题讨论】:
标签: c# selenium exception-handling timeout remotewebdriver