2

I am trying to run my tests headless and shard both my test suites to run them in parallel. On my local machine they run in parallel, but in this headless setup they run one after the other. I am using Docker images for the web driver and protractor.

I am using the webnicer-protractor Docker image: https://hub.docker.com/r/webnicer/protractor-headless/ and am using elgalu/selenium for the web driver.

My conf.js file that I run looks like this:

exports.config = {
  //Headless
  //seleniumAddress: 'http://localhost:4444/wd/hub',
  seleniumAddress: 'http://localhost:24444/wd/hub',
  capabilities: {
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2
  },
  specs: ['Suites/AccountSettingsSuite.js', 'Suites/CloneDashboardSuite.js']
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

1 Answers1

5

Protractor headless testing on real Google Chrome browser is now possible since Chrome >= 57, Chromedriver >= 2.29 along some basic config:

capabilities: {
    browserName: 'chrome',
    chromeOptions: {
        args: ['headless', 'window-size=1920,1080']
    }
}

Another cool thing is that the window size is not limited to the current display. It is truly headless, meaning it can be as large as needed for the tests.

Some webdriver features won't work there. For instance:

browser.manage().window().setPosition();
browser.manage().window().setSize();
browser.manage().window().maximize();

You will have to identify and remove the unsupported features, other than that Google Chrome headless is working great for me.

It's important to note that for example sendKeys might trigger this error:

Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb

If there was no real display or there was no Xvfb until this was fixed on the Chrome side. The X display required error was fixed with ChromeDriver 2.31.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Leo Gallucci
  • 16,355
  • 12
  • 77
  • 110