通过量角器启动无头 chrome 在 docker 中失败
Starting headless chrome via protractor fails in docker
我们用 node/protractor 编写了端到端测试,并希望在 docker 中执行它们。不幸的是,这失败了,因为它似乎 chrome 在启动后立即崩溃。
这是 docker run
进程的日志
Google Chrome 89.0.4389.114
Webdriver-manager has started - give her some time
[11:54:09] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[11:54:09] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[11:54:10] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml https://selenium-release.storage.googleapis.com/
[11:54:11] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.29.0 -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_89.0.4389.23 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar -port 4444
[11:54:11] I/start - seleniumProcess.pid: 26
Enough of that - lets start the tests
> protractor-cucumber-tests@2.1.0 e2eTests /e2e
> node ./config/e2eNodeRunner.js "-c" "....." "-u" "https://......" "-t" "@smokeTest"
Protractor config file has been created with the following data:
┌────────────┬──────────────────────────────┬───────────────────────────────────┬──────────────────────────────┬────────────────────┐
│ Selenium │ Url │ Feature │ Tags │
├────────────┼──────────────────────────────┼───────────────────────────────────┼──────────────────────────────┼────────────────────┤
│ http://12… │ https://… │ / │ @smokeTest │
└────────────┴──────────────────────────────┴───────────────────────────────────┴──────────────────────────────┴────────────────────┘
[11:54:39] I/launcher - Running 1 instances of WebDriver
[11:54:39] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[11:54:41] E/launcher - 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.)
(Driver info: chromedriver=89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}),platform=Linux 5.8.0-48-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 789 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '905345c52948', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.8.0-48-generic', java.version: '1.8.0_275'
Driver info: driver.version: unknown
[11:54:41] E/launcher - WebDriverError: 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.)
(Driver info: chromedriver=89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}),platform=Linux 5.8.0-48-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 789 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '905345c52948', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.8.0-48-generic', java.version: '1.8.0_275'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/e2e/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/e2e/node_modules/selenium-webdriver/lib/http.js:509:13)
at /e2e/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 (/e2e/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/e2e/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (/e2e/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/e2e/node_modules/selenium-webdriver/index.js:626:16)
at Hosted.getNewDriver (/e2e/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/e2e/node_modules/protractor/built/runner.js:195:43)
at /e2e/node_modules/protractor/built/runner.js:339:29
at _fulfilled (/e2e/node_modules/q/q.js:834:54)
at /e2e/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/e2e/node_modules/q/q.js:796:13)
[11:54:41] E/launcher - Process exited with error code 199
我的问题是,有没有人遇到过这个问题?任何人都可以理解,为什么 chrome 立即粉碎?
使用的能力是
11:54:40.018 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--headless",
"--disable-dev-shm-usage",
"--no-sandbox"
],
"perfLoggingPrefs": {
"enableNetwork": true,
"enablePage": true,
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
}
},
"count": 1,
"goog:chromeOptions": {
"w3c": false,
"prefs": {
"download": {
"prompt_for_download": false,
"directory_upgrade": true,
"default_directory": "\u002fe2e\u002ftests\u002fdownloads"
}
}
},
"host": "https:\u002f\u002f....,
"idleTimeout": 300,
"loggingPrefs": {
"performance": "ALL"
},
"maxDuration": "10800",
"maxInstances": 1,
"password": "Test_1234",
"screenResolution": "1920x1080",
"shardTestFiles": false,
"specs": "..\u002ftests\u002ffeatures\u002f**\u002f*.feature",
"timeZone": "UTC",
"user": "test_user",
"version": ""
}
并且使用的 docker 文件是:
FROM node:12.18.3
RUN apt-get clean
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgconf-2-4 \
openjdk-8-jre-headless
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
COPY . e2e
RUN cp e2e/runner.sh . ; chmod +x runner.sh
RUN cd e2e ; chmod 744 * ; npm install
RUN npm install -g protractor
RUN npm install -g eslint
RUN webdriver-manager update
ENTRYPOINT ["./runner.sh"]
runner.sh
脚本基本上只包含 npm run
命令和相应的参数。
是否有人已经在脚本中看到任何 problem/error 或者可以指出与此相关的任何内容?
哦,是的,我们使用量角器 7.0.0
谢谢
实际问题是量角器配置文件中的条件部分覆盖了我的 headless
选项 :( 这是个愚蠢的问题。
我们用 node/protractor 编写了端到端测试,并希望在 docker 中执行它们。不幸的是,这失败了,因为它似乎 chrome 在启动后立即崩溃。
这是 docker run
进程的日志
Google Chrome 89.0.4389.114
Webdriver-manager has started - give her some time
[11:54:09] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
[11:54:09] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[11:54:10] I/config_source - curl -o/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/standalone-response.xml https://selenium-release.storage.googleapis.com/
[11:54:11] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.gecko.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.29.0 -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_89.0.4389.23 -jar /usr/local/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar -port 4444
[11:54:11] I/start - seleniumProcess.pid: 26
Enough of that - lets start the tests
> protractor-cucumber-tests@2.1.0 e2eTests /e2e
> node ./config/e2eNodeRunner.js "-c" "....." "-u" "https://......" "-t" "@smokeTest"
Protractor config file has been created with the following data:
┌────────────┬──────────────────────────────┬───────────────────────────────────┬──────────────────────────────┬────────────────────┐
│ Selenium │ Url │ Feature │ Tags │
├────────────┼──────────────────────────────┼───────────────────────────────────┼──────────────────────────────┼────────────────────┤
│ http://12… │ https://… │ / │ @smokeTest │
└────────────┴──────────────────────────────┴───────────────────────────────────┴──────────────────────────────┴────────────────────┘
[11:54:39] I/launcher - Running 1 instances of WebDriver
[11:54:39] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[11:54:41] E/launcher - 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.)
(Driver info: chromedriver=89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}),platform=Linux 5.8.0-48-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 789 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '905345c52948', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.8.0-48-generic', java.version: '1.8.0_275'
Driver info: driver.version: unknown
[11:54:41] E/launcher - WebDriverError: 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.)
(Driver info: chromedriver=89.0.4389.23 (61b08ee2c50024bab004e48d2b1b083cdbdac579-refs/branch-heads/4389@{#294}),platform=Linux 5.8.0-48-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 789 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '905345c52948', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.8.0-48-generic', java.version: '1.8.0_275'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (/e2e/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/e2e/node_modules/selenium-webdriver/lib/http.js:509:13)
at /e2e/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 (/e2e/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/e2e/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (/e2e/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (/e2e/node_modules/selenium-webdriver/index.js:626:16)
at Hosted.getNewDriver (/e2e/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (/e2e/node_modules/protractor/built/runner.js:195:43)
at /e2e/node_modules/protractor/built/runner.js:339:29
at _fulfilled (/e2e/node_modules/q/q.js:834:54)
at /e2e/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/e2e/node_modules/q/q.js:796:13)
[11:54:41] E/launcher - Process exited with error code 199
我的问题是,有没有人遇到过这个问题?任何人都可以理解,为什么 chrome 立即粉碎?
使用的能力是
11:54:40.018 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"chromeOptions": {
"args": [
"--headless",
"--disable-dev-shm-usage",
"--no-sandbox"
],
"perfLoggingPrefs": {
"enableNetwork": true,
"enablePage": true,
"traceCategories": "blink.console,devtools.timeline,disabled-by-default-devtools.timeline,toplevel,disabled-by-default-devtools.timeline.frame,benchmark"
}
},
"count": 1,
"goog:chromeOptions": {
"w3c": false,
"prefs": {
"download": {
"prompt_for_download": false,
"directory_upgrade": true,
"default_directory": "\u002fe2e\u002ftests\u002fdownloads"
}
}
},
"host": "https:\u002f\u002f....,
"idleTimeout": 300,
"loggingPrefs": {
"performance": "ALL"
},
"maxDuration": "10800",
"maxInstances": 1,
"password": "Test_1234",
"screenResolution": "1920x1080",
"shardTestFiles": false,
"specs": "..\u002ftests\u002ffeatures\u002f**\u002f*.feature",
"timeZone": "UTC",
"user": "test_user",
"version": ""
}
并且使用的 docker 文件是:
FROM node:12.18.3
RUN apt-get clean
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgconf-2-4 \
openjdk-8-jre-headless
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
COPY . e2e
RUN cp e2e/runner.sh . ; chmod +x runner.sh
RUN cd e2e ; chmod 744 * ; npm install
RUN npm install -g protractor
RUN npm install -g eslint
RUN webdriver-manager update
ENTRYPOINT ["./runner.sh"]
runner.sh
脚本基本上只包含 npm run
命令和相应的参数。
是否有人已经在脚本中看到任何 problem/error 或者可以指出与此相关的任何内容?
哦,是的,我们使用量角器 7.0.0
谢谢
实际问题是量角器配置文件中的条件部分覆盖了我的 headless
选项 :( 这是个愚蠢的问题。