我无法让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
- 这可能是什么问题?
与How to run selenium chromedriver as root? (not working even with --no-sandbox类似,但这是由Python依赖项解决的 - 这是一个Java项目。
我还在maven命令中添加了-Dwebdriver.chrome.args="--no-sandbox"
。
您必须使用匹配的Chrome和ChromeDriver版本才能使Selenium正常运行。 http://chromedriver.chromium.org/downloads有一个清单。
在这篇文章的时候: