unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9
Asked Answered
T

17

92

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

Tempo answered 21/3, 2014 at 11:55 Comment(1)
Any one able to run in non-headless mode from jenkinsSteffy
T
64

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 &
    
Tempo answered 15/5, 2014 at 8:32 Comment(5)
Adding export DISPLAY=:XX where XX is number of display solves probllem for meIndaba
Thanks for the help! Also, a note that would have helped me: Setting global variables is done via "Manage Jenkins -> Configure System -> Global Properties"Nevarez
Should this be value:0:0 or value: :0?Maguire
Xvfb provides for a virtual display to render the browser onto. Possibly running tests in headless mode could also mitigate the need of rendering the browser that selenium otherwise spawns onto the virtual display.Wetmore
so this comes closest to my error. I voided my X11 session by ssh localhost ing to update my groups without restarting the X-Session. Persistently firefox and chrome failed in a similar way.Phonogram
R
16

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.

Restorative answered 25/3, 2014 at 17:34 Comment(2)
I am not trying to execute the tests in headless mode because I am using a laptop and I have set the screen to stay on even when the lid is closed. But may be I should try in headless mode?Tempo
Was having this problem on a headless server, making sure DISPLAY was set correctly fixed my problem! Thanks!Hers
T
15
  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);
...
Templia answered 10/1, 2020 at 9:27 Comment(2)
Thanks that was what I was missing. Works perfectlyEaves
How wonderful! it works with alpine linux, chromium 86, php! right nowSnashall
B
11

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
Bogus answered 22/8, 2016 at 7:34 Comment(0)
V
5

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']
    }
},
Vermillion answered 23/6, 2017 at 6:22 Comment(2)
xvfb is a virtual screen somehow it helps if you use terminal only: en.wikipedia.org/wiki/XvfbSkye
"somehow" is because a browser is a graphical application that requires a display to render anythingFaitour
I
3

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

Incontrovertible answered 16/8, 2016 at 21:29 Comment(2)
I had use no-sandbox while using chrome in a docker container in headless mode (selenium-webdriver 3 & Ruby on Rails).Maguire
Running it as root doesn't work unless you use --no-sandbox and many Docker containers run things as root, and some (scarily configured) Jenkins nodes may use root as well. Another option you can add is --headless which helps avoid the need for Xvfb entirely. You may also need --disable-dev-shm-usage specifically in Docker, or you need to bind mount that device in your run with --mount type=bind,source=/dev/shm,target=/dev/shm.Colly
T
3

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")
Theater answered 31/1, 2020 at 18:54 Comment(1)
no sandbox was the issue as chromedriver does not allow running in sudo in linux without that commanVile
J
2

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

Jilt answered 9/2, 2017 at 15:31 Comment(2)
Are you able to run in non-headless modeSteffy
Thanks, the first line fixed a chrome driver script for me :)Lasser
L
2

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.

Lou answered 20/10, 2017 at 13:58 Comment(0)
S
1

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,

Starwort answered 24/11, 2017 at 12:54 Comment(0)
S
1

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.

Saltigrade answered 13/12, 2019 at 11:32 Comment(0)
S
0

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);
};
Svetlana answered 3/4, 2017 at 8:2 Comment(1)
You can execute your xvfb starting script in current shell context environment (#16618571): . xvfb.shVermillion
S
0

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.

Skye answered 11/9, 2017 at 9:25 Comment(0)
N
0

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)

Nevarez answered 2/4, 2018 at 22:0 Comment(0)
I
0

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

Intellectual answered 22/7, 2019 at 13:50 Comment(0)
M
0

In my Ubuntu server, following solve the issue

Xvfb :11 -ac -screen 0 1024x768x24 &
export DISPLAY=:11

python selenium_test.py

killall Xvfb 

dont use the last line if you have multiple Xvfb process are running at the same time.

Mackenzie answered 14/9, 2021 at 14:5 Comment(0)
A
0

I had same error if I run python script inside docker container and forgot "--headless" option.

Arcograph answered 7/1, 2023 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.