1

I am trying to run a headless Chrome browser in a Docker container using a Docker file but is giving crash issue whenever it tries to execute the Automation script using it.

I have tried changing the Chrome driver version to 75 and 76 and gave issue with the Chrome browser version.

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-setuid-sandbox");
chromeOptions.addArguments("disable-infobars");
chromeOptions.addArguments("--disable-extensions");
Boris
  • 22,667
  • 16
  • 50
  • 71
Anand
  • 51
  • 1
  • 4
  • Please add the stack trace to the question. – Boris Oct 23 '19 at 16:13
  • I am currently trying it with Chrome driver version 78.0.3904.11 and it gave me the above error Unable to load browser: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) – Anand Oct 23 '19 at 16:15
  • Did you try --disable-gpu? – Arik Oct 23 '19 at 16:17
  • Yes I did and after some research over the internet it turned out that it holds true only in the case of Windows machines, whereas for Docker I am using Linux machine. – Anand Oct 23 '19 at 16:18
  • Have you checked this [question](https://stackoverflow.com/questions/50642308/webdriverexception-unknown-error-devtoolsactiveport-file-doesnt-exist-while-t)? – Boris Oct 23 '19 at 16:27
  • Do those steps mentioned work for Linux OS as well in a Docker image? – Anand Oct 23 '19 at 16:31
  • Don't know, please try it yourself. – Boris Oct 23 '19 at 16:33
  • It did not work in my case, still seeing the same error. – Anand Oct 23 '19 at 16:35

2 Answers2

4

https://hub.docker.com/r/markhobson/maven-chrome/

I used this image from Docker Hub and it is now working for me.

Thank you, all for your valuable inputs, they were helpful.

Anand
  • 51
  • 1
  • 4
0

Use chrome browser 74 and use chromedriver version as 74.0.3729.6. Seems like some issue with latest chrome driver version

  • Okay, but do I add a specific version on Chrome browser as Chrome does not allow doing that. It updates automatically – Anand Oct 24 '19 at 04:07
  • Try to install unstable chrome 74 version. Use below command for installation `apt-get update apt-get install wget wget http://dl.google.com/linux/deb/pool/main/g/google-chrome-unstable/google-chrome-unstable_74.0.3729.6-1_amd64.deb apt-get install -f ./google-chrome-unstable_74.0.3729.6-1_amd64.deb` – Harjinder Singh Oct 24 '19 at 08:02
  • It is failing with this error The command '/bin/sh -c apt-get install -f ./google-chrome-unstable_74.0.3729.6-1_amd64.deb' returned a non-zero code: 1 – Anand Oct 24 '19 at 10:23
  • @Anand, use `dpkg -i google-chrome-unstable_74.0.3729.6-1_amd64.deb` to install – Rada Bogdan Nov 20 '19 at 15:22