4

I have E2E tests running in a docker container. After Friday's update of selenium/node-chrome it would not work anymore. I have tried to use older versions of selenium/node-chrome but it won't work. I have very little experience with docker containers etc.

Google Chrome 80.0.3987.106 <- Info gotten running command google-chrome --version chromedriver-80.0.3987.106 <- Info gotten from /opt/selenium/ folder.

Here`s how my Dockerfile looks like:

FROM selenium/node-chrome:3.141.59
ENV NODE_VERSION 12.14.1

USER root

RUN apt-get -qqy update \
 && apt-get -qqy --no-install-recommends install xz-utils \
 && apt-get -qqy autoremove \
 && apt-get -qqy clean \
 && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
 && ARCH= \
 && dpkgArch="$(dpkg --print-architecture)" \
 && case "${dpkgArch##*-}" in \
    amd64) ARCH='x64';; \
    ppc64el) ARCH='ppc64le';; \
    s390x) ARCH='s390x';; \
    arm64) ARCH='arm64';; \
    armhf) ARCH='armv7l';; \
    i386) ARCH='x86';; \
    *) echo "unsupported architecture"; exit 1 ;; \
  esac \
  # gpg keys listed at https://github.com/nodejs/node#release-keys
  && set -ex \
  && for key in \
    94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
    FD3A5288F042B6850C66B31F09FE44734EB7990E \
    71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
    DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
    C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
    B9AE9905FFD7803F25714661B63B535A4C206CA9 \
    77984A986EBC2AA786BC0F66B01FBB92821C587A \
    8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
    4ED778F539E3634C779C87C6D7062848A1AB005C \
    A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
    B9E2F5981AA6E0CD28160D9FF13993A75599653C \
  ; do \
    gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
    gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
    gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
  done \
  && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
  && curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
  && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
  && grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
  && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
  && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
  && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
  && mkdir /src \
  && chown seluser /src

USER seluser

WORKDIR /src

COPY ./package-lock.json ./package.json ./
RUN npm install && \
  npm run wd:update

COPY . ./

CMD ["npm", "test"]

Build seems to go fine without any problems, but when trying to run tests I get the following error message:

    > protractor protractor.conf.js

[13:51:33] I/launcher - Running 1 instances of WebDriver
[13:51:33] I/local - Starting selenium standalone server...
[13:51:35] I/local - Selenium standalone server started at http://XXX.XX.X.X:51473/wd/hub
[13:51:36] E/launcher - unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '8bc3b606ae46', ip: 'XXX.XX.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_242'
Driver info: driver.version: unknown
remote stacktrace: #0 0x5584b6f867a9 <unknown>

[13:51:36] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '8bc3b606ae46', ip: 'XXX.XX.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_242'
Driver info: driver.version: unknown
remote stacktrace: #0 0x5584b6f867a9 <unknown>

    at Object.checkLegacyResponse (/src/node_modules/selenium-webdriver/lib/error.js:546:15)
    at parseHttpResponse (/src/node_modules/selenium-webdriver/lib/http.js:509:13)
    at /src/node_modules/selenium-webdriver/lib/http.js:441:30
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
From: Task: WebDriver.createSession()
    at Function.createSession (/src/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
    at Function.createSession (/src/node_modules/selenium-webdriver/chrome.js:761:15)
    at createDriver (/src/node_modules/selenium-webdriver/index.js:170:33)
    at Builder.build (/src/node_modules/selenium-webdriver/index.js:626:16)
    at Local.getNewDriver (/src/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
    at Runner.createBrowser (/src/node_modules/protractor/built/runner.js:195:43)
    at /src/node_modules/protractor/built/runner.js:339:29
    at _fulfilled (/src/node_modules/q/q.js:834:54)
    at /src/node_modules/q/q.js:863:30
    at Promise.promise.promiseDispatch (/src/node_modules/q/q.js:796:13)
[13:51:36] E/launcher - Process exited with error code 199
npm ERR! Test failed.  See above for more details.
4
  • Why isn't the chromedriver and chrome version available within the logs? Commented Feb 19, 2020 at 15:50
  • To be honest I have no idea. This way of running tests was not implemented by me. Commented Feb 19, 2020 at 16:00
  • Okay, programmatically or manually can you pull out the version information of ChromeDriver and Chrome, I suspect a mismatch Commented Feb 19, 2020 at 16:02
  • Google Chrome 80.0.3987.106 <- Info gotten running command google-chrome --version chromedriver-80.0.3987.106 <- Info gotten from /opt/selenium/ folder. Commented Feb 19, 2020 at 16:40

2 Answers 2

2

This error message...

[13:51:36] E/launcher - unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '8bc3b606ae46', ip: 'XXX.XX.X.X', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_242'
Driver info: driver.version: unknown
remote stacktrace: #0 0x5584b6f867a9 <unknown>

...implies that the ChromeDriver v80.0 was unable to initiate/spawn a new Browsing Context with in Docker image for Chrome (80.0).


As per the discussion WebDriver 80.0.3987.16 can't open Chrome on Linux @triciac mentioned that, the implementation of ChromeDriver v80.0 looks for Chrome in the following order:

  1. locations->push_back(base::FilePath("/usr/local/sbin"));
  2. locations->push_back(base::FilePath("/usr/local/bin"));
  3. locations->push_back(base::FilePath("/usr/sbin"));
  4. locations->push_back(base::FilePath("/usr/bin"));
  5. locations->push_back(base::FilePath("/sbin"));
  6. locations->push_back(base::FilePath("/bin"));
  7. locations->push_back(base::FilePath("/opt/google/chrome")); // last try with the default installation location.

@johnchen confirmed that, the binary search order on Linux was accidentally changed by r708243, which was intended to make it easier to configure the name of the Chrome binary, but accidentally changed the search order as well.

ChromeDriver team have updated ChromeDriver to fix this issue through this revision / commit.


Solution

The above mentioned solution is available with:


Interim solution

An interim solution would be using the binary_location attribute and you can find a detailed discussion in Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for such a detailed explanation. I have managed to get it working now. Altought I didnt use your Interim solution, but when reading throught links that you have provided, I noticed, that adding tag "--no-sandox" could help, and it did in my case. As mentioned by @johncen here bugs.chromium.org/p/chromedriver/issues/detail?id=3336
@Tralots As a side note these are the reasons behind I don't suggest --no-sandox right from the word go but only when it becomes necessary.
0

I have had a similar issue and spent hours. The problem could also be (as was in my case) because you are using a docker base image which only installs Selenium Web Driver but not Chrome Browser (or Chromium). In my case I changed my code to use WebDriver instead of ChromeDriver when it's a non-windows env. The Selenium Web Driver doesn't require Chromium/Chrome Browser. This fixed the issue for me.


    public WebDriver getWebDriver() throws IOException {
        final ChromeOptions options = new ChromeOptions();

        // Overwrite the values set in the Dockerfile.
        System.setProperty("webdriver.chrome.whitelistedIps", "");
        System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");

        // Set custom options for the webdriver.
        options.addArguments("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 11_4) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/91.0.4472.124 Safari/537.36");
        options.addArguments("--lang=en_US");
        options.addArguments("--window-size=3840,2160");
        options.addArguments("--disable-extensions");
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-gpu");
        options.addArguments("--headless");
        return new ChromeDriver(options);
    }

The above code works perfectly with the below Dockerfile's generated image:

FROM peavers/selenium-java:latest

WORKDIR /app
COPY target/BadmintonBooking-1.0.jar BadmintonBooking.jar
# EXPOSE 8080
# ENTRYPOINT ["java", "-jar", "BadmintonBooking.jar"]

ENV JAVA_OPTS="-Xms256m -Xmx512m"

# COPY application.properties /config/application.properties
# CMD ["java", "-jar", "app.jar", "--spring.config.location=file:/config/application.properties"]

# Default command with Java arguments
CMD java $JAVA_OPTS -jar BadmintonBooking.jar

My docker-compose file just in case you want one:

version: '3'
services:
  my-app:
    image: saurabhcrypto/badminton-booking
    shm_size: '2gb'
    volumes:
      # ensure you provide correct source paths to the below files
      - ./resource/application.properties:/config/application.properties
    environment:
      - SPRING_CONFIG_LOCATION=file:/config/application.properties

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.