繁体   English   中英

无法使用 selenium Web 驱动程序在 centos 7 中启动 google chrome v61?

[英]Unable to launch google chrome v61 in centos 7 using selenium web driver?

环境:

  • Centos 7
  • 谷歌 Chrome V61
  • 硒网络驱动程序 3.5.3
  • ChromeDriver 2.30/2.32

尝试在 jenkins-slave 中手动运行谷歌浏览器

google-chrome --no-sandbox --disable-setuid-sandbox &

给了我这个错误:

[31339:31350:1003/144118.591084:ERROR:bus.cc(395)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1003/144118.702053:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly

网络驱动程序错误信息:

Chrome failed to start: crashed
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.8-20.46.amzn1.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.06 seconds
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z'
System info: host: 'jenkins-slavev2', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.8-20.46.amzn1.x86_64', java.version: '1.8.0_102'
Driver info: driver.version: ChromeDriver

这个错误信息...

NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly

...暗示您的系统中没有 setuid 沙箱,因此程序无法启动/生成新的浏览上下文,Chrome 浏览器会话。


解决方案

正如您在配置--no-sandbox--disable-setuid-sandbox看到的错误一样,根据Linux SUID Sandbox Development 中的文档, 需要一个SUID帮助程序二进制文件来打开 Linux 上的沙箱。 在大多数情况下,您可以使用以下命令为您安装合适的沙箱:

build/update-linux-sandbox.sh

该程序将在/usr/local/sbin为您安装适当的沙箱,并告诉您在需要时更新.bashrc

但是,可能有一些例外,例如,如果您的setuid二进制文件已过期,您将收到如下消息:

Running without the SUID sandbox! 

或者

The setuid sandbox provides API version X, but you need Y
You are using a wrong version of the setuid binary!

在这些情况下,您需要:

  • 每当您构建 chrome 时构建chrome_sandboxninja -C xxx chrome chrome_sandbox而不是ninja -C xxx chrome
  • 构建完成后,执行update-linux-sandbox.sh

     # needed if you build on NFS! sudo cp out/Debug/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox sudo chown root:root /usr/local/sbin/chrome-devel-sandbox sudo chmod 4755 /usr/local/sbin/chrome-devel-sandbox
  • 最后,您必须在~/.bashrc (或.zshenv )中包含以下行:

     export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox

tl; 博士

安全注意事项 - ChromeDriver - 适用于 Chrome 的 Webdriver

有一些缺失的依赖项导致了这个问题( https://www.centos.org/forums/viewtopic.php?t=60908&start=10

yum install liberation-mono-fonts liberation-narrow-fonts liberation-sans-fonts liberation-serif-fonts

安装以上包解决了问题!

希望它有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM