【问题标题】:Selenium Webdriver C# Click works then times out in IESelenium Webdriver C# Click 工作然后在 IE 中超时
【发布时间】:2016-02-16 20:20:18
【问题描述】:

我正在测试一个使用 selenium webdriver 的 c# 绑定的 web 应用程序。测试点击了一些具有 onclick 功能的元素,例如 (onclick="window.location.href = 'google.com'")。当涉及到最后一个元素时,它会单击它并加载作为 javascript 图像查看应用程序的下一页。页面没有完成测试,而是在同一位置保持打开 60 秒,直到它失败并出现错误:

--WebException 在 System.Net.HttpWebRequest.GetResponse() 在 OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest 请求)

结果信息: OpenQA.Selenium.WebDriverException :对 URL http://localhost:27431/session/fd102072-024b-4ccc-99af-4c8e609c027d/element/0843e2a6-82ce-48ff-9ad2-2649585a43dc/click 的远程 WebDriver 服务器的 HTTP 请求在 60 秒后超时。 ----> System.Net.WebException : 请求被中止:操作超时。

同样的测试适用于 chrome 和 firefox。该元素肯定会显示并单击。浏览器也可以正常访问该页面,但由于某种原因超时。

【问题讨论】:

    标签: c# html selenium


    【解决方案1】:

    这不是一个新问题。它已经存在了很长时间。我不时在stackoverflowgoogle group 上阅读有关此问题的信息。尽管这个问题似乎是独一无二的(因为我已经使用 webdriver .net 绑定大约两年并且从未遇到过这个问题),但 IEDriver 服务器的作者给出了一个可靠的explanation 为什么会发生这种情况。很多人建议增加隐式等待可能会有所帮助,即使我怀疑这会有所帮助。阅读博客可以帮助您了解问题并找出问题所在。

    【讨论】:

      【解决方案2】:

      你需要做的是……:

      InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService();
                      //driverService.HideCommandPromptWindow = true;
                      driverService.LibraryExtractionPath = Environment.CurrentDirectory;
      
                      InternetExplorerOptions options = new InternetExplorerOptions();
                      options.EnableNativeEvents = true;
                      options.IgnoreZoomLevel = true;
                      options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
      
      
      
                      IWebDriver driver = new InternetExplorerDriver(driverService, options, TimeSpan.FromSeconds(180));
      

      【讨论】:

      • 我试过了,不幸的是它没有解决问题。你知道我可能还缺少什么吗?
      猜你喜欢
      • 2015-03-27
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多