硒与铬一起使用webworker

时间:2019-07-09 19:45:45

标签: selenium-webdriver webdriver selenium-chromedriver chromium

我正在使用:

  • 铬73
  • Chromium ChromeDriver 73
  • 高山3.9
  • 硒Java

在CI(在kuberenetes集群中)中,并且由于我将WebWorker添加到正在测试的应用程序代码中,导致Web驱动程序崩溃。

此处崩溃的日志-https://gist.github.com/yosiat/360cb40af0cf7e234a0c6304c8c26ef1

我启用了chrome webdriver详细日志记录,我看到了以下几行:

[33751:33751:0709/175416.767497:ERROR:validation_errors.cc(76)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED (DevToolsAgentHost::ChildWorkerCreated deserializer)
[33751:33761:0709/175416.767545:ERROR:render_process_host_impl.cc(4800)] Terminating render process for bad Mojo message: Received bad user message: Validation failed for DevToolsAgentHost::ChildWorkerCreated deserializer [VALIDATION_ERROR_DESERIALIZATION_FAILED (DevToolsAgentHost::ChildWorkerCreated deserializer)
[33751:33761:0709/175416.767578:ERROR:bad_message.cc(27)] Terminating renderer for bad IPC message, reason 123
[1562694856.784][DEBUG]: DevTools WebSocket Event: Inspector.targetCrashed EBB11FCDAB2DEC02066BF3BCD6FF4F8D {

}
[1562694856.784][INFO]: Done waiting for pending navigations. Status: unknown error: cannot determine loading status
from tab crashed
[1562694856.835][INFO]: [d62047bf581d2bfcc6f681474fb0ea28] RESPONSE Navigate ERROR unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: chrome=73.0.3683.103)

2 个答案:

答案 0 :(得分:0)

尝试使用参数'--disable-dev-shm-usage'启动chrome。 示例JAVA:

  ChromeOptions options = new ChromeOptions();
  options.addArguments("--disable-dev-shm-usage");

很可能是由于内存问题而导致崩溃的。 Reference

如果上述解决方案不起作用,则可以尝试mounting an emptyDir to /dev/shm and setting the medium to Memory

答案 1 :(得分:0)

尝试在docker中设置守夜人+铬+ chromedriver时遇到了完全相同的错误。我们的项目使用Auth0,而后者又使用了Web工作程序,而其他一些没有Web工作程序的网站也可以正常打开。我使用了node:10-alpine图片,并像这样apk add chromium-chromedriver chromium一样简单地安装了chrome和chromedriver,尝试了-特权模式和一堆chrome标志,但是没有用。

然后我尝试使用它作为基础(现在它安装了chrome 76)https://github.com/GoogleChromeLabs/lighthousebot/blob/master/builder/Dockerfile,并且可以正常工作。最终的dockerfile就是这样

FROM node:10-slim AS test

RUN apt-get update --fix-missing && apt-get -y upgrade

RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable --no-install-recommends \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /src/*.deb
RUN npm install nightwatch chromedriver

# copy nightwatch files, etc

然后使用--headless--no-sandbox--disable-gpu运行chrome。