【发布时间】:2022-08-16 09:08:03
【问题描述】:
我们的端到端测试在 docker 容器中运行并使用 Webdriver.io - 与 selenium-standalone。
自从更新到 M1/arm64 Mac 以来,我一直在尝试更新要运行的测试。
通过从使用./google-chrome-stable_current_amd64.deb 更改为使用chromium,我们的单元测试(开玩笑)很容易修复。
测试容器dockerfile:
FROM node:14-bullseye
ENV CHROME_BIN=/usr/bin/chromium
RUN apt-get update \\
&& apt-get install -y chromium \\
openjdk-11-jre \\
xvfb \\
x11vnc \\
php \\
&& mkdir ~/.vnc \\
&& x11vnc -storepasswd \"fakepwd\" ~/.vnc/passwd \\
&& rm -rf /var/lib/apt/lists/*
COPY ./entrypoint.sh /usr/local/bin/
ENTRYPOINT [\"entrypoint.sh\"]
我希望它对 webdriver 测试同样简单,但到目前为止还没有运气。
我已经升级了@wdio 软件包,如下所示:
\"@wdio/allure-reporter\": \"^7.10.1\",
\"@wdio/cli\": \"^7.19.3\",
\"@wdio/devtools-service\": \"^7.19.3\",
\"@wdio/junit-reporter\": \"^7.19.1\",
\"@wdio/local-runner\": \"^7.19.3\",
\"@wdio/mocha-framework\": \"^7.19.3\",
\"@wdio/selenium-standalone-service\": \"^7.19.1\",
\"@wdio/sync\": \"^7.19.3\",
在锁定文件中,我已经确认selenium-standalone 版本是 7.1。
(如上所述,我们使用 @wdio 的 7.19.1 服务 - 这使用 ^7.0 但只有 7.1 适用于 M1 的服务:https://github.com/webdriverio/selenium-standalone/commit/10e31d0e20444b0f6eb2d897cb3b471782dd243d)
我已经确认也使用了正确的 chromedriver 二进制文件(在./node_modules/selenium-standalone/.selenium/chromedriver 下是99.0.4844.51-arm64)
来自wdio.conf.js:
services:[[\'selenium-standalone\',{
installArgs: {
drivers: {
chrome: {
binary: \'/usr/bin/chromium\',
version: chromeDriverVersion,
arch : process.arch,
baseURL : \'https://chromedriver.storage.googleapis.com\'
}
}
},
args: {
drivers: {
chrome: {
binary: \'/usr/bin/chromium\',
version: chromeDriverVersion,
arch : process.arch
}
}
}
}]];
capabilities: [{
browserName: process.env._BROWSER,
acceptInsecureCerts: true,
maxInstances: 4,
\'goog:browserOptions\': {
binary: \'/usr/bin/chromium\', // may not be needed, tried anyway
args: process.env._ENABLE_UI === \'false\' ?
[\'--disable-dev-shm-usage\',\'--no-sandbox\',\'--headless\',\'--disable-infobars\',\'--deterministic-fetch\', `--window-size=${default_viewport_width},${default_viewport_height}`] :
[\'--disable-dev-shm-usage\',\'--no-sandbox\',\'--disable-infobars\', `--window-size=${default_viewport_width},${default_viewport_height}`]
}
}],
观察 wdio 日志输出:
2022-04-01T08:09:37.336Z WARN @wdio/utils:shim: You are running tests with @wdio/sync which will be discontinued starting Node.js v16.Read more on https://github.com/webdriverio/webdriverio/discussions/6702
2022-04-01T08:09:40.101Z INFO @wdio/local-runner: Run worker command: run
2022-04-01T08:09:40.124Z DEBUG @wdio/config:ConfigParser: No compiler found, continue without compiling files
2022-04-01T08:09:42.042Z DEBUG @wdio/local-runner:utils: init remote session
2022-04-01T08:09:42.048Z DEBUG @wdio/utils:initialiseServices: initialise service \"selenium-standalone\" as NPM package
2022-04-01T08:09:42.648Z DEBUG @wdio/sync: Finished to run \"beforeSession\" hook in 0ms
2022-04-01T08:09:44.535Z DEBUG @wdio/local-runner:utils: init remote session
2022-04-01T08:09:44.536Z INFO webdriver: Initiate new session using the WebDriver protocol
2022-04-01T08:09:44.585Z INFO webdriver: [POST] http://127.0.0.1:4433/wd/hub/session
2022-04-01T08:09:44.586Z INFO webdriver: DATA {
capabilities: {
alwaysMatch: {
browserName: \'chromium\',
acceptInsecureCerts: true,
\'goog:browserOptions\': [Object]
},
firstMatch: [ {} ]
},
desiredCapabilities: {
browserName: \'chromium\',
acceptInsecureCerts: true,
\'goog:browserOptions\': { binary: \'/usr/bin/chromium\', args: [Array] }
}
}
2022-04-01T08:09:44.600Z ERROR webdriver: RequestError: connect ECONNREFUSED 127.0.0.1:4433
at ClientRequest.<anonymous> (/srv/api/author/node_modules/got/dist/source/core/index.js:956:111)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:412:35)
at ClientRequest.emit (domain.js:475:12)
at ClientRequest.origin.emit (/srv/api/author/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
at Socket.socketErrorListener (_http_client.js:475:9)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:475:12)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
2022-04-01T08:09:44.601Z ERROR @wdio/runner: Error: Failed to create session.
Unable to connect to \"http://127.0.0.1:4433/wd/hub\", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
at startWebDriverSession (/srv/api/author/node_modules/webdriver/build/utils.js:72:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Function.newSession (/srv/api/author/node_modules/webdriver/build/index.js:46:45)
at async remote (/srv/api/author/node_modules/@wdio/runner/node_modules/webdriverio/build/index.js:77:22)
at async Runner._startSession (/srv/api/author/node_modules/@wdio/runner/build/index.js:223:56)
at async Runner._initSession (/srv/api/author/node_modules/@wdio/runner/build/index.js:176:25)
at async Runner.run (/srv/api/author/node_modules/@wdio/runner/build/index.js:88:19)
2022-04-01T08:09:44.601Z DEBUG @wdio/sync: Finished to run \"after\" hook in 0ms
我认为它的铬开始有问题 - 但我找不到任何相关的日志。
我尝试在容器内手动启动它,但我不知道这里是否有任何有用的东西:
root@15adddf1e180:/srv/mydir# export DISPLAY=:99
root@15adddf1e180:/srv/mydir# /usr/bin/Xvfb :99 -ac -screen 0 1920x1080x24 > /dev/null 2>&1 &
[1] 9
root@15adddf1e180:/srv/mydir# x11vnc -listen 0.0.0.0 -display :99.0 -usepw -forever -nevershared > /dev/null 2>&1 &
[2] 24
root@15adddf1e180:/srv/mydir# /usr/bin/chromium --no-sandbox
[25:67:0401/081257.532385:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:67:0401/081257.532481:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:66:0401/081257.540896:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")
[25:66:0401/081257.540933:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:66:0401/081257.571813:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")
[25:66:0401/081257.571995:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")
[25:25:0401/081257.619504:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
*** stack smashing detected ***: terminated
[25:89:0401/081257.630541:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:89:0401/081257.631138:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:89:0401/081257.631196:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:89:0401/081257.631336:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[25:89:0401/081257.631366:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:25:0401/081257.665149:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:25:0401/081257.679383:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:25:0401/081257.691523:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:25:0401/081257.701605:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
*** stack smashing detected ***: terminated
*** stack smashing detected ***: terminated
[25:25:0401/081257.705098:ERROR:gpu_process_host.cc(972)] GPU process exited unexpectedly: exit_code=6
[25:25:0401/081257.705122:FATAL:gpu_data_manager_impl_private.cc(447)] GPU process isn\'t usable. Goodbye.
*** stack smashing detected ***: terminated
[0401/081257.720823:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[0401/081257.720915:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
Trace/breakpoint trap
root@15adddf1e180:/srv/mydir#
任何帮助将不胜感激,谢谢!
标签: docker selenium-webdriver webdriver chromium arm64