简体   繁体   English

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

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

Environment:环境:

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

Tried running manually running google chrome inside jenkins-slave尝试在 jenkins-slave 中手动运行谷歌浏览器

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

Was giving me this error:给了我这个错误:

[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

Webdriver Error Info:网络驱动程序错误信息:

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

This error message...这个错误信息...

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

...implies that you have no setuid sandbox in your system, hence the program was unable to initiate/spawn a new Browsing Context ie Chrome Browser session. ...暗示您的系统中没有 setuid 沙箱,因此程序无法启动/生成新的浏览上下文,Chrome 浏览器会话。


Solution解决方案

As you are seeing the error even with configuring --no-sandbox and --disable-setuid-sandbox , as per the documentation in Linux SUID Sandbox Development needs a SUID helper binary to turn on the sandbox on Linux.正如您在配置--no-sandbox--disable-setuid-sandbox看到的错误一样,根据Linux SUID Sandbox Development 中的文档, 需要一个SUID帮助程序二进制文件来打开 Linux 上的沙箱。 In majority of the cases you can install the proper sandbox for you using the command:在大多数情况下,您可以使用以下命令为您安装合适的沙箱:

build/update-linux-sandbox.sh

This program will install the proper sandbox for you in /usr/local/sbin and tell you to update your .bashrc if required.该程序将在/usr/local/sbin为您安装适当的沙箱,并告诉您在需要时更新.bashrc

However, there can be some exceptions as an example, if your setuid binary is out of date, you will get messages such as:但是,可能有一些例外,例如,如果您的setuid二进制文件已过期,您将收到如下消息:

Running without the SUID sandbox! 

Or或者

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

In these cases, you need to:在这些情况下,您需要:

  • Build chrome_sandbox whenever you build chrome ( ninja -C xxx chrome chrome_sandbox instead of ninja -C xxx chrome )每当您构建 chrome 时构建chrome_sandboxninja -C xxx chrome chrome_sandbox而不是ninja -C xxx chrome
  • After building, execute update-linux-sandbox.sh .构建完成后,执行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
  • Finally, you have to include the following line in your ~/.bashrc (or .zshenv ):最后,您必须在~/.bashrc (或.zshenv )中包含以下行:

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

tl; tl; dr博士

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

There were some missing dependencies that caused this issue ( https://www.centos.org/forums/viewtopic.php?t=60908&start=10 )有一些缺失的依赖项导致了这个问题( 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

Installing above packages solved the problem!安装以上包解决了问题!

Hope it helps.希望它有帮助。

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

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