IEDriver.下载. 60秒后,到远程WebDriver服务器的HTTP请求超时 [英] IEDriver. Download. HTTP request to the remote WebDriver server timed out after 60 seconds

查看:339
本文介绍了IEDriver.下载. 60秒后,到远程WebDriver服务器的HTTP请求超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试脚本正在导航到报告页面,单击下载报告"按钮.单击它后,页面底部将显示一个IE下载对话框.

My test script is navigating to report page, where it clicks "Download Report" button. After clicking it, an IE download dialog appears at the bottom of the page.

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

The issue is that it looks like driver is losing connection after clicking that button in IE. Looking for some possible workarounds. Both IEDriver and Webdriver nuget packages are the latets versions. This is C#. This issue is only in IE.

这是我得到的错误:

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

OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:52706/session/ea7da8ec-add0-4562-81c2-d2ebc706a073/click timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.

推荐答案

此处的问题是,当IE正在下载文件时,浏览器的readyState永远不会从interactive移到complete ,表示浏览器等待页面加载"检测永远不会完成.停止此操作的方法是在创建驱动程序时更改驱动程序的页面加载策略.不利的一面是,它可能会影响其他操作,因为驱动程序将从页面加载中返回的时间比您的代码期望的要早,因此需要在代码的其他部分中明智地使用WebDriverWait.设置页面加载策略的代码如下:

The problem here is that when IE is in the process of downloading a file, the readyState of the browser never moves from interactive to complete, meaning that the browser "wait for page load" detection never finishes. The way to stop this is to change the driver’s page load strategy on creation. The downside to this is that there is a chance that it will affect other operations in that the driver will return earlier from a page load than your code expects, so judicious use of WebDriverWait in other parts of your code will be required. The code to set the page load strategy is something like the following:

// 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);

这篇关于IEDriver.下载. 60秒后,到远程WebDriver服务器的HTTP请求超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