Skip to content

Support chrome --headless  #832

Closed
@brian-mann

Description

@brian-mann
Member

Change 1.

With Chrome 63 coming out we can make some big changes at Cypress.

  1. We will be able to support the debugger protocol which will enable native events
  2. We will be able to support chrome --headless

The reason we currently do not support chrome --headless is because Chrome does not support extensions in that mode. We use an extension to automate the browser and that's why its a no-go. By switching from the extension to the debugger protocol, we'll be able to get around this.

Change 2.

Once we support chrome headless I propose the following changes to the CLI:

cypress run

Currently cypress run will launch Electron headlessly. This is confusing for users because they can't see what's going on and because they don't read our docs they don't understand that we're launching Electron instead of Chrome. Due to the browser version differences, they see failures in Electron that aren't happening in Chrome.

What I propose is to change this behavior so that cypress run by default will search for Chrome and launch it in headed mode. When no Chrome is installed, it'll fall back to Electron.

Currently we support a --headed option that only applies to Electron. This was done to prevent breaking changes.

This should now switch to being the default but then enabling the user to explicitly opt into the --headless mode for both Electron + Chrome.

This will be a breaking change and could come out in Cypress 2.x.x.

Activity

self-assigned this
on Oct 26, 2017
tnhu

tnhu commented on Nov 7, 2017

@tnhu

This is important. Today I found a couple of our tests failing in CI environments but not locally using cypress app. It turns out Chrome and Electron act differently.

Is there anyway you can prioritize this feature? 2.x.x seems like too far away.

brian-mann

brian-mann commented on Nov 7, 2017

@brian-mann
MemberAuthor

Chrome and Electron act the same - the difference is the underlying version of Chromium each is using.

Electron uses Chromium 53. Your local version of Chrome likely differs. These different versions will not act exactly the same.

I can't say when this will be prioritized because all of our team members are currently working on other features. We are open source now and are accepting PR's of course. It's going to be a lot of work - likely weeks for someone to work on full time.

As for the 2.x.x - its not that far off because we use semver. Whenever we have the next breaking change we will reach 2.x.x - it could be the next release for that matter!

brian-mann

brian-mann commented on Nov 7, 2017

@brian-mann
MemberAuthor

What I would suggest is install chrome in CI and make it match the version you're running locally. We have several docker containers with this prebuilt.

Alternatively you could also run Electron locally to suss out the differences in failing tests. Plenty of users do either.

nrutman

nrutman commented on Feb 1, 2018

@nrutman

@brian-mann, has there been any consideration to either:

  1. Expose arguments to pass to chrome to run it in headless mode?
  2. Semi-regularly update the version of Chromium used in the Electron browser? It looks like it's currently 10 versions behind.

Those might be lower-hanging (?) fruit that might help close the gap.

brian-mann

brian-mann commented on Feb 1, 2018

@brian-mann
MemberAuthor

@nrutman there is already an API for doing your first bullet item: https://docs.cypress.io/api/plugins/browser-launch-api.html

The problem is that running in headless mode disables chrome extensions which prevents Cypress from working. However you can modify other arguments.

Yes, per your second bullet item we have been waiting for Electron to drop 1.8 which bumps node to 8.x.x. They are currently in beta with semi regular releases.

https://electronjs.org/releases#1.8.2-beta.4

Graham42

Graham42 commented on Feb 1, 2018

@Graham42
Contributor

Looks like should be able to load extensions for headless chrome with flags

--disable-extensions-except=/path/to/extension/
--load-extension=/path/to/extension/

Source: puppeteer/puppeteer#659 (comment)

brian-mann

brian-mann commented on Feb 1, 2018

@brian-mann
MemberAuthor

I had read somewhere about chrome headless not ever going to support extensions. I don't believe there are any configuration options that will change this. Puppeteer here is irrelevant since this is a restriction from Chrome itself.

rsudarson

rsudarson commented on Mar 30, 2018

@rsudarson

78 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CIGeneral issues involving running in a CI providerbrowser: chromecli

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @weyert@tnhu@nrutman@jrnail23@kelegorm

    Issue actions

      Support `chrome --headless` · Issue #832 · cypress-io/cypress