【发布时间】:2020-06-23 16:36:30
【问题描述】:
对 selenium chromedriver 有疑问。我在 AzureDevops CI 上运行了一些测试。一些随机数量的测试失败,但有异常:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:50080/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out.
端口号每次都是随机的。
下面是启动chrome的代码:
var chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--headless");
driver = new ChromeDriver(chromeOptions);
没什么特别的,但由于某种原因,测试仍然失败。在我的本地电脑上运行稳定,在 CI 运行期间出现问题
这是完整的堆栈跟踪:
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
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(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
at ClickBrainAutomation.Common.ConditionsHook.SetUp() in C:\agent_pool\agent_0\_work\610\s\ClickBrainAutomation\Common\ConditionsHook.cs:line 82
at TechTalk.SpecFlow.Bindings.SynchronousBindingDelegateInvoker.<>c__DisplayClass2_0.<<InvokeBindingDelegateAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at TechTalk.SpecFlow.Bindings.AsyncHelpers.<>c__DisplayClass1_0`1.<<RunSync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at TechTalk.SpecFlow.Bindings.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop()
at TechTalk.SpecFlow.Bindings.AsyncHelpers.RunSync[T](Func`1 task)
at TechTalk.SpecFlow.Bindings.SynchronousBindingDelegateInvoker.InvokeBindingDelegateAsync(Delegate bindingDelegate, Object[] invokeArgs)
at TechTalk.SpecFlow.Bindings.SynchronousBindingDelegateInvoker.InvokeDelegateSynchronously(Delegate bindingDelegate, Object[] invokeArgs)
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart()
at TechTalk.SpecFlow.TestRunner.OnScenarioStart()
at ClickBrainAutomation.Features.AdFeature.ScenarioStart()
at ClickBrainAutomation.Features.AdFeature.AdStatusesLifecycle() in C:\agent_pool\agent_0\_work\610\s\ClickBrainAutomation\Features\AdsFeature.feature:line 145
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--TearDown
at ClickBrainAutomation.Common.ConditionsHook.AfterScenario() in C:\agent_pool\agent_0\_work\610\s\ClickBrainAutomation\Common\ConditionsHook.cs:line 95
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
at TechTalk.SpecFlow.TestRunner.OnScenarioEnd()
at ClickBrainAutomation.Features.AdFeature.TestTearDown()
【问题讨论】:
标签: selenium azure-devops selenium-chromedriver