在 CodeFresh 中运行冒烟测试时,我们偶尔会收到此错误
[xUnit.net 00:02:41.43] OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: exited abnormally.
[xUnit.net 00:02:41.43] (unknown error: DevToolsActivePort file doesn't exist)
[xUnit.net 00:02:41.43] (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
[xUnit.net 00:02:41.43] Stack Trace:
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
[xUnit.net 00:02:41.43] at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
[xUnit.net 00:02:41.43] /src/Features/Helpers/Hooks.cs(32,0): at Live_Automation.Features.Helpers.Hooks.BeforeScenario()
[xUnit.net 00:02:41.43] at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
[xUnit.net 00:02:41.43] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
[xUnit.net 00:02:41.43] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
[xUnit.net 00:02:41.43] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart()
[xUnit.net 00:02:41.43] at TechTalk.SpecFlow.TestRunner.OnScenarioStart()
[xUnit.net 00:02:41.43] at Live_Automation.Features.SmokeTestsOnLiveFeature.ScenarioStart()
这在 10 次测试中平均发生 1 次,通常只是一种情况,如下所示
Test Run Failed.
Total tests: 52
Passed: 51
Failed: 1
失败的测试是随机的,因为这可能发生在一天中的时间。测试套件围绕 Visual Studio/C#/Selenium/Xunit 构建
在更罕见的情况下,我们得到这个
[xUnit.net 00:03:26.88] OpenQA.Selenium.WebDriverException : unknown error: session deleted because of page crash
[xUnit.net 00:03:26.88] from unknown error: cannot determine loading status
[xUnit.net 00:03:26.88] from tab crashed
[xUnit.net 00:03:26.88] (Session info: headless chrome=87.0.4280.141)
[xUnit.net 00:03:26.88] Stack Trace:
[xUnit.net 00:03:26.88] at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
[xUnit.net 00:03:26.88] at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
[xUnit.net 00:03:26.88] at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
[xUnit.net 00:03:26.88] at OpenQA.Selenium.Remote.RemoteNavigator.GoToUrl(String url)
[xUnit.net 00:03:26.88] /src/Features/Pages/HomePage.cs(61,0): at Live_Automation.Features.Pages.HomePage.Visit()
[xUnit.net 00:03:26.88] at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
[xUnit.net 00:03:26.88] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments)
[xUnit.net 00:03:26.88] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
[xUnit.net 00:03:26.88] at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
[xUnit.net 00:03:26.88] at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
[xUnit.net 00:03:26.88] at Live_Automation.Features.SmokeTestsOnLiveFeature.ScenarioCleanup()
[xUnit.net 00:03:26.88] /src/Features/SmokeTests.feature(80,0): at Live_Automation.Features.SmokeTestsOnLiveFeature.TestFooterOptions(String footer, String url, String[] exampleTags)
现在,当这种情况发生时,从这一点开始的所有场景都将失败有没有人对造成这种情况的原因有任何想法。我不认为这是测试。
提前致谢
凯夫