10

I am running selenium tests in C# and every now and then I get this error while initiating or running my tests:

The HTTP request to the remote WebDriver server for
http://localhost:7055/xxxxx timed out after 60 seconds.

This occurs when instantiating the firefox driver when running my test suite:

  var driver = new FirefoxDriver();  

I have seen seen some threads on it (like this https://stackoverflow.com/questions/22322596/) but that was from over a year ago. Does anyone know of any workaround or solution to this intermittent problem?

4
  • does it timeout while you watch the test running or is this only when using a build server?
    – ECiurleo
    Jun 5, 2015 at 9:21
  • This is occurring when I run tests locally
    – GKS1
    Jun 8, 2015 at 15:02
  • Need some more information to help you with this one: What browser are you using? and can you place any code into the initial question? this will give us a better idea of what you are seeing.
    – DEnumber50
    Jun 11, 2015 at 16:08
  • I am using a firefox driver in C#. The problem usually occurs when I am running a large number of tests. It happens on the firefox driver instantiation:
    – GKS1
    Jun 11, 2015 at 16:59

2 Answers 2

2

Instead of simple new FirefoxDriver(); try

new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), TimeSpan.FromSeconds(180));
0

I had the same issue as well but only on Firefox driver. Turns out it might be related to when you use the driver Navigate method and it tries to interact too fast with the page. Calling below code fix it for me on Navigate (I also recommend to use it before FindElement as well):

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.