为了尝试同时针对两个浏览器(Chrome和IE)运行测试,我一直在争夺常见的“远程WebDriver服务器的URL请求以获取URL ... x秒后超时”几个月通过stackoverflow和搜索引擎结果一次小时搜索,以尝试找到解决方案。
与我之前的其他人一样,我的行为在点击功能超时或尝试获取网址时有所不同,并且在各种情况下我将页面加载和隐式等待超时增加到超过600秒,在元素之前插入等待,在调用url之后,在调用url之前,调用驱动程序构造函数并将其作为驱动程序对象调用中的参数。
我试图包含javascript exectutor脚本(在此问题的先前SO帖子中提供),在继续执行操作之前检查页面加载就绪状态是否完成,但没有成功。
我试图将我的chrome和IE,selenium web和支持驱动程序全部更新到最新的兼容版本,手动调用二进制文件以获取最新的兼容浏览器可执行文件 - 以及尝试回滚到人们报告的先前版本成功(chrome v48,chromedriver 2.22.0.0,webdriver 2.53.1)。我尝试添加“no-sandbox”作为chrome选项,确保我的IE安全区域共享相同级别的保护。
我已经调查过我的网页是否使用了AJAX脚本,并试图使用各种线程中提供的解决方案来适应任何动态内容。
在并行查询之外单独运行IE或Chrome时,不会出现超时问题。当chrome初始化其远程WebDriver实例时,会出现此问题。我也尝试过使用32位和64位版本的chrome / ie驱动程序。
我从许多主题和页面中提取信息,但这些是最相关的信息。
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5441
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5071
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
Selenium WebDriver throws Timeout exceptions sporadically
以下是输出的示例:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.AggregateException : One or more errors occurred.
----> OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:52240/session/a969dbe2-3b0c-461f-a979-21bafec0dd8e/element/7005aeab-ff31-454a-8f78-0a39ad861695/click timed out after 120 seconds.
----> System.Net.WebException : The request was aborted: The operation has timed out.
我从案例列表中调用驱动程序,稍后将其添加到并行查询中:
private static IWebDriver DefineDriver(Browser supportedbrowsers)
{
var baseDriverPath = ConfigurationManager.AppSettings["BaseDriverPath"].ToString();
var ieDriverFolder = ConfigurationManager.AppSettings["IeDriverFolder"].ToString();
var chromeDriverFolder = ConfigurationManager.AppSettings["ChromeDriverFolder"].ToString();
ChromeOptions chromeoptions = new ChromeOptions();
chromeoptions.BinaryLocation = @"C:\WebDrivers\Binary\chrome32_49.0.2623.75\chrome.exe";
chromeoptions.AddArgument("no-sandbox");
InternetExplorerOptions ieoptions = new InternetExplorerOptions();
ieoptions.IntroduceInstabilityByIgnoringProtectedModeSettings = false;
IWebDriver driver = null;
switch (supportedbrowsers)
{
case Browser.Chrome:
driver = new ChromeDriver(Path.Combine(baseDriverPath, chromeDriverFolder), chromeoptions, TimeSpan.FromMinutes(5));
break;
case Browser.InternetExplorer:
driver = new InternetExplorerDriver(Path.Combine(baseDriverPath, ieDriverFolder), ieoptions, TimeSpan.FromMinutes(5));
break;
default:
driver = new ChromeDriver(Path.Combine(baseDriverPath, chromeDriverFolder), chromeoptions, TimeSpan.FromMinutes(5));
break;
}
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(120));
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(10));
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromMinutes(10));
driver.Manage().Window.Maximize();
return driver;
}
在我的测试代码中,我只是启动一个页面,导航到另一个本地页面,然后尝试单击页面上立即可见的按钮。
我尝试在try catch中包含按钮的click命令,在预期条件(显示,启用,isclickable)中添加显式等待,使用的线程休眠在运行单个浏览器时都按预期工作。
例如,我通过以下方式调用按钮:
public void SelectAddWorkWorkPageButton()
{
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementToBeClickable(addNewWorkItemWorkPageBtn));
addNewWorkItemWorkPageBtn.Click();
}
其中包含以下元素:
//Create New Button
[FindsBy(How = How.Id, Using = "btnWorkDefinitionCreateNewWorkDefinition")]
public IWebElement addNewWorkItemWorkPageBtn { get; set; }
它是HTML:
<i id="btnWorkDefinitionCreateNewWorkDefinition" title="Add work" class="fa fa-plus-circle cursorPointer crudIcon" style="font-size: 20px;margin:0;padding-left:15px" ng-click="AddNewWorkDefinition()" role="button" tabindex="0"></i>
作为有关超时的单独注释,在更新到WebDriver的最新版本时,我还将超时更新为新格式:
//driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
//driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
//driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(120);
这个问题似乎早在2012年就已经存在于社区中,并且根据我的发现,从未被孤立和明确确定,人们仍然在今年5月报道。
Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds
答案 0 :(得分:1)
在尝试了几个解决方法之后,包括使用Protractor来解释AngularJS代码,我终于将远程WebDriver服务器的HTTP请求的原因与URL&#34;在针对测试中的应用程序单独或并行运行IEDriver时出现特定问题的异常消息。
应用程序似乎正在使用SignalR连接来处理某些进程,这导致IED驱动程序操作(例如单击事件)超时,因为SignalR连接永远不会完成,因此导致IED驱动程序无法确定页面已完成加载,然后才能执行其他操作。
当SignalR连接类型更新为使用&#34; Long Polling&#34;这完全解决了IEDriver超时问题。
这些帖子提供了更好的解释,并且对那些在内部贡献的人有很多信用,我从未猜到SignalR是其他原因: https://github.com/SignalR/SignalR/issues/293
C# Protractor AngularJS IEDriverServer Click() Exception "Timed out waiting for page to load"
感谢。