Селен: Chrome недоступен после выполнения некоторых шагов моей функции specflow - PullRequest
1 голос
/ 04 мая 2020

Я запускаю тесты пользовательского интерфейса на собственном агенте Windows 10 в Azure DevOps. Тест начинает работать нормально, но после определенных шагов я начинаю получать ошибку «Chrome недоступен». Я не уверен, почему это происходит. Меня озадачивает то, что, когда я запускаю одни и те же тесты на моем старом Windows 2012 самодостаточном агенте, они работают нормально.

Оба они имеют одинаковую версию Chrome и драйвер chrome объединяется с помощью nuget.

Это журналы, которые я получаю

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()

1 Ответ

0 голосов
/ 05 мая 2020

Вы можете определить точную причину этой проблемы, добавив опцию видеомагнитофона. Создайте файл с именем 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>

Вы можете включить опцию видеозаписи и указать на этот файл из задачи, заданной в конвейере, который запускает тест

...