尽管--no-sandbox选项,Chromedriver不会以root身份运行

问题描述 投票:2回答:1

我无法让Chromedriver在Docker中运行,而且似乎我正在根据需要传递所有内容,但它仍然会抛出“root with sandbox”错误并退出。

2019-02-15 15:30:22 INFO : Using chromedriver set in webdriver.chrome.driver: /usr/bin/google-chrome
2019-02-15 15:30:22 INFO : Setting ChromeDriver options {browserName=chrome, goog:chromeOptions={args=[--start-maximized, headless, --no-sandbox], extensions=[], prefs={profile.default_content_settings.popups=0, download.prompt_for_download=false, download.default_directory=/home/jenkins/workspace/..../}}}
[1036:1036:0215/153022.769651:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Feb 15, 2019 3:30:42 PM org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
Failure in before hook:Hooks.getDriver(Scenario)

我已经记录了ChromeOptions内容,很明显args包含--no-sandbox - 这可能是什么问题?


  • 谷歌浏览器70.0.3538.77
  • org.seleniumhq.selenium:selenium-chrome-driver:jar:3.141.59

How to run selenium chromedriver as root? (not working even with --no-sandbox类似,但这是由Python依赖项解决的 - 这是一个Java项目。


我还在maven命令中添加了-Dwebdriver.chrome.args="--no-sandbox"

java selenium selenium-webdriver selenium-chromedriver
1个回答
2
投票

您必须使用匹配的Chrome和ChromeDriver版本才能使Selenium正常运行。 http://chromedriver.chromium.org/downloads有一个清单。

在这篇文章的时候:

  • 如果您使用的是Chrome 73版,请下载ChromeDriver 73.0.3683.20
  • 如果您使用的是Chrome版本72,请下载ChromeDriver 2.46或ChromeDriver 72.0.3626.69
  • 如果您使用的是Chrome版本71,请下载ChromeDriver 2.46或ChromeDriver 71.0.3578.137
© www.soinside.com 2019 - 2024. All rights reserved.