I am getting the following error when running selenium c# tests on docker windows. Could anyone help me on this. Thank you
OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
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 SeleniumCore.Core.Chrome.Initialize() in C:\src\SeleniumCore\Core\Chrome.cs:line 58
The code which initializes the chrome is shown below:
public class Chrome : IBrowser
{
public RemoteWebDriver MainDriver { get; private set; }
private readonly bool Headless;
public Chrome(AppConfigContext context)
{
Headless = context.Headless;
}
/// <summary>
/// Initialize Chrome Browser Instance.
/// </summary>
public void Initialize()
{
ChromeOptions options = new ChromeOptions();
if (Headless)
options.AddArgument("headless");
options.AddArgument("--disable-gpu");
options.AddArgument("--no-sandbox");
options.AddArguments("--disable-dev-shm-usage");
var downloadPath = Controls.DataFilePath + @"Downloads";
Controls.CreateDirectory(downloadPath);
options.AddUserProfilePreference("download.default_directory", downloadPath);
options.AddUserProfilePreference("download.prompt_for_download", false);
options.AddUserProfilePreference("disable-popup-blocking", "true");
RemoteWebDriver driver = new ChromeDriver(@"C:\Chromedrivers\new",options);
MainDriver = driver;
The docker info which I am using :
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.7.1)
compose: Docker Compose (Docker Inc., v2.2.1)
scan: Docker Scan (Docker Inc., v0.14.0)
Server:
Containers: 5
Running: 0
Paused: 0
Stopped: 5
Images: 50
Server Version: 20.10.11
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics internal l2bridge l2tunnel nat null overlay private transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 19042 (19041.1.amd64fre.vb_release.191206-1406)
Operating System: Windows 10 Pro Version 2009 (OS Build 19042.1466)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 7.886GiB
Name:
DESKTOP-QCTUL51
ID: 4YUB:HKPT:WGDP:V3JZ:X255:CHSR:5TTA:FPA2:4JBN:GUTW:PAQZ:I6W6
Docker Root Dir: C:\ProgramData\Docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine