无法使用 selenium 网络驱动程序在 centos 7 中启动 google chrome v61?
Unable to launch google chrome v61 in centos 7 using selenium web driver?
环境:
- Centos 7
- GOOGLECHROMEV61
- SELENIUM WEBDRIVER 3.5.3
- Chrome 驱动程序 2.30/2.32
在 jenkins-slave
中手动尝试 运行 运行 google chrome
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
缺少一些依赖项导致了这个问题 (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
安装以上软件包解决了问题!
希望对您有所帮助。
这个错误信息...
NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
...意味着您的系统中没有 setuid 沙箱,因此该程序无法initiate/spawn 新的浏览上下文 即 Chrome 浏览器 会话。
解决方案
正如您在配置 --no-sandbox
和 --disable-setuid-sandbox
时看到的错误,根据 Linux SUID Sandbox Development google-chrome 中的文档需要一个 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_sandbox
(ninja -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;博士
Security Considerations - ChromeDriver - Webdriver for Chrome
环境:
- Centos 7
- GOOGLECHROMEV61
- SELENIUM WEBDRIVER 3.5.3
- Chrome 驱动程序 2.30/2.32
在 jenkins-slave
中手动尝试 运行 运行 google chromegoogle-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
缺少一些依赖项导致了这个问题 (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
安装以上软件包解决了问题!
希望对您有所帮助。
这个错误信息...
NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
...意味着您的系统中没有 setuid 沙箱,因此该程序无法initiate/spawn 新的浏览上下文 即 Chrome 浏览器 会话。
解决方案
正如您在配置 --no-sandbox
和 --disable-setuid-sandbox
时看到的错误,根据 Linux SUID Sandbox Development google-chrome 中的文档需要一个 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_sandbox
(ninja -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;博士
Security Considerations - ChromeDriver - Webdriver for Chrome