Chrome failed to start in docker container using Selenium after upgrading to ChromeDriver v80 and Chrome v80

走远了吗. 提交于 2020-03-02 08:02:27

问题


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.

回答1:


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:

  • ChromeDriver v80.0.3987.106
  • ChromeDriver v81.0.4044.20

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



来源:https://stackoverflow.com/questions/60304109/chrome-failed-to-start-in-docker-container-using-selenium-after-upgrading-to-chr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!