在TeamCity的无法启动C#+ SeleniumWebDriver + Specflow + NUnit的测试 [英] Can't start c#+SeleniumWebDriver+Specflow+Nunit tests on Teamcity

查看:875
本文介绍了在TeamCity的无法启动C#+ SeleniumWebDriver + Specflow + NUnit的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在想经营我的Selenium测试,使用的TeamCity服务器。服务器安装在本地。
在TeamCity的这一刻项目包含3个步骤:

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. 与Visual Studio的亚军步骤。

  3. 步骤与NUnit的为亚军。

在这一刻,1和2的步骤成功完成。
中的第三步失败,并在日志中记录下一个:

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.

推荐答案

我们的自动化测试套件是失败出于同样的原因,并几个小时试图昨天多种解决方案后,我们的团队跟踪这个问题的事实, TeamCity的生成代理服务的:该系统帐户下运行。这通常不应是一个问题,但对我们来说,Chrome的失败当在本地系统帐户下运行运行/打开。

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.

这被证明是问题,当我们手动运行我们的CI服务器上NUnit的,并没有遇到问题。

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)

和下每一个我们构建的参考(除非你让一个管理员文件夹)的安全设置添加新用户时,Chromedriver能够正确初始化而该套件运行正常。

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.

我们仍然不知道为什么Chrome的失败,而在本地系统帐户下运行初始化的根源问题,但我们猜测,它与Chrome浏览器需要做一些文件夹或文件,只有用户帐户具有(桌面,程序App_Data等)

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...)

这篇关于在TeamCity的无法启动C#+ SeleniumWebDriver + Specflow + NUnit的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