[selenium] unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9

I am trying to run Selenium tests on Debian 7 but without success.

The error is:

unknown error: Chrome failed to start: exited abnormally   (Driver info: chromedriver=2.9.248316,platform=Linux 3.2.0-4-686-pae x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.55 seconds Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17' System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-4-686-pae', java.version: '1.7.0_25' Driver info: org.openqa.selenium.chrome.ChromeDriver

I have chromedriver 29 with chrome 34.0.1847.76 beta running on Debian 7 32 bits. I am using selenium-java 2.33.0

Following this link, chromedriver 29 is the right version for chrome 34. And anyway, previous versions do not work on Debian 7 because of glibc version …

----------ChromeDriver v2.9 (2014-01-31)----------
Supports Chrome v31-34

[update 1]

I tried with with both java 7 and java 6, still the same problem. May be I should try with java 8 ^^

[update 2]

I am using this command to test the chrome driver, to make sure that is not an issue with jenkins:

curl -X POST -H "Content-Type: application/json; charset=utf-8" -d "{\"desiredCapabilities\":{\"platform\":\"ANY\",\"browserName\":\"chrome\",\"chromeOptions\":{\"args\":[],\"extensions\":[]},\"version\":\"\",\"chrome.switches\":[]}}" localhost:12495/session

I am getting the same error message:

{"sessionId":"210f3f837a798ee68cd91f089976d0c2","status":13,"value":{"message":"unknown error: Chrome failed to start: exited abnormally\n  (Driver info: chromedriver=2.9.248316,platform=Linux 3.2.0-4-686-pae x86)"}}

Any help to know what is going on would be appreciated.

Thanks

This question is related to selenium selenium-webdriver selenium-chromedriver

The answer is


In Linux adding these lines to my code helped me.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(options=chrome_options)

driver.get("www.counterviews.online")

Passing no-sandbox to exec seems important for jenkins on windows in foreground or as service. Here's my solution

chromedriver fails on windows jenkins slave running in foreground


The Mike R's solution works for me. This is the full set of commands:

Xvfb :99 -ac -screen 0 1280x1024x24 &
export DISPLAY=:99
nice -n 10 x11vnc 2>&1 &

Later you can run google-chrome:

google-chrome --no-sandbox &

Or start google chrome via selenium driver (for example):

ng e2e --serve true --port 4200 --watch true

Protractor.conf file:

capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        'args': ['no-sandbox']
    }
},

I finally managed to get Selenium tests starting the Chrome Driver on my laptop (server).

The important bit is to use Xvfb. Don't ask me why but once you accept this fact follow these steps (more detailed than @Anon answer)

  • In you Jenkins settings add a global property

    key : DISPLAY
    value:0:0
    
  • On your server start Xvfb in the background:

     Xvfb :0 -ac -screen 0 1024x768x24 &
    

Exporting the DISPLAY variable is definitely the solution but depending on your setup you may have to do this in a slightly different way.

In my case, I have two different processes: the first one starts Xvfb, the other one launches the tests. So my shell scripting knowledge is a bit rusty but I figured out that exporting the DISPLAY variable from the first process didn't make it available in the second process.

Fortunately, Selenium WebDriver allows you to 'redefine' your environment. This is my function for creating a driver for Chrome in JS. Pretty sure the equivalent exists for your programming language:

const caps = require('selenium-webdriver/lib/capabilities');
const chrome = require('selenium-webdriver/chrome');
const chromedriver = require('chromedriver');

module.exports = function (cfg) {
    let serviceBuilder = new chrome.ServiceBuilder(chromedriver.path);
    let options = chrome.Options.fromCapabilities(caps.Capabilities.chrome());
    let service;
    let myENV = new Map();

    // 're-export' the `DISPLAY` variable
    myENV.set('DISPLAY', ':1');
    serviceBuilder.setEnvironment(myENV);

    service = serviceBuilder.build();

    options.addArguments('disable-setuid-sandbox');
    options.addArguments('no-sandbox');
    options.addArguments('allow-insecure-localhost');
    options.excludeSwitches('test-type');

    return chrome.Driver.createSession(options, service);
};

  1. Check that you use ChromeDriver version that corresponds to your Chrome version
  2. In case you are on Linux without graphical interface "headless" mode must be used

