首页 文章

Selenium RemoteWebDriver按钮单击方法异常超时,即使单击该按钮也是如此

提问于
浏览
1

我有以下代码来点击按钮 . 当我调试它时,它会经过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未由用户代码处理HResult = -2146233088 Message =对URL的远程WebDriver服务器的HTTP请求http:// localhost:7055 / hub / session / 5e7fc81a-ed31-4310-9419-f1e5cc0d1b35 / element /%7B96a49e56-d619-4765-b0a7-222f69da23bf%7D / 60秒后点击超时 . Source = WebDriver StackTrace:在OpenQA的OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(命令commandToExecute)的OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(命令commandToExecute)中的OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求) . Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary`2参数)位于C:\ Src \ EPSQA \ Regression_Portals \中的OCSPortalFramework.Pages.BankPortal.ListFormsPage.ClickAddCustomer()中的OpenQA.Selenium.Remote.RemoteWebElement.Click() OCSPortal \ OCSPortalFramework \ Pages \ BankPortal \ ListFormsPage.cs:第25行,OCSPortalTests.OCS_146710_Add_Customer.OCS_146710_Add_Customer_Test(),位于C:\ Src \ EPSQA \ Regression_Portals \ OCSPortal \ OCSPortalTests \ OCS_146710_Add_Customer.cs:第52行InnerException:HResult = -2146233079 Message =请求已中止:操作已超时 . Source = System StackTrace:位于OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求)的System.Net.HttpWebRequest.GetResponse()内部异常:

1 回答

  • 1

    解决这个问题的方法是:

    try {
    button.click();
    thread.sleep(300);
    }
    catch(Exception e) {
    //System.out.println("" +e.getMessage());
    }
    

相关问题