+3 votes
1 view
in Devops and Agile by (19.8k points)

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 web driver 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. As I said, this has been running fine for months previously, and the only thing that has changed is the selenium web driver kit.

I have experienced this problem before, whilst in debug, and when 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 web driver source? I'd like to not go down that route if possible if anyone else can offer any suggestions. 

5 Answers

+3 votes
by (63.4k points)
selected by
 
Best answer

First thing you should look at how your browsers are closing. I doubt that your browser instances on the Continuous Integration server are not getting closed.

Also, use the Grid tool in case, if you have not done yet.  The load will be distributed and will result in more stable tests.

And also you should look at your perfmonitor(The Microsoft Windows Performance Monitor is a tool that administrators can use to examine how programs running on their computers affect the computer's performance. The tool can be used in real-time and also be used to collect information in a log to analyze the data at a later time.) and see if there are any existing chromedriver.exe process running. Too many of those processes will slowdown execution and you may encounter the error above.

Clean up your %temp% folder and restart your CI server once.

Learn Selenium with the help of this Selenium Tutorial by Intellipaat.

by (19.8k points)
Thanks, there was an existing chromedriver.exe process running, we removed it and now the code works perfectly fine.
by (33.2k points)
Thanks, It worked for me.
by (47.2k points)
This solved my problem. I was unable to run chrome tests anymore after months of not trying them
by (28.1k points)
This worked for me
+2 votes
by (92.8k points)

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

launch your browser utilizing the above lines of code. It worked for me.

by (44.6k points)
Addin this line made it again work in a hosted environment after it was failing
+1 vote
by (16.3k points)

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.

+1 vote
by (29.8k points)

 I was able to fix a similar issue by adding the "no-sandbox" flag to the Chrome options:

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

0 votes
by (107k points)

To fix the Selenium Error - The HTTP request to the remote WebDriver timed out after 60 seconds the new FirefoxDriver(binary, profile, timeSpan) has been obsolete.

You can now use the below-mentioned piece of code:-

new FirefoxDriver(FirefoxDriverService.CreateDefaultService(), FirefoxOptions options, TimeSpan commandTimeout)

There is another method to solve this problem which is as follows:-

new FirefoxDriver(string geckoDriverDirectory, FirefoxOptions options, TimeSpan commandTimeout) 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...