Example of WebDriverSettings.java :

...
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--no-sandbox");
options.addArguments("--headless"); //!!!should be enabled for Jenkins
options.addArguments("--disable-dev-shm-usage"); //!!!should be enabled for Jenkins
options.addArguments("--window-size=1920x1080"); //!!!should be enabled for Jenkins
driver = new ChromeDriver(options);
...

Not sure if this is stopping everyone else, but I resolved this by upgrading chromedriver and then ensuring that it was in a place that my user could read from (it seems like a lot of people encountering this are seeing it for permission reasons like me).

On Ubuntu 16.04: 1. Download chromedriver (version 2.37 for me) 2. Unzip the file 3. Install it somewhere sensible (I chose /usr/local/bin/chromedriver)

Doesn't even need to be owned by my user as long as it's globally executable (sudo chmod +x /usr/local/bin/chromedriver)


I am running a similar setup: Selenium 3.40, Chrome 61, chromedriver 2.33 running with xvfb on ubuntu 16.04.

I was getting the same Chrome error intermittently. It seems that sometimes, the chromedriver fails to cleanup the temp files associated with the Chrome profile.

A workaround for me is to cleanup the temp files before running tests:

rm -rf /tmp/.org.chromium.Chromium*

I expect this will be resolved in future versions of chromedriver, but for now this solves the problem in my case.


I increase max memory to start node-chrome with -Xmx3g, and it's work for me


We had the same issue while trying to launch Selenium tests from Jenkins. I had selected the 'Start Xvfb before the build, and shut it down after' box and passed in the necessary screen options, but I was still getting this error.

It finally worked when we passed in the following commands in the Execute Shell box.

Xvfb :99 -ac -screen 0 1280x1024x24 & nice -n 10 x11vnc 2>&1 & ... killall Xvfb


I had simillar issue with maven tests on x86 linux which i was using in terminal. I was logging in to linux by ssh. I started my java selenium tests by

mvn -DargLine="-Dbaseurl=http://http://127.0.0.1:8080/web/" install

Excepting my app, after running these tests I received error in logs:

unknown error: Chrome failed to start: exited abnormally

I was running these tests as root user. Before this error i received that ChromeDriver is nor present. I moved forward with this by installing ChromeDriver binary and adding it to PATH. But then i had to install google-chrome browser - ChromeDriver alone isn't enough to run tests. So the mistake is problem maybe with screen buffer in terminal window, but You can install Xvfb which is virtual screen buffer. What is important, that you should run your tests not as root, because you may receive another Chrome Browser error. So no as root i run:

export DISPLAY=:99
Xvfb :99 -ac -screen 0 1280x1024x24 &

What is important here, that in my case the number related to DISPLAY ought to be same as Xvfb :NN parameter. 99 in that case. I had another problem because i ran Xvfb with another DISPLAY value and I wanted it to stop. In order to restart Xvfb:

ps -aux | grep Xvfb
kill -9 PID
sudo rm /tmp/.X11-unix/X99

So find a process PID with grep. Kill Xvfb process. And then there is lock in /tmp/.X11-unix/XNN , so delete this lock and you can start server again. If You run not as root, set simillar displays, install google-chrome then with maven you can start selenium tests. My tests went fine with these rules and operations.


Are you passing the DISPLAY parameter to your Jenkins job?

I assume you are trying to execute the tests in headless mode, too. So setup some x service (i.e. Xvfb) and pass the DISPLAY number to your job. Worked for me.


You don't need Xvfb

It is failing to start due to a mismatch between the chrome version and the chromedriver version. Downloading and installing the same versions or latest versions would solve the issue.


I was trying to run selenium on Jenkins with Mocha framework using wdio. So following are the steps to solve this issue:-

Install google chrome

sudo apt-get update 

sudo apt-get install google-chrome-stable

Install chrome-driver

wget http://chromedriver.storage.googleapis.com/2.23/chromedriver_linux64.zip
unzip chromedriver_linux64.zip

Run following commands to start selenium web server

nohup sudo Xvfb :10 -ac
export DISPLAY=:10
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver"

After this start you tests with wdio command

wdio wdio.conf.js

