ChromeDriver keeps crashing on Jenkins Selenium Job: "WebDriverError: Chrome failed to start: crashed"
<p>I am trying to run some automated tests on <strong>Jenkins</strong> using <strong><a href="http://www.protractortest.org/#/" rel="nofollow noreferrer">protractor</a></strong> which uses <strong>selenium</strong> and <strong>chromedriver</strong>.</p>

<p>I have also setup <strong>xvfb</strong> so that we can run these tests in a <strong>headless</strong> manner. I have the <strong>xvfb jenkins plugin</strong> installed and it is working correctly.</p>

<hr>

<h1>Error</h1>

<p>The problem I'm having, is when I start the tests, chrome keeps crashing. I get this error:</p>

<pre><code>E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
...
E/launcher - Process exited with error code 199
</code></pre>

<hr>

<h1>Setup</h1>

<p>Here is the information I have on the setup of the system:</p>

<ul>
<li><strong>Chrome</strong>

<ul>
<li>Location: <code>/usr/bin/google-chrome</code></li>
<li>Version: Chromium 52.0.2743.0</li>
</ul></li>
<li><strong>ChromeDriver</strong>

<ul>
<li>Location: <code>{project_home}/src/js/node_modules/webdriver-manager/selenium/chromedriver_2.24</code></li>
<li>Version: ChromeDriver 2.24.417424</li>
</ul></li>
<li><strong>Selenium</strong>

<ul>
<li>Location: <code>{project_home}/src/js/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar</code></li>
<li>Version: 2.53.1</li>
</ul></li>
<li><strong>Protractor</strong>

<ul>
<li>Location: <code>{project_home}/src/js/node_modules/protractor</code></li>
<li>Version: 4.0.9</li>
</ul></li>
<li><strong>WebDriver Manager</strong>

<ul>
<li>Location: <code>{project_home}/src/js/node_modules/webdriver-manager</code></li>
<li>Version: 10.2.4</li>
</ul></li>
<li><strong>Jenkins</strong>

<ul>
<li>Version: 1.6.17</li>
</ul></li>
<li><strong>xvfb</strong> 

<ul>
<li>Version: Unknown</li>
</ul></li>
<li><strong>Node</strong>

<ul>
<li>Version: 6.7</li>
</ul></li>
<li><strong>Java</strong>

<ul>
<li>Version: java-8-openjdk-amd64</li>
</ul></li>
</ul>

<hr>

<h1>Output</h1>

<p>Here is the console output from Jenkins:</p>

<pre><code>...
21:58:07.380 INFO - Launching a standalone Selenium Server
21:58:07.407 INFO - Java: Oracle Corporation 25.111-b14
21:58:07.407 INFO - OS: Linux 4.4.0-47-generic amd64
21:58:07.418 INFO - v2.53.1, with Core v2.53.1. Built from revision a36b8b1
21:58:07.473 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
21:58:07.474 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
21:58:07.474 INFO - Driver class not found: com.opera.core.systems.OperaDriver
21:58:07.474 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
21:58:07.475 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
21:58:07.475 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
21:58:07.475 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
21:58:07.527 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
21:58:07.527 INFO - Selenium Server is up and running
Current webdriver status: [21:58:08] I/status - selenium standalone version available: 2.53.1 [default]
[21:58:08] I/status - chromedriver versions available: 2.22, 2.24 [default]
[21:58:08] I/status - geckodriver version available: v0.9.0 [default]
[21:58:08] I/status - android-sdk is not present
[21:58:08] I/status - appium is not present
**** STARTING GUI TESTS ****


