-1

当我使用命令“npm test”在容器中运行测试时,出现以下错误:

ERROR @wdio/runner: Error: Failed to create session.
[0-1] Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: exited abnormally.
[0-1]   (unknown error: DevToolsActivePort file doesn't exist)
[0-1]   (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
[0-1] Build info: version: '4.0.0', revision: '3a21814679'
[0-1] System info: host: '76f435460e13', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-27-generic', java.version: '1.8.0_312'
[0-1] Driver info: driver.version: unknown
[0-1] Build info: version: '4.0.0', revision: '3a21814679'
[0-1] System info: host: '76f435460e13', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.13.0-27-generic', java.version: '1.8.0_312'
[0-1] Driver info: driver.version: unknown
[0-1]     at startWebDriverSession (/usr/src/app/node_modules/@wdio/local-runner/node_modules/webdriver/build/utils.js:72:15)
[0-1]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[0-1]     at async Function.newSession (/usr/src/app/node_modules/@wdio/local-runner/node_modules/webdriver/build/index.js:42:45)
[0-1]     at async remote (/usr/src/app/node_modules/@wdio/local-runner/node_modules/webdriverio/build/index.js:73:22)
[0-1]     at async Runner._startSession (/usr/src/app/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/index.js:223:56)
[0-1]     at async Runner._initSession (/usr/src/app/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/index.js:176:25)
[0-1]     at async Runner.run (/usr/src/app/node_modules/@wdio/local-runner/node_modules/@wdio/runner/build/index.js:88:19)

虽然我在 ubuntu 20.04 VM 中遇到了同样的错误,但我使用以下命令解决了它:

sudo apt-get install -y xvfb
sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99

您知道我该如何解决吗?

4

0 回答 0