I've been fighting with this issue for a long time, and just y'day I figure out how to make it gone and today I can run a 50 threads process calling selenium without seen this issue anymore and also stop crashing my machine with outofmemory issue with too many open chromedriver processes.

  1. I am using selenium 3.7.1, chromedrive 2.33, java.version: '1.8.0', redhat ver '3.10.0-693.5.2.el7.x86_64', chrome browser version: 60.0.3112.90;
  2. running an open session with screen, to be sure my session never dies,
  3. running Xvfb : nohup Xvfb -ac :15 -screen 0 1280x1024x16 &
  4. export DISPLAY:15 from .bashsh/.profile

these 4 items are the basic setting everyone would already know, now comes the code, where all made a lot of difference to achieve the success:

public class HttpWebClient {
    public static ChromeDriverService service;
    public ThreadLocal<WebDriver> threadWebDriver = new ThreadLocal<WebDriver>(){
    @Override
    protected WebDriver initialValue() {
        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("permissions.default.stylesheet", 2);
        profile.setPreference("permissions.default.image", 2);
        profile.setPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
        profile.setPreference(FirefoxProfile.ALLOWED_HOSTS_PREFERENCE, "localhost");
        WebDriver driver = new FirefoxDriver(profile);
        return driver;
    };
};

public HttpWebClient(){
    // fix for headless systems:
    // start service first, this will create an instance at system and every time you call the 
    // browser will be used
    // be sure you start the service only if there are no alive instances, that will prevent you to have 
    // multiples chromedrive instances causing it to crash
    try{
        if (service==null){
            service = new ChromeDriverService.Builder()
            .usingDriverExecutable(new File(conf.get("webdriver.chrome.driver"))) // set the chromedriver path at your system
            .usingAnyFreePort()
            .withEnvironment(ImmutableMap.of("DISPLAY", ":15"))
            .withSilent(true)
            .build();
            service.start();
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

// my Configuration class is for good and easy setting, you can replace it by using values instead.
public WebDriver getDriverForPage(String url, Configuration conf) {
    WebDriver driver = null;
    DesiredCapabilities capabilities = null;
    long pageLoadWait = conf.getLong("page.load.delay", 60);

    try {
            System.setProperty("webdriver.chrome.driver", conf.get("webdriver.chrome.driver"));
            String driverType = conf.get("selenium.driver", "chrome");

        capabilities = DesiredCapabilities.chrome();
        String[] options = new String[] { "--start-maximized", "--headless" };
        capabilities.setCapability("chrome.switches", options);

                    // here is where your chromedriver will call the browser
                    // I used to call the class ChromeDriver directly, which was causing too much problems 
                    // when you have multiple calls
        driver = new RemoteWebDriver(service.getUrl(), capabilities);

        driver.manage().timeouts().pageLoadTimeout(pageLoadWait, TimeUnit.SECONDS);
        driver.get(url);

                    // never look back

    } catch (Exception e) {
        if (e instanceof TimeoutException) {
            LOG.debug("Crawling URL : "+url);
            LOG.debug("Selenium WebDriver: Timeout Exception: Capturing whatever loaded so far...");
            return driver;
        }
        cleanUpDriver(driver);
        throw new RuntimeException(e);
    }
    return driver;
}

public void cleanUpDriver(WebDriver driver) {
    if (driver != null) {
        try {
                            // be sure to close every driver you opened
            driver.close();
            driver.quit();
            //service.stop(); do not stop the service, bcz it is needed
            TemporaryFilesystem.getDefaultTmpFS().deleteTemporaryFiles();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

}

Good luck and I hope you don't see that crash issue anymore

Please comment your success

Best regards,


Examples related to selenium

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser Class has been compiled by a more recent version of the Java Environment How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? element not interactable exception in selenium web automation Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception?

Examples related to selenium-webdriver

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception? Scrolling to element using webdriver? Only local connections are allowed Chrome and Selenium webdriver Check if element is clickable in Selenium Java

Examples related to selenium-chromedriver

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? Python Selenium Chrome Webdriver selenium - chromedriver executable needs to be in PATH Only local connections are allowed Chrome and Selenium webdriver How to set "value" to input web element using selenium? Can a website detect when you are using Selenium with chromedriver?