【问题标题】:IEDriver. Download. HTTP request to the remote WebDriver server timed out after 60 seconds驱动程序。下载。对远程 WebDriver 服务器的 HTTP 请求在 60 秒后超时
【发布时间】:2019-02-21 22:37:43
【问题描述】:

我的测试脚本正在导航到报告页面,它点击“下载报告”按钮。点击后,页面底部会出现一个IE下载对话框。

问题是,在 IE 中单击该按钮后,驱动程序似乎失去了连接。寻找一些可能的解决方法。 IEDriver 和 Webdriver nuget 包都是最新版本。这是 C#。 此问题仅在 IE 中。

这是我得到的错误:

OpenQA.Selenium.WebDriverException:对远程的 HTTP 请求 URL 的 WebDriver 服务器 http://localhost:52706/session/ea7da8ec-add0-4562-81c2-d2ebc706a073/click 60 秒后超时。 ---> System.Net.WebException:请求 已中止:操作已超时。

【问题讨论】:

  • 使用“eager”而不是“normal”的pageLoadStrategy。

标签: c# selenium internet-explorer selenium-webdriver


【解决方案1】:

这里的问题是,当IE在下载文件的过程中,浏览器的readyState永远不会从interactive移动到complete,这意味着浏览器“等待页面加载”检测永远不会完成.阻止这种情况的方法是在创建时更改驱动程序的页面加载策略。这样做的缺点是它可能会影响其他操作,因为驱动程序会比您的代码预期更早地从页面加载中返回,因此需要在代码的其他部分中明智地使用WebDriverWait。设置页面加载策略的代码如下:

// DISCLAIMER: Code below written from memory,
// without benefit of Visual Studio or
// another IDE. It might require modification
// to work properly, or even to compile.
InternetExplorerOptions options = new InternetExplorerOptions;
options.PageLoadStrategy = PageLoadStrategy.Eager;
IWebDriver driver = new InternetExplorerDriver(options);

【讨论】:

  • 非常感谢!首先,这解决了问题。其次,为了绕过您列出的可能的缺点,我使用链接到 BeforeScenario 钩子的标签标记了需要单击该按钮的特定场景,这将启动新的 sriver 实例,并将该选项设置为 Eager,因此其他场景不应该受到影响.再次感谢。
  • 感谢您的回答,我在为 IE 驱动程序分配 URL 时遇到了同样的错误(browser.Url =...),但我不能使用此方法,请给我您的主意?谢谢/
猜你喜欢
  • 2019-06-28
  • 2017-05-06
  • 2017-09-03
  • 2018-03-22
  • 2014-04-14
  • 1970-01-01
  • 2018-11-15
  • 2021-12-04
  • 2023-03-19
相关资源
最近更新 更多