簡體   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