Selenium: Support for headless chrome

Created on 4 May 2017  路  6Comments  路  Source: SeleniumHQ/selenium

Hi!

Since version 58, Chrome can run in headless mode. I wanted to try it out with the following code:

Selenium::WebDriver.for :chrome, switches: %w[--disable-gpu --headless]

This resulted with Selenium::WebDriver::Error::UnknownError: unknown error: unrecognized Chrome version: HeadlessChrome/58.0.3029.96 so I tried:

Selenium::WebDriver.for :chrome, switches: %w[--disable-gpu --headless --remote-debugging-port=9222], port: 9222

But the result was Net::ReadTimeout: Net::ReadTimeout.

Most helpful comment

@lmtierney My bad. I was looking at this list of chromedrivers and was under the impression that 2.9 was newer than 2.33.

All 6 comments

Hi, I'm having a similar issue:驴. I'm unable to start the browser in a headless mode.

https://github.com/SeleniumHQ/selenium/issues/3970

this is with C#.

This is working fine for me on Ubuntu with Chrome 58, Chromedriver 29, selenium-webdriver 3.4

lucas@lucas-VirtualBox:~$ gem list selenium-webdriver

*** LOCAL GEMS ***

selenium-webdriver (3.4.0)
lucas@lucas-VirtualBox:~$ chromedriver --version
ChromeDriver 2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5)
lucas@lucas-VirtualBox:~$ chrome --version
Google Chrome 58.0.3029.81 
lucas@lucas-VirtualBox:~$ irb
irb(main):001:0> require "selenium-webdriver"
=> true
irb(main):002:0> d = Selenium::WebDriver.for :chrome, switches: %w[--disable-gpu --headless]
=> #<Selenium::WebDriver::Driver:0x4f1c0ba0332db846 browser=:chrome>
irb(main):003:0> d.get('http://www.google.com')
=> nil
irb(main):004:0> d.title
=> "Google"

Please provide concise reproducible test case so that we can act on this issue. Once this is done the issue will be re-opened. See CONTRIBUTING.md

This is working fine for me on Mac with Chrome canary, selenium-webdriver 3.4
changes in config file...
====>
var readline = require('readline')
var hasTriggered = false

exports.config = {

specs: [
    // './test/desktop/specs/**/*.js'
],

capabilities: [{
    browserName: 'chrome',
    chromeOptions: {
        // run in headless mode
        args: ['--headless'],
        // point to your Canary version as it is only supported there
        binary: '/Applications/Google Chrome Canary.app/Contents/MacOS/Canary'
    }
}],
framework: 'mocha',
mochaOpts: {
    timeout: 10000
}

}

I'm using Chromium headless with Chimp and am having a similar issue. I believe it has to do with Chromedriver. Chromedriver 2.33 works fine, but Chromedriver 2.9 gives me this error

[chimp][helper] setupBrowserAndDDP had error
{ Error: unknown error: unrecognized Chrome version: HeadlessChrome/63.0.3238.0
    at initBrowser (node_modules/chimp/dist/lib/chimp-helper.js:196:31)
    at Object.setupBrowserAndDDP (node_modules/chimp/dist/lib/chimp-helper.js:275:7)
    at node_modules/chimp/dist/lib/cucumberjs/hooks.js:22:24
    at node_modules/chimp/node_modules/cucumber/node_modules/meteor-promise/fiber_pool.js:124:39
    (Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.12.6 x86_64)
  message: 'unknown error: unrecognized Chrome version: HeadlessChrome/63.0.3238.0\n  (Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.12.6 x86_64)',
  type: 'RuntimeError',
  seleniumStack: 
   { status: 13,
     type: 'UnknownError',
     message: 'An unknown server-side error occurred while processing the command.',
     orgStatusMessage: 'unknown error: unrecognized Chrome version: HeadlessChrome/63.0.3238.0\n  (Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.12.6 x86_64)' } }
Error: unknown error: unrecognized Chrome version: HeadlessChrome/63.0.3238.0
    at initBrowser (node_modules/chimp/dist/lib/chimp-helper.js:196:31)
    at Object.setupBrowserAndDDP (node_modules/chimp/dist/lib/chimp-helper.js:275:7)
    at node_modules/chimp/dist/lib/cucumberjs/hooks.js:22:24
    at node_modules/chimp/node_modules/cucumber/node_modules/meteor-promise/fiber_pool.js:124:39
    (Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.12.6 x86_64)

@Windso 2.9 is extremely old. 2.33 is the latest

@lmtierney My bad. I was looking at this list of chromedrivers and was under the impression that 2.9 was newer than 2.33.

Was this page helpful?
0 / 5 - 0 ratings