我正在Azure DevOps中的Windows 10自托管代理上运行UI测试。测试开始工作正常,但是经过某些步骤后,我开始出现“ Chrome无法访问”错误。我不确定为什么会这样。让我感到困惑的是,当我在旧的Windows 2012自托管代理上运行相同的测试时,它们运行良好。
它们两个都具有相同版本的Chrome,并且使用nuget捆绑了chrome驱动程序。
这是我收到的日志
A total of 1 test files matched the specified pattern.
Starting ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}) on port 62049
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Starting ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}) on port 62156
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
X DismissAnAlert("North",null) [39s 791ms]
Standard Output Messages:
C:\vstsagent\A4\_work\r5\a\_MyProject Automation UI Tests\AutomationTests
When I select a specific "North" area and click on go to Alerts
-> done: SelectMonitoringAreasSteps.WhenISelectASpecificAreaAndClickOnGoToAlerts("North") (3.8s)
And I click on the first alert to view
-> done: AlertsSteps.WhenIClickOnTheFirstAlertToView() (3.3s)
Then I should see options to convert or dismiss an alert are displayed
-> error: chrome not reachable
(Session info: chrome=81.0.4044.129)
When I select option to "dismiss" an incident
-> skipped because of previous errors
Then I should see warning message as "Are you sure you want to dismiss this alert"
-> skipped because of previous errors
When I click on Dismiss alert button
-> skipped because of previous errors
Then the alert should be dismissed and should be disappeared from map and alert queue
-> skipped because of previous errors
And I should see that dismissed alert has been audited in the audit log table
-> skipped because of previous errors
Error Message:
OpenQA.Selenium.WebDriverException : chrome not reachable
(Session info: chrome=81.0.4044.129)
TearDown : OpenQA.Selenium.WebDriverException : chrome not reachable
(Session info: chrome=81.0.4044.129)
Stack Trace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector(String cssSelector)
at OpenQA.Selenium.By.<>c__DisplayClass23_0.<CssSelector>b__0(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at MyCompanyMyProject.Automation.Tests.Pages.AlertsPage.get_AlertMonitoringAreaElement() in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\Pages\AlertsPage.cs:line 28
at MyCompanyMyProject.Automation.Tests.Pages.AlertsPage.GetAlertCardDetails() in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\Pages\AlertsPage.cs:line 53
at MyCompanyMyProject.Automation.Tests.Steps.AlertsSteps.ThenIShouldSeeOptionsToConvertOrDismissAnAlertAreDisplayed() in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\Steps\AlertsSteps.cs:line 125
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
at MyCompanyMyProject.Automation.Tests.TestFeatures.DismissAlertFeature.ScenarioCleanup()
at MyCompanyMyProject.Automation.Tests.TestFeatures.DismissAlertFeature.DismissAnAlert(String monitoring, String[] exampleTags) in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\TestFeatures\DismissAlert.feature:line 14
--TearDown
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.GetScreenshot()
at MyCompanyMyProject.Automation.Tests.Steps.Initialiser.TakeScreenshot(IWebDriver driver) in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\Steps\Initialiser.cs:line 131
at MyCompanyMyProject.Automation.Tests.Steps.Initialiser.CloseDriver() in c:\vstsagent\A3\_work\16\s\MyCompanyMyProject.Automation.Tests\MyCompanyMyProject.Automation.Tests\Steps\Initialiser.cs:line 86
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 MyCompanyMyProject.Automation.Tests.TestFeatures.DismissAlertFeature.TestTearDown()
您可以通过添加录像机选项来确定此问题的确切原因。创建一个名为webapp.runsettings
的文件<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="Screen and Voice Recorder">
<!--Video data collector was introduced in Visual Studio 2017 version 15.5 -->
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
您可以启用视频录制选项,并可以从运行测试的管道中给定的任务指向此文件