"Chrome failed to start: exited abnormally"



我正在尝试在Ubuntu 16.4上运行一个简单的硒案例来检查我更新的ChromeDriver版本。这是我的设置信息:

OS: Ubuntu 16.04
Chromium: 69.0.3497.81, Built on Ubuntu , 
Chromedriver: v2.8.240825
jdk: openjdk version "1.8.0_181"

这是我的简单Java代码:

public static void main(String[] args) throws IOException, InterruptedException {
System.setProperty("webdriver.chrome.driver", "/usr/bin/chromedriver");
System.setProperty("webdriver.chrome.logfile", "/tmp/chromedriver.log");
System.setProperty("webdriver.chrome.verboseLogging", "true");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless", "window-size=1024,768", "--no-sandbox");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://google.com");
System.out.println("Title is " + driver.getTitle());
if (driver.getPageSource().contains("I'm Feeling Lucky")) {
System.out.println("Pass");
} else {
System.out.println("Fail");
}
driver.quit();
}

但是在运行时,我不断收到"Chrome无法启动:异常退出">,日志文件中如下:

"
....
[0.317][INFO]: Launching chrome: /usr/bin/chromium-browser --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --dis
able-web-resources --enable-logging --full-memory-crash-report --ignore-certificate-errors --load-extension=/tmp/.org.chromium.Chromium.GO6lAd/internal --logging-level=1 --metrics-recording-only --no-first-run --password-store=basic --re
mote-debugging-port=12811 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --use-mock-keychain --user-data-dir=/tmp/.org.chromium.Chromium.uTbJHO data:,
[0.317][DEBUG]: DevTools request: http://127.0.0.1:12811/json/version
[0.319][WARNING]: PAC support disabled because there is no system implementation
[0.390][DEBUG]: DevTools request failed
[0.440][DEBUG]: DevTools request: http://127.0.0.1:12811/json/version
[0.441][DEBUG]: DevTools request failed
"

但是,如果我要将ChromeDriver降级到2.4版,则相同的代码可以完美运行。有谁知道为什么?我需要最新版本的原因是因为我需要使用其他一些功能。

失败实际上是在较旧的Chrome驱动程序,版本2.9,2.8等。最新的 2.38 或 2.42 没有这种行为。

相关内容

最新更新