org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:崩溃(无头Chrome) [英] org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (headless chrome)

查看:227
本文介绍了org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:崩溃(无头Chrome)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在centos上运行无头Chrome,无头chrome版本2.38和google-chrome-stable稳定版67.0

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选项:

 "--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

我已经验证了chrome和chromedriver版本,它是兼容的.不明白为什么它不能在centos上运行? 相同的代码在Mac上可以正常运行

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

绒球

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

推荐答案

此错误消息...

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

...表示 ChromeDriver 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话.

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

在CentOS上使用 Headless Chrome 时,值得一提的是,根据讨论 无头Chrome入门 --disable-gpu Temporarily needed if running on Windows.

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:

  • 您正在使用 chromedriver = 2.38
  • 您正在使用 chrome = 67.0
  • 您的 Selenium Client 版本是 2017-09-27T15:28:36.4Z 3.6.0 差不多要一年.
  • 您的 JDK版本 1.8.0_101 ,这是古代的.
  • 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.

因此 JDK v8u101 Selenium Client v3.6.0 ChromeDriver v2.38 Chrome浏览器v67.0

  • JDK 升级到最新级别 版本3.12.0 > .
  • ChromeDriver 升级到当前的 ChromeDriver v2.40 级别.
  • Chrome 版本保持在 Chrome v66-68 级别之间. (根据ChromeDriver v2.40发行说明)
  • 通过 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项.
  • 使用 CCleaner 工具清除之前和之后的所有操作系统杂项在您执行 Test Suite 之后.
  • 如果您的基本 Web客户端版本太旧,请通过来卸载. Revo Uninstaller 并安装最新版本的 Web客户端 GA和发行版.
  • 进行系统重启.
  • 执行您的@Test.
  • 始终在tearDown(){}方法中调用driver.quit()以关闭&优雅地销毁 WebDriver Web Client 实例.
  • 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.

这篇关于org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:崩溃(无头Chrome)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