Running ./node_modules/protractor/bin/protractor conf-server.js
[21:58:08] I/local - Starting selenium standalone server...
[21:58:08] I/launcher - Running 1 instances of WebDriver
[21:58:09] I/local - Selenium standalone server started at http://10.0.0.82:33509/wd/hub
[21:59:09] E/launcher - unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.17 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[21:59:09] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.17 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at WebDriverError ({project_home}/src/js/node_modules/selenium-webdriver/lib/error.js:27:5)
    at Object.checkLegacyResponse ({project_home}/src/js/node_modules/selenium-webdriver/lib/error.js:639:15)
    at parseHttpResponse ({project_home}/src/js/node_modules/selenium-webdriver/http/index.js:538:13)
    at client_.send.then.response ({project_home}/src/js/node_modules/selenium-webdriver/http/index.js:472:11)
    at ManagedPromise.invokeCallback_ ({project_home}/src/js/node_modules/selenium-webdriver/lib/promise.js:1379:14)
    at TaskQueue.execute_ ({project_home}/src/js/node_modules/selenium-webdriver/lib/promise.js:2913:14)
    at TaskQueue.executeNext_ ({project_home}/src/js/node_modules/selenium-webdriver/lib/promise.js:2896:21)
    at asyncRun ({project_home}/src/js/node_modules/selenium-webdriver/lib/promise.js:2820:25)
    at {project_home}/src/js/node_modules/selenium-webdriver/lib/promise.js:639:7
    at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
    at Function.createSession ({project_home}/src/js/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
    at Builder.build ({project_home}/src/js/node_modules/selenium-webdriver/builder.js:458:24)
    at Local.DriverProvider.getNewDriver ({project_home}/src/js/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
    at Runner.createBrowser ({project_home}/src/js/node_modules/protractor/built/runner.js:198:43)
    at {project_home}/src/js/node_modules/protractor/built/runner.js:277:30
    at _fulfilled ({project_home}/src/js/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done ({project_home}/src/js/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch ({project_home}/src/js/node_modules/q/q.js:796:13)
    at {project_home}/src/js/node_modules/q/q.js:604:44
    at runSingle ({project_home}/src/js/node_modules/q/q.js:137:13)
[21:59:09] E/launcher - Process exited with error code 199
</code></pre>

<hr>

<h1>Protractor Config</h1>

<pre><code>exports.config = {
  seleniumServerJar: './node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar',
  chromeDriver: './node_modules/webdriver-manager/selenium/chromedriver_2.24',

  capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
      binary: '/usr/bin/google-chrome',
      args: ['--enable-logging','--v=1'],
      extensions: []
    }
  },

  framework: 'custom',
  frameworkPath: require.resolve('./node_modules/protractor-cucumber-framework'),
  specs: [
      '../../features/gui/active/*.feature'
  ],

  onPrepare: function ()
  {
    require('babel-register')({ presets : ['es2015'] })
  }
};
</code></pre>

<hr>

<h1>Jenkins xvfb plugin</h1>

<p><a href="https://i.stack.imgur.com/sSElQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sSElQ.jpg" alt="xvfb configuration"></a></p>

<hr>

<h1>Related</h1>

<ul>
<li>Chrome reference: <a href="https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start" rel="nofollow noreferrer">https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start</a></li>
<li><a href="https://stackoverflow.com/questions/22558077/unknown-error-chrome-failed-to-start-exited-abnormally-driver-info-chromedri">unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9</a> suggests configuring xvfb</li>
<li><a href="https://stackoverflow.com/questions/37692793/webdrivererror-unknown-error-chrome-failed-to-start-exited-abnormally?rq=1">WebDriverError: unknown error: Chrome failed to start: exited abnormally</a> unsolved</li>
<li><a href="https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8409" rel="nofollow noreferrer">https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/8409</a> suggests using <a href="https://github.com/angular/protractor/blob/master/docs/server-setup.md" rel="nofollow noreferrer">direct connect</a>: "Protractor can test directly against Chrome and Firefox without using a Selenium Server. To use this, in your config file set directConnect: true."</li>
<li><a href="https://stackoverflow.com/questions/21950192/selenium-webdriver-chrome-driver-not-able-to-run-chrome-driver">Selenium Webdriver &amp; Chrome driver - not able to run chrome driver</a> suggests using java 1.6 instead</li>
<li><a href="https://stackoverflow.com/questions/19030230/chrome-on-remote-webdriver-via-grid-failed-to-start">Chrome on remote webdriver (via Grid) failed to start</a> suggests using x64 chromedriver and specifying it in a parameter</li>
</ul>