vendredi 30 octobre 2020

Selenium with chromium based app and Docker: Chrome failed to start: crashed (chrome not reachable)

Just did some Selenium tests with Java + Maven to run them on my Chromium based application, everything was great as long as I was using them on my PC with Windows 10 but when i try to run them in Docker container get such error:

Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 34013
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.657 s <<< FAILURE! - in com.me.seleniumtests.ProjectFlowTests
[ERROR] projectTest  Time elapsed: 3.625 s  <<< ERROR!
org.openqa.selenium.WebDriverException:
unknown error: Chrome failed to start: crashed
  (chrome not reachable)
  (The process started from chrome location app/app.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

Code:

System.setProperty("webdriver.chrome.driver", "src/main/resources/drivers/chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("app/app.exe");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-setuid-sandbox");
chromeOptions.addArguments("remote-debugging-port=9222");
ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);
chromeDriver.get("https://www.google.com/");

I'm using:

  1. Docker image with Open JDK 8, Maven 3.6 and Windows Server Core from here(link). Powershell command to run tests in Docker:

    docker run -it --rm --name selenium-tests -v "$(Get-Location):C:/Src" -w C:/Src csanchez/maven:3.6-openjdk-8-windowsservercore-1809 mvn test

  2. Desktop Application written with Chromium Based Framework, Chromium 71, Chrome Driver 2.46, JUnit 5.7.0, Selenium 3.141.

Tried with adding some flags with ChromeOptions, changing Chrome Driver. Read also about using docker run with --privilege command but can't do it with Windows container I think.

Aucun commentaire:

Enregistrer un commentaire