当前位置: 首页 > 编程语言 > C#

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

时间:2023-04-10 12:03:40 C#

C#学习教程:无法在Teamcity上启动c#+SeleniumWebDriver+Specflow+Nunit测试服务器安装在本地。此时TeamCity中的项目包含3个步骤:NuGet安装程序。使用VisualStudio作为运行器。以NUnit作为跑步者。至此,步骤1和2成功完成。第3步失败,日志中有下一条记录:[Step3/3]Volvo.DigitalCommerce.AutomatedTests.dll(9m:11s)[15:02:26][Volvo.DigitalCommerce.AutomatedTests.dll]Volvo.DigitalCommerce.Chrome上的AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow(1m:01s)[15:03:28][步骤3/3]在端口6915上启动ChromeDriver2.21.371459(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4)[步骤18][28]/3]只允许本地连接。[15:03:28][Chrome上的Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow][测试错误输出]->警告:先前的ScenarioContext已被处理。[15:03:28][Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlowonChrome]TearDown方法失败。Autofac.Core.DependencyResolutionException:在类型“ChromeDriver”上调用构造函数“Void.ctor()”时抛出异常。--->对远程WebDriver的HTTP请求URLhttp://localhost:6896/session的服务器在60秒后超时。(有关详细信息,请参阅内部异常。)---->OpenQA.Selenium.WebDriverException:对URLhttp://localhost:6896/session的远程WebDriver服务器的HTTP请求在60秒后超时。---->System.Net.WebException:请求已中止:操作已超时。TearDown:System.NullReferenceException:未将对象引用设置为对象的实例。[15:03:28][Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlowonChrome]TearDown方法失败。Autofac.Core.DependencyResolutionException:在类型“ChromeDriver”上调用构造函数“Void.ctor()”时抛出异常。--->对URLhttp://localhost:6896/session的远程WebDriver服务器的HTTP请求在60秒后超时。(有关详细信息,请参阅内部异常。)---->OpenQA.Selenium.WebDriverException:HTTP请求toURLhttp://localhost:6896/session的远程WebDriver服务器在60秒后超时。---->System.Net.WebException:请求已中止:操作已超时。TearDown:System.NullReferenceException:未将对象引用设置为对象的实例。在Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()在Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext上下文,IEnumerable`1参数)在Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1参数)在Autofac.Core.Resolving.InstanceLookup.Execute()在Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScopecurrentOperationScope,IComponentRegistration注册,IEnumerable`1参数)在Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration注册,IEnumerable`1个参数)在Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ICAutofac.Core.Container.ResolveComponent(IComponentRegistration注册,IEnumerable`1参数)在Autofac.ResolutionExtensions.TryResolveService(IComponentContext上下文,服务服务,IEnumerable`1参数,对象和实例)在Autofac.ResolutionExtensionsAutofac.ResolutionExtensions.ResolveNamed[TService](IComponentContext上下文,字符串服务名称,IEnumerable`1参数)在Volvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.CS_GoingThroughFullFlow(字符串浏览器)在C:TeamCitybuildAgentworkd7512e1031e4b296Volvo.DigitalCommerce.AutomatedTestsFeaturesChildSeatCS_BaseFlow.feature.cs:line0--WebDriverException在OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest请求)在OpenQA.Selenium.ExtecutpComman.HndcommandToExecute)在OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(CommandcommandToExecute)在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(StringdriverCommandToExecute,Dictionary`2参数)在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilitiesdesiredCapabilities)在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutorcommandExecutor,ICapabilitiesdesiredCapabilities)在OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptionsoptions)在lambda_method(Closure,Object[])在Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()--WebExceptionatSystem.Net.HttpWebRequest.GetResponse()atOpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequestrequest)--TearDownatVolvo.DigitalCommerce.AutomatedTests.Features.ChildSeat.CS_BaseFlowFeature.ScenarioTearDown()在C:TeamCitybuildAgentworkd7512e1031e4b296Volvo.DigitalCommerce.AutomatedTestsFeaturesChildSeatCS_BaseFlow.feature.cs:line0[15:03:28][Volvo.DigitalCommerce.AutomatedTests.dll]Volvo.DigitalCommerce.AutomatedTests.Features.DigitalCommerce.FullFlowTestFeature.DC_FullFlowonChrome(1m:01s)谁能帮助解决这个错误?提前致谢,Valentin我们的自动化测试套件由于同样的原因而失败,在昨天尝试了几种解决方案之后,我们的团队将问题追溯到TeamcityBuildAgent服务:事实上它是在系统帐户下运行的。这通常不是问题,但在我们的例子中,Chrome在本地系统帐户下运行时没有运行/打开。当我们在CI服务器上手动运行NUnit并且没有遇到任何问题时,这被证明是一个问题。使用新用户帐户更新服务后(密码永不过期,无法登录)并在我们构建引用的每个文件夹的安全设置下添加新用户(除非您将其设置为管理员),Chromedriver正确初始化并套件运行正常。我们仍然不知道Chrome在本地系统帐户下运行时无法初始化的根本问题,但我们猜测它与Chrome需要一些只有用户帐户的文件夹或文件有关(Desktop,App_Data,etc...):无法在Teamcity上启动c#+SeleniumWebDriver+Specflow+Nunit来测试和共享所有内容。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: