Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds

122,358

Solution 1

I had a similar issue using the Chrome driver (v2.23) / running the tests thru TeamCity. I was able to fix the issue by adding the "no-sandbox" flag to the Chrome options:

var options = new ChromeOptions();
options.AddArgument("no-sandbox");

I'm not sure if there is a similar option for the FF driver. From what I understand the issue has something to do with TeamCity running Selenium under the SYSTEM account.

Solution 2

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

Launch your browser using the above lines of code. It worked for me.

Solution 3

I first encountered this issue months ago (also on the click() command), and it has been an issue for me ever since. It seems to be some sort of problem with the .NET Selenium bindings. This blog post by the guy that works on the IE driver is helpful in explaining what's happening:

http://jimevansmusic.blogspot.com/2012/11/net-bindings-whaddaymean-no-response.html

Unfortunately, there doesn't seem to be a real solution to this problem. Whenever this issue has been raised to the Selenium developers (see here), this is a typical response:

We need a reproducible scenario, that must include a sample page or a link to a public site's page where the issue can be reproduced.

If you are able to submit a consistently reproducible test case, that could be very helpful in putting this bug to rest for good.

That said, perhaps you can try this workaround in the meantime. If the HTML button that you are trying to click() has an onclick attribute which contains Javascript, consider using a JavascriptExecutor to execute that code directly, rather than calling the click() command. I found that executing the onclick Javascript directly allows some of my tests to pass.

Solution 4

Had same issue with Firefox. I switched over to Chrome with options and all has been fine since.

ChromeOptions options = new ChromeOptions();
options.AddArgument("no-sandbox");

ChromeDriver driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromMinutes(3));
driver.Manage().Timeouts().PageLoad.Add(System.TimeSpan.FromSeconds(30));

Solution 5

In my case, it's because I deleted the chrome update folder. After chrome reinstall, it's working fine.

Share:
122,358
Admin
Author by

Admin

Updated on January 19, 2022

Comments

  • Admin
    Admin over 2 years

    I've been using Selenium for a number of months, which we're using to automate some of our internal testing processes. The scripts have been passing fine. I've recently upgraded to C# 2.40.0 webdriver using FF 27.01 and our scripts are now failing in random places with the following error.

    [Portal.SmokeTest.SmokeRunTest.Booking] TearDown method failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/element timed out after 60 seconds.
      ----> System.Net.WebException : The operation has timed out
    TearDown : OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/window timed out after 60 seconds.
      ----> System.Net.WebException : The operation has timed out
    [09:01:20]
    [Portal.SmokeTest.SmokeRunTest.Booking] TearDown method failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/element timed out after 60 seconds.
      ----> System.Net.WebException : The operation has timed out
    TearDown : OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL htt(p)://localhost:7055/hub/session/56e99e88-ba17-4d12-bef1-c6a6367ccc2f/window timed out after 60 seconds.
      ----> System.Net.WebException : The operation has timed out
       at OpenQA.Selenium.Support.UI.DefaultWait`1.PropagateExceptionIfNotIgnored(Exception e)
       at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
       at Portal.Test.Helpers.Process_Bookings.OpenBookings.SelectBooking(String bookingnumber)
       at Portal.SmokeTest.SmokeRunTest.Booking() in d:\TeamCityAgent\work\dac1dcea7f2e80df\SmokeTests\SmokeRunTest.cs:line 68
    --WebException
       at System.Net.HttpWebRequest.GetResponse()
       at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
    --TearDown
       at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
       at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
       at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
       at OpenQA.Selenium.Remote.RemoteWebDriver.Close()
       at Portal.Test.Helpers.Setup.CloseWebdriver()
       at Portal.SmokeTest.SmokeRunTest.TearDown() in d:\TeamCityAgent\work\dac1dcea7f2e80df\SmokeTests\SmokeRunTest.cs:line 162
    --WebException
       at System.Net.HttpWebRequest.GetResponse()
       at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
    

    The latest error I've managed to track down to one single line of code:

    _setup.driver.FindElement(By.XPath("//button[@class='buttonSmall lockBookingButton']")).Click();
    

    The annoying thing is, trying to fix the problem is proving difficult, as if I run the test on my local machine, in debug it passes. Additionally, if I run it via the NUNIT runner on the build machine I'm running the test off, it also passes. It only seems to fail as part of our automated build running process when using Teamcity. Like I said, this has been running fine for months previously, and the only thing that has changed is the selenium webdriver kit.

    I have experienced this problem before, whilst in debug, and when a Click() line of code was called, Firefox appeared to lock up, and only stopping the test would allow Firefox to continue. There are a number of suggestions on here including modifying the webdriver source? I'd like to not go down that route if possible if anyone else can offer any suggestions.

  • Admin
    Admin about 10 years
    Hi, The retry option wont work as the browser just locks up. Only stopping the test enables the browser to continue.
  • Admin
    Admin about 10 years
    Hi there bewu, would that be in the format like the below? driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSecon‌​ds(5));
  • Bart Wojtala
    Bart Wojtala about 10 years
    No, not this wait ImplicitlyWait is connected with finding elements. You need to change default(60sec) driver timeout, when it waits for request to be proceed(if I'm not wrong). Anyway you have to find a line where you set FF driver's constructor and add there more attributes or change the timeout. Something like: driver = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(path to your profile), TimeSpan.FromMinutes(3));
  • redwards510
    redwards510 over 7 years
    for ChromeDriver it would look like driver = new ChromeDriver(service, chromeDriverOptions, TimeSpan.FromMinutes(3));
  • Etienne
    Etienne over 7 years
    this solve my problem as well. I was unable to run chrome tests anymore after months of not trying them. Thanks combatc2
  • KayakinKoder
    KayakinKoder almost 7 years
    Fixed for us as well. When running a basic script which just created a FF driver and nothing else, a 60 second timeout worked 100% of the time. When running our resource-heavy script, which opens connections to databases/reads/writes/does a lot more immediately before opening FF, a 60 timeout would cause failures ~50% of the time. Increasing the timeout to 3 minutes fixed the problem. Seems that Webdriver just needs a little more time to get the engine warmed up.
  • Legends
    Legends about 6 years
    My code was running fine in an IIS hosted env and stopped suddenly, but still worked in my unit tests. Adding this line made it work again in IIS env. Thanks!
  • moto_geek
    moto_geek about 5 years
    I delcared it as var options = new ChromeOptions(); options.AddArgument("--no-sandbox"); Working now in C# version Webdriver 3.14.
  • Madeline Ritchie
    Madeline Ritchie over 3 years
    I'm likely mistaken here, but it seems the last line there will have no effect. PageLoad is a TimeSpan itself, and .Add on TimeSpan is a pure function, which doesn't modify PageLoad it simply returns a new TimeSpan which is being discarded.
  • Shannon M
    Shannon M over 2 years
    Yes! I've been dealing with this issue for like 5 months, this worked! woohoooo
  • Reg Smith
    Reg Smith almost 2 years
    I just had this problem. Typically when a new version releases my tests will just outright fail and won't run because of an incompatible version but apparently running Chrome 101 with ChromeDriver 100 works but gave those errors intermittently. Such a silly mistake.
  • Reg Smith
    Reg Smith almost 2 years
    Aaand I was wrong. Still get that error after updating.