org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (headless chrome)

对着背影说爱祢 提交于 2019-12-13 03:41:40

问题


I am running headless chrome on centos, with headless chrome version 2.38, and google-chrome-stable version 67.0

System.setProperty("webdriver.chrome.driver", driverPath);
    log.warn("chrome driver path is : {}", driverPath);
    List<String> options = proxyConfig.getChromeOptions();
    ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.addArguments(options);
    Map<String, String> capabilites = proxyConfig.getCapabilities();
    if(MapUtils.isNotEmpty(capabilites)) {
      for (Map.Entry<String, String> entry : capabilites.entrySet()) {
        chromeOptions.setCapability(entry.getKey(), entry.getValue());
      }
    }
    // proxy configuration
    /*Proxy proxy = new Proxy();
    proxy.setProxyType(Proxy.ProxyType.MANUAL);
    proxy.setHttpProxy(proxyConfig.getProxyHost());
    proxy.setSocksUsername(proxyConfig.getProxyUsername());
    proxy.setSocksPassword(proxyConfig.getProxyPassword());
    chromeOptions.setCapability(CapabilityType.PROXY, proxy);*/
    log.warn("chorme driver created ");
    return new ChromeDriver(chromeOptions);

chrome options:

 "--headless", 
        "----disable-gpu", 
        "--ignore-certificate-errors", 
        "window-size=1920,1080"

It is giving below given error message at last line :

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 4.9.77blibli.com x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.11 seconds
Build info: version: ‘3.6.0’, revision: ‘6fbf3ec767’, time: ‘2017-09-27T15:28:36.4Z’
System info: host: ‘csrapp-02’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘4.9.77dwdwde.com’, java.version: ‘1.8.0_101’
Driver info: driver.version: ChromeDriver

i have verified chrome, and chromedriver version, it is compatible. Couldn't understand why it is not running on centos? Same code works fine on mac

pom

<dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.12.0</version>
    </dependency>

回答1:


This error message...

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

As you are using Headless Chrome on CentOS it is worth to mention that as per the discussion Getting Started with Headless Chrome --disable-gpu is Temporarily needed if running on Windows.

--disable-gpu \                # Temporarily needed if running on Windows.

However, your main issue is the incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.38
  • You are using chrome=67.0
  • Your Selenium Client version is 3.6.0 of 2017-09-27T15:28:36.4Z which is almost a year older.
  • Your JDK version is 1.8.0_101 which is pretty ancient.

So there is a clear mismatch between the JDK v8u101 , Selenium Client v3.6.0 , ChromeDriver v2.38 and the Chrome Browser v67.0

Solution

  • Upgrade JDK to recent levels JDK 8u171.
  • Upgrade Selenium to current levels Version 3.12.0.
  • Upgrade ChromeDriver to current ChromeDriver v2.40 level.
  • Keep Chrome version between Chrome v66-68 levels. (as per ChromeDriver v2.40 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.


来源:https://stackoverflow.com/questions/50830193/org-openqa-selenium-webdriverexception-unknown-error-chrome-failed-to-start-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!