Headless Chrome causing tests to fail?

See original GitHub issue

I have written a number of tests that successfully pass when running through the Chrome Driver normally, however if running with Headless Chrome, all of the tests fail. As they cannot find the element and instead timeout. I have tried passing the window-size argument, but that didn’t resolve the issue.

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

The error thrown by Jasmine…

An element could not be located on the page using the given search parameters.

  • WebdriverIO version: 4.14.1
  • Mode: WDIO Testrunner
  • If WDIO Testrunner, running sync/async: sync
  • Node.js version: v8.11.2
  • NPM version: 5.6.0
  • Browser name and version: Chrome 66
  • Platform name and version: Windows 7
  • Additional wdio packages used (if applicable): wdio-jasmine-framework

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
mgrybykcommented, Jul 4, 2019

@CharuDattPimple without any logs it is impossible to say what is going wrong. From what I see you have invalid arguments.

I’d recommend to capture as much logs as possible, quite often at this point it is clear enough what went wrong. Also, running chrome in headless depends on the environment, are you running it in docker?

Here is my config:

'goog:chromeOptions': {
  args: ['--headless', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage', '--window-size=1920,1080']
}
3reactions
emilyrohrboughcommented, Dec 14, 2018

Depending on the chromedriver version you are using, you should actually be specifying goog:chromeOptions instead of chromeOptions, but you should be able to drop the -- before your args. Theses are for running the drive via the command line. Try something like:

  capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ['headless', 'disable-gpu'],
    },
  }],
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

selenium tests fail against headless chrome - Stack Overflow
I am trying to get my selenium test automation to run against headless chrome so that I can move it to TeamCity. I...
Read more >
Headless testing on Chrome browser fails few times for no ...
There are many things that could cause tests to fail in headless and pass in head mode. The most likely cause is timing....
Read more >
What are the limitations of chrome headless browser?
While test case counts are persistently increased test cases are caused fatal memory exception in phantom JS. so finally we are jumped into...
Read more >
Selenium Java Code Runs Test Successfully But Fails When ...
join with Github I have written a number of tests that successfully pass when running through the Chrome Driver normally however if running...
Read more >
Flags don't work when running headless? - Google Groups
... some of my tests to fail. If I do: Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found