Chrome在升级到ChromeDriver v80和Chrome v80后,无法在使用Selenium的docker容



我在docker容器中运行了E2E测试。在周五的硒元素/节点铬元素更新之后,它将不再工作。我试过使用旧版本的selenium/nodechrome,但它不起作用。我对码头集装箱等的经验很少

谷歌浏览器80.0.3987.106<-运行命令获得的信息谷歌chrome——chromediver-80.0.3987.106<-信息获取自/opt/selement/文件夹。

以下是我的Dockerfile的样子:

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"]

构建似乎很顺利,没有任何问题,但当尝试运行测试时,我收到以下错误消息:

> 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.

此错误消息。。。

[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>

意味着ChromeDriverv80.0无法启动/生成新的浏览上下文,其中Docker镜像适用于Chrome(80.0(


根据讨论,WebDriver 80.0.3987.16无法在Linux上打开Chrome@triciac提到,ChromeDriverv80.0的实现按以下顺序查找Chrome

  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"((;//最后一次尝试使用默认安装位置

@johnchen证实,Linux上的二进制搜索顺序被r708243意外更改,这是为了更容易配置Chrome二进制文件的名称,但也意外更改了搜索顺序。

ChromeDriver团队已更新ChromeDriver,以通过此次修订/提交解决此问题。


解决方案

上述解决方案可用于:

  • ChromeDriver v80.0.3987.106
  • ChromeDriver v81.0.4044.20

临时解决方案

一个临时解决方案是使用binary_location属性,您可以在Selenium:WebDriverException中找到详细的讨论:Chrome无法启动:由于谷歌Chrome不再运行而崩溃,因此ChromeDriver假设Chrome已崩溃

相关内容

  • 没有找到相关文章

最新更新