I'm running into an issue where Selenium Chrome Driver will hang the unit test process if the driver fails to initialize. See the below code. In this case the driver fails to initialize because the chrome version was updated. However this hangs the unit test process as the conhost and chrome instance are still running in the background. Anyone know how to get around this programmatically. This really becomes an issue on Azure Devops CI where DotNetCoreCLI@2 will not terminate if there are running processed spawned by dotnet test still running.
using System;
using System.Diagnostics;
using OpenQA.Selenium.Chrome;
namespace Tests.Fixtures
{
/// <summary>
/// Test fixture which provides Chrome web driver instance.
/// </summary>
public sealed class ChromeDriverFixture : IDisposable
{
public ChromeDriverFixture()
{
var chromeOptions = new ChromeOptions();
if (!Debugger.IsAttached)
{
chromeOptions.AddArguments("headless");
}
chromeOptions.AcceptInsecureCertificates = true;
Browser = new ChromeDriver(chromeOptions); //failure here hangs dotnet test
}
/// <summary>
/// Chrome web browser instance
/// </summary>
public ChromeDriver Browser { get; }
public void Dispose()
{
Browser?.Dispose();
}
}
}