1
votes

Now trying to run my Selenium tests, using Teamcity server. Server is installed locally. At this moment project in teamcity contains 3 steps:

  1. NuGet instaler.
  2. Step with Visual Studio as runner.
  3. Step with NUnit as runner.

At this moment, 1 and 2nd steps are successfully finished. The 3rd step fails with next record in log:

 [Step 3/3] Volvo.DigitalCommerce.AutomatedTests.dll (9m:11s)
[15:02:26][Volvo.DigitalCommerce.AutomatedTests.dll] Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow on Chrome (1m:01s)
[15:03:28][Step 3/3] Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 6915
[15:03:28][Step 3/3] Only local connections are allowed.
[15:03:28]
[Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow on Chrome] [Test Error Output]
-> warning: The previous ScenarioContext was already disposed.
[15:03:28]
[Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow on Chrome] TearDown method failed. Autofac.Core.DependencyResolutionException : An exception was thrown while invoking the constructor 'Void .ctor()' on type 'ChromeDriver'. ---> The HTTP request to the remote WebDriver server for URL http://localhost:6896/session timed out after 60 seconds. (See inner exception for details.)
  ----> OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:6896/session timed out after 60 seconds.
  ----> System.Net.WebException : The request was aborted: The operation has timed out.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
[15:03:28]
[Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow on Chrome] TearDown method failed. Autofac.Core.DependencyResolutionException : An exception was thrown while invoking the constructor 'Void .ctor()' on type 'ChromeDriver'. ---> The HTTP request to the remote WebDriver server for URL http://localhost:6896/session timed out after 60 seconds. (See inner exception for details.)
  ----> OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:6896/session timed out after 60 seconds.
  ----> System.Net.WebException : The request was aborted: The operation has timed out.
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Container.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.ResolveNamed[TService](IComponentContext context, String serviceName, IEnumerable`1 parameters)
   at Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow(String browser) in C:\TeamCity\buildAgent\work\d7512e1031e4b296\Volvo.DigitalCommerce.AutomatedTests\Features\Child Seat\CS_BaseFlow.feature.cs:line 0
--WebDriverException
   at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   at lambda_method(Closure , Object[] )
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
--WebException
   at System.Net.HttpWebRequest.GetResponse()
   at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
--TearDown
   at Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.ScenarioTearDown() in C:\TeamCity\buildAgent\work\d7512e1031e4b296\Volvo.DigitalCommerce.AutomatedTests\Features\Child Seat\CS_BaseFlow.feature.cs:line 0
[15:03:28][Volvo.DigitalCommerce.AutomatedTests.dll] Volvo.DigitalCommerce.AutomatedTests.Features.DigitalCommerce.FullFlowTestFeature.DC_FullFlow on Chrome (1m:01s)

Can anyone help with this mistake? Thanks in advance, Valentin.

1

1 Answers

2
votes

Our Automated Test Suite was failing for the same reason and after trying multiple solutions for a few hours yesterday, our team traced this issue to the fact that the Teamcity Build Agent Service: was running under the System Account. This shouldn't normally be an issue but in our case, Chrome was failing to run / open when run under the local system account.

This proved to be the issue when we manually ran NUnit on our CI server and did not experience the issue.

After updating the service to use a new user account (password never expires, cannot login)

And added the new user under the security settings for each of the folders that our build references (unless you make it an administrator), the Chromedriver was able to initialize properly and the suite runs normally.

We still don't know the root issue of why Chrome was failing to initialize while running under the local system account, but we are guessing that it has to do with Chrome requiring some folder or files that only user accounts have (Desktop, App_Data etc...)