Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenQA.Selenium.WebDriverException : A exception with a null response was thrown and halts the selenium test run

Tags:

c#

selenium

I am using firefox webdriver running firefox 41.0.2 Nunit 3.4.1 selenium 2.47.0 specflow 2.1.0 My tests run in parallel.

Passed couple days my tests have been failing to complete while running through jenkins, the run gets stuck on a process and cannot continue with the rest of the run. I have intermittently been able to reproduce the error locally when running 20+ scenarios. I am getting the below exception, has anyone seen this issue before?

OpenQA.Selenium.WebDriverException : A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:7056/hub/session/d0a83b9c-bd79-4218-8eac-dc8b273f8f40/element/%7B84966a91-06c4-42dd-98c0-278ed35e3667%7D/attribute/value.

The status of the exception was ConnectFailure, and the message was: Unable to connect to the remote server ----> System.Net.WebException : Unable to connect to the remote server ----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it 127.0.0.1:7056

+++++++++++++++++++ STACK TRACE: at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) at OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.GetAttribute(String attributeName) at TeamHours.Automation.StandAlone.WebComponents.Pages.WeeklySalesForecastPage.<Save>b__0(IWebElement s) in c:\Program Files (x86)\Jenkins\jobs\Automation Build Develop\workspace\TeamHours.Automation.StandAlone.WebComponents\Pages\WeeklySalesForecastPage.cs:line 38 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate) at TeamHours.Automation.StandAlone.WebComponents.Pages.WeeklySalesForecastPage.Save() in c:\Program Files (x86)\Jenkins\jobs\Automation Build Develop\workspace\TeamHours.Automation.StandAlone.WebComponents\Pages\WeeklySalesForecastPage.cs:line 39 at TeamHours.Automation.StandAlone.CommonSteps.Steps.SalesForecast.WeeklySalesForecastGraphsSteps.WhenISaveTheForecast() in c:\Program Files (x86)\Jenkins\jobs\Automation Build Develop\workspace\TeamHours.Automation.StandAlone.CommonSteps\Steps\SalesForecast\WeeklySalesForecastGraphsSteps.cs:line 73 at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(StepInstance stepInstance) at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() at TeamHours.Automation.StandAlone.RegresionTests.Features.Schedule.ScheduleGraphFeature.ScenarioCleanup() in c:\Program Files (x86)\Jenkins\jobs\Automation Build Develop\workspace\TeamHours.Automation.StandAlone.RegresionTests\Features\Schedule\ScheduleGraph.feature.cs:line 0 at TeamHours.Automation.StandAlone.RegresionTests.Features.Schedule.ScheduleGraphFeature.VerifyScheduleGraphShowsCorrectPeopleAndOverstaffedWhenDemandIsExceeded(String role, String tab, String link, String noOfItems, String peopleRequired, String itemsOrSales, String tab2, String view, String total, String tab3, String type1, String type2, String type3, String[] exampleTags) in c:\Program Files (x86)\Jenkins\jobs\Automation Build Develop\workspace\TeamHours.Automation.StandAlone.RegresionTests\Features\Schedule\ScheduleGraph.feature:line 133 --WebException at System.Net.HttpWebRequest.GetResponse() at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request) --SocketException at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

like image 617
Brett Avatar asked Sep 14 '16 09:09

Brett


3 Answers

We found this issue could be related to TCP ports being exhausted on the host machine. There is other material out there about this but basically the web driver exhausts all the ports where they get stuck in a waiting state due to the driver polling the OS for an available port. The fix involved modifying the registry to either increase the number of available ports or decrease the amount of time they are in the waiting state.

like image 68
Daniel Kereama Avatar answered Oct 20 '22 14:10

Daniel Kereama


This Issue may Occurs unreachable of your launched port. So that your Browser Window got Closed, In this case Each Testcase refer the QuitDriver instead of Next Test Case, the quit driver must triggered after completing the testsuite. In Selenium we need to use [OneTimeTearDown] instead of [TearDown]..

like image 2
Ram Avatar answered Oct 20 '22 15:10

Ram


When I've had this error, and the answer has always been "update the ****driver.exe". In my case ChromeDriver.exe, in your case it's probably the FireFoxDriver.exe

like image 1
LawrenceF Avatar answered Oct 20 '22 14:10

LawrenceF