Unknown error: Chrome failed to start: exited abnormally

后端 未结 10 1069
不知归路
不知归路 2020-12-04 17:36

I am getting this error when I run my tests with Selenium using chromedriver.

selenium.common.exceptions.WebDriverException: Message:
unknown error: Chrome f         


        
相关标签:
10条回答
  • 2020-12-04 18:08

    I was faced with the same issue and fixed it by installing Chrome in:

    C:\Users\..\AppData\Local\Google\Chrome\Application
    

    You can do this by running the Chrome Setup and saying no when prompted by the User Account Control.

    0 讨论(0)
  • 2020-12-04 18:09

    Someone already mentioned about --no-sandbox option, but to expand on it: make sure, it's the first option you pass:

            System.setProperty("webdriver.chrome.driver",
                    Paths.get("setups", driverFolder, driverFile).toAbsolutePath().toString());
    
            ChromeOptions options = new ChromeOptions();
            Map<String, Object> prefs = new HashMap<>();
            prefs.put("intl.accept_languages", "English");
            options.setExperimentalOption("prefs", prefs);
    
            options.addArguments("--no-sandbox");
            options.addArguments("--disable-features=VizDisplayCompositor");
            options.addArguments("--incognito");
            options.addArguments("enable-automation");
            options.addArguments("--headless");
            options.addArguments("--window-size=1920,1080");
            options.addArguments("--disable-gpu");
            options.addArguments("--disable-extensions");
            options.addArguments("--dns-prefetch-disable");
            options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
    
            options.addArguments("enable-features=NetworkServiceInProcess");
    
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            capabilities.setCapability("marionette", true);
            capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    
            WebDriver driver = new ChromeDriver(capabilities);
            driver.manage().timeouts().implicitlyWait(15, SECONDS);
            driver.manage().timeouts().pageLoadTimeout(15, SECONDS);
    

    When it was added after other options, I got the error.

    0 讨论(0)
  • 2020-12-04 18:09

    Another solution for selenium webdriver is X virtual frame buffer:

    with Xvfb() as _:
        timeout_request = ConfigTargetsManager.target_global_configs.get('timeout_request', 10)
        driver = webdriver.Chrome(executable_path=ConfigTargetsManager.target_global_configs.get('chrome_browser_path',
                                                                                                 '/usr/lib/chromium-browser/chromedriver'))
        driver.get(url)
    
    0 讨论(0)
  • 2020-12-04 18:10

    An alternative solution of using a virtual display is the headless mode.

    from selenium import webdriver
    
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--no-sandbox')
    chrome_options.add_argument('--window-size=1420,1080')
    chrome_options.add_argument('--headless')
    chrome_options.add_argument('--disable-gpu')
    driver = webdriver.Chrome(chrome_options=chrome_options)
    
    0 讨论(0)
  • 2020-12-04 18:11

    You may be able to fix this issue by making sure your version of chromedriver is right for the version of Chrome you have installed, which you can check here. You will also need to remove your current version of chromedriver before installing the new one, as described in Delete Chromedriver from Ubuntu

    0 讨论(0)
  • 2020-12-04 18:22

    If using Linux make sure you are not running as root. That what gave me the error.

    0 讨论(0)
提交回复
热议问题