当前位置: 首页 > 知识库问答 >
问题:

未知错误:Chrome无法启动:崩溃(selenium,headless mode)

徐洋
2023-03-14

我有这个代码和一个执行中的问题(代码下的描述)

   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;
    }

我使用:

  1. Ubuntu 14.04.5 LTS

当我创建RemoteWebDriver时,我得到以下错误:异常:未知错误:Chrome无法启动:崩溃

启动selenium服务器的命令

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

此方案的哪些部分可能是所述错误的原因?

共有1个答案

微生青青
2023-03-14

首先,你提出的所有论点都是无头的错误。

它是无头的

使用以下代码

options.addArguments("--headless");

另一件事你必须通过系统。setProperty如下所示:

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

从我这边工作正常的代码是:

         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;
            }

    }
 类似资料:
  • 问题内容: 我正在尝试使用ChromeWebDriver在Chrome上测试我的应用程序,但是每次尝试都会出现以下异常: 在chromedriver.log中,我看到了 我正在使用: 镀铬36 ChromeWebDriver 2.10 Windows 7的 在Process Explorer中,我可以看到chromedriver.exe进程正在运行,但是没有打开任何窗口,几秒钟后,我得到了上面的异

  • 我在centos上运行无头chrome,无头chrome版本2.38和google-chrome-稳定版本67.0 chrome选项: 最后一行给出以下给定错误消息: 我已经验证了chrome和chromedriver版本,它是兼容的。无法理解为什么它没有在centos上运行?同样的代码在mac上运行良好 聚甲醛

  • 我试图将与一起使用,我为chromedriver到/usr/local/bin的路径创建了一个符号链接,但当我运行 我的错误是 它还会生成一个核心。******,一个包含五个随机数的核心文件点,大小超过200MB。 版本: 有谁能帮我找出问题出在哪里吗?

  • 问题内容: 由于这个问题,我已经呆了好几天,而且似乎找不到解决方案。无论我做什么,我都无法让chromedriver在我的机器上工作。我已经尝试了几乎所有我可以想象的设置。列举一些: Chrome 64位,Python 64位 Chrome 32位,Python 32位 Chrome 64位,Python 32位 Chrome 32位,Python 64位 我还尝试了不同版本的Chrome及其相应

  • 问题内容: 这是我的代码脚本: 并在运行此脚本时出现此错误: 我已经编辑了chromedriver的可执行路径,但是当我运行脚本时,我的chrome驱动程序会打开,但之后停留2-3分钟,然后由于上述错误而崩溃。 问题答案: 拇指法则 Chrome在启动过程中崩溃的常见原因是 在Linux上以 用户( )的身份运行Chrome 。虽然可以在创建WebDriver会话时通过传递标志来解决此问题,但这种

  • 问题内容: 我正在尝试使用官方的詹金斯码头工人镜像来设置詹金斯。 Docker文件 在运行作业时,浏览器将无法打开并进入本地主机。我也尝试点击“ google.com” 仍然没有成功 我不明白为什么詹金斯用户无法打开浏览器。 谷歌浏览器74.0.3729.169 ChromeDriver 2.35.528139(47ead77cb35ad2a9a83248b292151462a66cd881) R