简体   繁体   English

未知错误:Chrome无法启动:崩溃(硒,无头模式)

[英]unknown error: Chrome failed to start: crashed(selenium ,headless mode)

i have this code and one problem(description under code) in its execution 我有此代码和执行中的一个问题(代码下的描述)

   try {
        ChromeOptions options = new ChromeOptions();
        options.setBinary("/usr/bin/chromium-browser");
        options.addArguments("--start-maximized");
        options.addArguments("headless");
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();

        capabilities.setBrowserName("chrome");
        capabilities.setPlatform(Platform.LINUX);

        capabilities.setCapability(ChromeOptions.CAPABILITY, options);
        WebDriver driver = null;

        // here throws exception
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
    }catch (Exception ex){
        int point = 0;
    }

I use: 我用:

  1. Ubuntu 14.04.5 LTS Ubuntu 14.04.5 LTS
  2. selenium-server-standalone-3.7.1 硒服务器独立3.7.1
  3. dependency org.seleniumhq.selenium:selenium-java:3.7.1 依赖org.seleniumhq.selenium:selenium-java:3.7.1
  4. ChromeDriver(for Linux 64) ChromeDriver(适用于Linux 64)
  5. Chromium(instead of just chrome) 铬(不只是铬)
  6. xvfb xvfb

and when i create RemoteWebDriver i get this error: Exception: unknown error: Chrome failed to start: crashed 当我创建RemoteWebDriver时,出现以下错误:异常: 未知错误:Chrome无法启动:崩溃

command to start selenium-server 启动硒服务器的命令

DISPLAY=:1 xvfb-run java  -Dwebdriver.chrome.driver="/home/builds/chromedriver" -jar /home/builds/selenium-server-standalone-3.7.1.jar

which of the parts of this scheme can be the cause of the described error? 该方案的哪一部分可能是所描述错误的原因?

First all the argument you have entered is wrong for headless. 首先,您输入的所有论点都是无稽之谈。

It's --headless not headless --headlessheadless

Use below code 使用以下代码

options.addArguments("--headless");

Another thing you have to pass System.setProperty like below: 另一件事,您必须像下面这样传递System.setProperty

 System.setProperty("webdriver.chrome.driver","E:\\Selenium\\src\\libs\\chromedriver.exe");

The code working fine from my side is: 就我而言,工作正常的代码是:

         try {
             System.setProperty("webdriver.chrome.driver","E:\\Selenium\\Workplace\\Selenium\\src\\libs\\chromedriver.exe");
                ChromeOptions options = new ChromeOptions();
            //    options.setBinary("/usr/bin/chromium-browser");
                options.addArguments("--start-maximized");
                options.addArguments("--headless");
                DesiredCapabilities capabilities = DesiredCapabilities.chrome();

                capabilities.setBrowserName("chrome");
                capabilities.setPlatform(Platform.WINDOWS);

                capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                WebDriver driver =  new ChromeDriver(capabilities);
                driver.get("http://google.com");


            }catch (Exception ex){
                int point = 0;
            }

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.openqa.selenium.WebDriverException:未知错误:Chrome无法启动:崩溃(无头Chrome) - org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed (headless chrome) org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed using ChromeDriver Selenium in Jenkins on Ubuntu 18.04 - org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed using ChromeDriver Selenium in Jenkins on Ubuntu 18.04 org.openqa.selenium.WebDriverException:未知错误:chrome 无法通过 Java 开始使用 Selenium ChromeDriver 和 Chrome - org.openqa.selenium.WebDriverException: unknown error: chrome failed to start using Selenium ChromeDriver and Chrome through Java 在 Java 中使用 selenium 在无头模式下启动 chrome 时会出现错误 - Launching chrome in headless mode with selenium in Java giving error 线程“ main” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:正常退出 - Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally Selenium 网格:DevToolsActivePort 文件不存在(未知错误:Chrome 无法启动:异常退出) - Selenium Grid: DevToolsActivePort file doesn't exist (unknown error: Chrome failed to start: exited abnormally) 在无头模式下使用 Chrome 驱动程序配置时,在 WebDriverSampler 脚本中遇到预期条件失败错误 - Facing expected condition failed error in WebDriverSampler script while using Chrome driver config in headless mode 硒无头测试无头模式 - selenium headless test headless mode Jenkins:WebDriver连接被拒绝(Firefox)/ Chrome无法启动:崩溃(Chrome) - Jenkins: WebDriver connection refused (Firefox) / Chrome failed to start: crashed (Chrome) 无法启动新的 session。 响应代码 500。消息:未知错误:Microsoft Edge 无法启动:崩溃 - Could not start a new session. Response code 500. Message: unknown error: Microsoft Edge failed to start: crashed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM