webdriver的硒偶尔抛出超时异常 [英] Selenium WebDriver throws Timeout exceptions sporadically

查看:501
本文介绍了webdriver的硒偶尔抛出超时异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用硒对我们的项目的UI测试。我们正在运行2.30.0的最新版本。 我们使用Firefox webdriver的和运行Firefox 19.0。

通常说的UI测试工作的地方,甚至服务器端当我运行在Visual Studio中的UI测试。我们的UI测试被执行nighlty我们的构建服务器上。它使用相同的部署在同一台服务器我通过Visual Studio的手动测试上。

但偶尔我们遇到以下问题时,UI测试得到的buildserver执行:

 测试(S)失败。 OpenQA.Selenium.WebDriverException:HTTP请求到远程webdriver的服务器用于URL http://localhost:7056/hub/session/bed1d0e7-efdc-46b6-ba07-34903519c44d/element/%7B8717bb19-96c7-44d3-b0ee-d4b989ae652d%7D/click 60秒后超时。
      ----> System.Net.WebException:操作已超时
       在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest的要求)
       在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串driverCommandToExecute,Dictionary`2参数)
--WebException
   在System.Net.HttpWebRequest.GetResponse()
   在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest的要求)
 

基本上测试点击上传按钮,在输入字段中之前充满了文件。由于文件是非常小的这得到在几秒钟内完成。 尽管如此的60秒timout有时达到

任何想法如何找出潜在的问题?或者之前运行任何人进入同一个问题? 任何提示AP preciated。谢谢你。

解决方案

我得到这个同样的错误

:.NET webdriver的:2.37,FF:25.0.1。我注意到,火狐被锁定,直到我离开我的测试应用程序,所以我建立的Firefox的调试版本,并发现,当它被写入标准错误禁售发生。这给我的线索,以改变webdriver的code,使其不再重定向标准输出和错误,这解决了我的问题。这似乎是webdriver的阻止以某种方式STD错误。从MSDN:

  

同步读取操作介绍呼叫者之间的相关性   从StandardError的流和子进程写入读   该流。这些依赖性会导致死锁条件......

更多信息<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandarderror%28v=vs.110%29.aspx"相对=nofollow>这里。

有关任何人想要做出同样的调整我所做的: -

  1. 获取硒源。然后检查你使用的是相同的code分支。

  2. 在FireFoxBinary.cs:

    我。无论你在哪里找到 RedirectStandardError = TRUE ,更改为 RedirectStandardError = FALSE

    二。无论你在哪里找到 RedirectStandardOutput = TRUE ,更改为 RedirectStandardOutput = FALSE 。 (对于非Windows,也有一在Executable.cs)

    三。在ConsoleOuput,变化的回归this.stream.ReadToEnd(),以回报

  3. 建立和与你替换WebDriver.dll。

免责声明:本文为我工作,但您的问题可能会有所不同。另外据我所知,这并没有比禁用控制台输出等不利影响,但可能有其他副作用,我不知道。

我很想知道,如果任何人发现一样。

既然我已经解决了我的问题,我不会挖得更深。如果有人一硒组成员希望有更多的信息/日志/调整我会很乐意这样做。

希望这会得到尽快解决。

更新

看来,火狐V25目前不支持。请参见此评论

更新2014年2月25日

请参阅此更新

  

好吧,这个问题一般不会体现在IE浏览器,左右吧   似乎从注释中。我希望人们试着用Firefox和   Chrome浏览器和.NET绑定2.40.0(将成为下一个版本的   写这篇文章的时候)或更高版本,看看这还是发生了。

     

我已经看到这种情况发生在Chrome自2.35.0较少的报道,让我   需要知道,如果这仍然是一个问题的.NET绑定和一   最近chromedriver.exe。

     

2.40.0可具有为的问题中的至少一个的修复可能在Firefox导致此

这解决了这个问题对我来说。纵观更改日志,所以从2014年1月31日提交,除去控制台记录重定向:

 不再重定向控制台输出为Firefox在.NET中的绑定。
 

这是我在这里用的解决方法。那么,这一切是有道理的。

Using selenium for ui tests on our project. We are running the newest version 2.30.0. We use Firefox WebDriver and are running Firefox 19.0.

Generally said the ui test works local and even server side when I run the ui test in Visual Studio. Our ui tests gets executed nighlty on our build server. It uses the same deploy on the same server I test manually via Visual Studio.

But sporadically we run into following issue when the ui test gets executed on buildserver:

Test(s) failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:7056/hub/session/bed1d0e7-efdc-46b6-ba07-34903519c44d/element/%7B8717bb19-96c7-44d3-b0ee-d4b989ae652d%7D/click timed out after 60 seconds.
      ----> System.Net.WebException : The operation has timed out
       at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
--WebException
   at System.Net.HttpWebRequest.GetResponse()
   at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)

Basically the test clicks on an upload button where the input field was filled with a file before. Since the file is very small this gets done in a few seconds. Nevertheless the timout of 60 seconds is reached sometimes.

Any ideas how to isolate the underlying issue? Or run anybody into the same issue before? Any hints appreciated. Thanks.

解决方案

I got this same error: .NET WebDriver: 2.37, FF: 25.0.1. I noticed that Firefox was locking up until I exited my test application, so I built the debug version of Firefox and found that the lock-up happened when it was writing to stderr. This gave me the clue to change the webdriver code so that it no longer redirects standard out and error and this solved my problem. It seems like the WebDriver is blocking the std error in some way. From MSDN:

Synchronous read operations introduce a dependency between the caller reading from the StandardError stream and the child process writing to that stream. These dependencies can cause deadlock conditions...

More info here.

For anyone wanting to make the same tweak I did: -

  1. Get the Selenium source. Then check out the same code branch that you are using.

  2. In FireFoxBinary.cs:

    i. Wherever you find RedirectStandardError = true, change to RedirectStandardError = false.

    ii. Wherever you find RedirectStandardOutput = true, change to RedirectStandardOutput = false. (for non-Windows, there is also one in Executable.cs)

    iii. In ConsoleOuput, change 'return this.stream.ReadToEnd()', to 'return ""'

  3. Build and replace WebDriver.dll with yours.

Disclaimer: This worked for me, but your issue might be different. Also as far as I can tell, this has no adverse effects other than disabling the console output, but there may be other side effects that I am unaware of.

I would be interested to know if anyone else finds the same.

Since I have solved my problem, I will not dig any deeper. If anyone a Selenium group member wants more info / logs / tweaks I would be happy to do so.

Hopefully this will get fixed soon.

Update

It appears that Firefox v25 is not currently supported. See this comment.

Update 25th Feb 2014

See this update:

Okay, this issue in general does not manifest itself in IE, or so it seems from the comments. I'd like people to try with Firefox and Chrome, and the .NET bindings 2.40.0 (will be the next release at the time of this writing) or later, and see if this is still happening.

I've seen fewer reports of this happening in Chrome since 2.35.0, so I need to know if this is still an issue with the .NET bindings and a recent chromedriver.exe.

2.40.0 may have a fix for at least one of the issues that may cause this in Firefox.

This solved the problem for me. Looking at the change log, there is a commit from 1/31/2014 to remove console logging redirection:

"No longer redirecting console output for Firefox in .NET bindings."

Which is the workaround I used here. So, it all makes sense.

这篇关于webdriver的硒偶尔抛出超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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