Selenium WebDriver throws timeout exceptions sporadically

Using selenium for ui tests in our project. We are launching the latest version 2.30.0. We use Firefox WebDriver and run Firefox 19.0.

As a rule, the ui test works on the local and even the server side when I run the ui test in Visual Studio. Our ui tests are run on our build server. It uses the same deployment on the same server that I manually test through Visual Studio.

But sporadically we encounter the following problem when the ui test is run on the buildserver server:

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 presses the download button, where the input field was filled with the file earlier. Since the file is very small, this is done in a few seconds. However, a time between 60 seconds is sometimes reached.

Any ideas on how to isolate the underlying problem? Or run someone into the same problem earlier? Any hints appreciated. Thank.

+36
c # selenium testing webdriver
Mar 07 '13 at 10:06 on
source share
8 answers

I have the same error: .NET WebDriver: 2.37, FF: 25.0.1. I noticed that Firefox blocked until I quit my test application, so I built a debug version of Firefox and found that the lock occurred when he wrote stderr. This gave me the key to modifying the webdriver code so that it no longer redirects standard errors and errors, and this solved my problem. It appears that WebDriver is somehow blocking the std error. From MSDN:

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

More details here .

For those who want to do the same setup as me: -

  • Get the source of Selena. Then check the same code branch you are using.

  • In FireFoxBinary.cs:

    I am. 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" "

  • Create and replace WebDriver.dll with your own.

Disclaimer: this worked for me, but your problem may be different. Also, as far as I can tell, this has no side effects other than disabling console output, but there may be other side effects that I don't know about.

I would be interested to know if anyone else would find.

Since I solved my problem, I will not dig deeper. If anyone in Selenium wants to get more information / magazines / tricks, I would be happy to do that.

Hopefully this will be fixed soon.

Update

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

February 25, 2014 update

See this update :

Well, this question doesn't show up at all in IE, or so it seems from the comments. I would like people to try to use Firefox and Chrome and the .NET 2.40.0 bindings (there will be the next version at the time of this writing) or later, and see if this is all happening.

I have seen fewer posts about this in Chrome since version 2.35.0, so I need to know if this is still a problem with .NET bindings and the recent chromedriver.exe file.

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

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

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

What a workaround I used here. So everything makes sense.

+8
Nov 24 '13 at 22:05
source share

It happened to me in four different scenarios:

  • The fact is that the window handler that I requested was already closed or at closed stages. If so, it is best to verify that the window still exists before requesting it. If you want to avoid a long wait period of 60 seconds, you must change the way you create a Firefox instance to reduce the delay by 60 seconds:

    new FirefoxDriver ("FfBinaryPath", FfProfileInstance, TimeSpan.FromSeconds (5));

  • The reason was the Protected Mode plugin. This scenario happened to me only under windows 7 and 8, when they ran under Jenkins' work, the timeout did not happen sporadically. To fix this, I launched an instance of selenium Firefox with the flash protection mode disabled:

    FfProfile.SetPreference ("dom.ipc.plugins.flash.disable-protected-mode", true);

  • Another reason, also not sporadic, under Jenkins and related to Flash, occurred when using Firefox version 45. To solve this problem, I had to upgrade to version 44 or change the removal of Flash.

    / li>
  • Reason for the internal browser: sometimes the browser takes more than one minute to respond to Selenium calls. In this case, setting a timeout for the browser command for more than 60 seconds may solve the problem. eg:

    new FirefoxDriver("FfBinaryPath", FfProfileInstance, TimeSpan.FromMinutes(3));

+5
Jan 23 '14 at 11:18
source share

In my case, the page is just not fully loaded. Some facebook plugins seem to load too long. I tried to catch the exception and manipulate the unfinished dom, but this did not give me any results. :(

John

+2
Jul 16 '13 at 13:45
source share

I had the same error with a timeout. I used IEDriverServer (64 bit), and with long sendKey commands timeout.

The reason is that the default timeout is 60 seconds.

What is the problem: I created a driver instance using a method that allows you to enter the IEDriverServer location, driver parameters, and timeout value.

Documentation link: http://seleniumhq.imtqy.com/selenium/docs/api/dotnet/

 public InternetExplorerDriver( string internetExplorerDriverServerDirectory, InternetExplorerOptions options, TimeSpan commandTimeout ) 

Options

  • InternetExplorerDriverServerDirectory:
    • Type: System.String
    • Full path to the directory containing the IEDriverServer.exe file
  • Options
    • Type: OpenQA.Selenium.IE.InternetExplorerOptions
    • InternetExplorerOptions used to initialize the driver
  • CommandTimeout
    • Type: System.TimeSpan
    • Maximum waiting time for each team

My code

 InternetExplorerOptions options = new InternetExplorerOptions(); IWebDriver driver = new InternetExplorerDriver("C:/Users/jeff/AppData/Local/Microsoft/WindowsApps", options, TimeSpan.FromSeconds(120)); 
+2
Nov 29 '16 at 0:20
source share

We faced a similar problem in our project. The problem had nothing to do with Selenium or our application. It was a timeout because the build server configuration for this project was due to expire after 5 minutes. But all our tests did not complete after 5 minutes, so the assembly was unsuccessful due to timeout errors.

We also had a problem with firefox-19, tests that were used for a random crash. Anyway, firefox-10 only worked for our selenium tests.

+1
Jul 22 '13 at 11:56 on
source share

Try this code:

  DesiredCapabilities caps = DesiredCapabilities.Firefox(); //set the timeout to 120 seconds IWebDriver driver = new RemoteWebDriver(new Uri("<app_url>"), caps, TimeSpan.FromSeconds(120)); 
+1
Sep 06 '13 at 11:23
source share

I had the same problem, but only on Firefox. It turns out that this may be due to when you use the Navigate navigation method, and it tries to interact with the page too quickly. Calling below code fix this for me in Navigate (I also recommend using it before FindElement):

 public void VerifyPageIsLoaded() { var pageLoaded = false; for (var i = 0; i < DefaultTimeout.Timeout.Seconds; i++) { Thread.Sleep(1000); if (WebDriver.ExecuteJavaScript<string>("return document.readyState").Equals("complete")) //jQuery.active might cause problems on some browser or browserstack so I commented it out //&& WebDriver.ExecuteJavaScript<bool>("return jQuery.active == 0").Equals(true)) { pageLoaded = true; break; } Thread.Sleep(1000); } if (!pageLoaded) { throw new Exception("Page was not with complete state)!"); } } 
+1
Mar 17 '17 at 15:12
source share
 public static IWebElement WaitForElementVisible(By selector, uint timeout = Config.DefaultTimeoutSec) { IWebDriver driver = Browser.Instance.Driver; if (timeout > 0) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout)); wait.Until(ExpectedConditions.ElementIsVisible(selector)); return driver.FindElement(selector); } else { // Search for element without timeout return driver.FindElement(selector); } } 

We use this to prevent the appearance of such elements, and it works like a charm.

There is also another version if the element may be there, but should not be visible.

Just use ExpectedConditions.ElementExists(selector) instead of ExpectedContitions.ElementIsVisible(selector)

edit: Browser.Instance.Driver is a class containing the built-in driver

0
Mar 03 '16 at 12:59 on
source share



All Articles