无法在 Teamcity 上启动 c#+SeleniumWebDriver+Specflow +Nunit 测试



现在尝试使用Teamcity服务器运行Selenium测试。服务器安装在本地。目前teamcity中的项目包含3个步骤:

  1. NuGet安装程序
  2. 以Visual Studio为跑步者
  3. 以NUnit为跑步者

此时,第1步和第2步已成功完成。第三步失败,日志中有下一条记录:

[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:TeamCitybuildAgentworkd7512e1031e4b296Volvo.DigitalCommerce.AutomatedTestsFeaturesChild SeatCS_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:TeamCitybuildAgentworkd7512e1031e4b296Volvo.DigitalCommerce.AutomatedTestsFeaturesChild SeatCS_BaseFlow.feature.cs:line 0
[15:03:28][Volvo.DigitalCommerce.AutomatedTests.dll] Volvo.DigitalCommerce.AutomatedTests.Features.DigitalCommerce.FullFlowTestFeature.DC_FullFlow on Chrome (1m:01s)

有人能帮我纠正这个错误吗?提前感谢,Valentin。

我们的自动化测试套件由于同样的原因失败,在昨天尝试了几个小时的多个解决方案后,我们的团队将此问题归因于Teamcity Build Agent Service:在系统帐户下运行。这通常不应该是一个问题,但在我们的案例中,Chrome在本地系统帐户下运行时无法运行/打开。

事实证明,当我们在CI服务器上手动运行NUnit时,并没有遇到这个问题。

更新服务后使用新的用户帐户(密码永远不会过期,无法登录)

并在我们的构建引用的每个文件夹的安全设置下添加了新用户(除非你让它成为管理员),Chromedriver能够正确初始化,套件正常运行。

我们仍然不知道Chrome在本地系统帐户下运行时未能初始化的根本问题,但我们猜测这与Chrome需要一些只有用户帐户才能拥有的文件夹或文件有关(桌面、应用程序数据等)

相关内容

  • 没有找到相关文章

最新更新