Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running with headless chrome settings opens a visible maximized chrome instance #5949

Closed
Waterstraal opened this issue Dec 13, 2019 · 18 comments · Fixed by #5953 · May be fixed by qsays/grafana#1
Closed

Running with headless chrome settings opens a visible maximized chrome instance #5949

Waterstraal opened this issue Dec 13, 2019 · 18 comments · Fixed by #5953 · May be fixed by qsays/grafana#1
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0

Comments

@Waterstraal
Copy link

running cypress run --headless --browser chrome opens a visible maximized (it does not adhere viewportWidth and viewportHeight settings) Chrome instance. I would expect it to run headless with the correct dimensions.

Interestingly, it does report to be running chrome 78 headless:
image

Cypress: 3.8.0
OS: Microsoft Windows 10 Enterprise Version 10.0.16299 Build 16299

Originally posted by @Waterstraal in #832 (comment)

@karol-f
Copy link

karol-f commented Dec 13, 2019

Same on OSX

@knagarajan1984
Copy link

knagarajan1984 commented Dec 13, 2019

it seems to work if you use in plugins\index.js

on('before:browser:launch', (browser = {}, args) => {
   args.push('--headless')
}

But then I am loading an extension for ignoreXFrameHeaders which seems to fail. I use below line to load extensions.

args.push('--load-extension=' + extention_path); 

@jennifer-shehane jennifer-shehane added the v3.8.0 🐛 Issue present since 3.8.0 label Dec 13, 2019
@jennifer-shehane
Copy link
Member

Yes, I have confirmed that the --headless flag still opens the Chrome browser in 3.8.0.

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Dec 13, 2019
@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Dec 13, 2019
@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

@knagarajan1984 Chrome headless mode does not support extensions, so you will have to use one or the other, not both.

@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs investigating Someone from Cypress needs to look at this labels Dec 13, 2019
@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

I have a fix for this in #5953.

For a temporary workaround, you can use the pluginsfile as @knagarajan1984 mentioned above:

on('before:browser:launch', (browser = {}, args) => {
	if (browser.family === 'chrome') {   
        args.push('--headless')
	}
}

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Dec 13, 2019
@WinstonN
Copy link

WinstonN commented Dec 16, 2019

For me, on mac os, the work around does not work. The chrome browser window still opens

Below I have console logged the plugin browser object

{
  name: 'chrome',
  family: 'chrome',
  displayName: 'Chrome',
  version: '78.0.3904.108',
  path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
  majorVersion: 78,
  isHeadless: true,
  isHeaded: false
}

and the arguments after the plugin code

[
  '--test-type',
  '--ignore-certificate-errors',
  '--start-maximized',
  '--silent-debugger-extension-api',
  '--no-default-browser-check',
  '--no-first-run',
  '--noerrdialogs',
  '--enable-fixed-layout',
  '--disable-popup-blocking',
  '--disable-password-generation',
  '--disable-save-password-bubble',
  '--disable-single-click-autofill',
  '--disable-prompt-on-repos',
  '--disable-background-timer-throttling',
  '--disable-renderer-backgrounding',
  '--disable-renderer-throttling',
  '--disable-restore-session-state',
  '--disable-translate',
  '--disable-new-profile-management',
  '--disable-new-avatar-menu',
  '--allow-insecure-localhost',
  '--reduce-security-for-testing',
  '--enable-automation',
  '--disable-device-discovery-notifications',
  '--disable-infobars',
  '--autoplay-policy=no-user-gesture-required',
  '--disable-site-isolation-trials',
  '--metrics-recording-only',
  '--disable-prompt-on-repost',
  '--disable-hang-monitor',
  '--disable-sync',
  '--disable-web-resources',
  '--safebrowsing-disable-auto-update',
  '--safebrowsing-disable-download-protection',
  '--disable-client-side-phishing-detection',
  '--disable-component-update',
  '--disable-default-apps',
  '--use-fake-ui-for-media-stream',
  '--use-fake-device-for-media-stream',
  '--disable-ipc-flooding-protection',
  '--disable-backgrounding-occluded-window',
  '--disable-breakpad',
  '--password-store=basic',
  '--use-mock-keychain',
  '--user-agent=Kathmandu Test Automation Service',
  '--proxy-server=http://localhost:65048',
  '--disable-web-security',
  '--allow-running-insecure-content',
  '--proxy-bypass-list=<-loopback>',
  '--remote-debugging-port=65052',
  '--headless'
]

however, as mentioned, the chrome browser window still shows up. When I close the chrome window, the test seems to stop running

@flotwig
Copy link
Contributor

flotwig commented Dec 16, 2019

@WinstonN interesting, what version of Chrome are you using? If you run chrome --headless from the command line, does it spawn headlessly?

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 16, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 16, 2019

The code for this is done in cypress-io/cypress#5953, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@rpocase
Copy link

rpocase commented Dec 18, 2019

@flotwig I appear to be having the same issue as @WinstonN . My index.js and similar debug information is below.

// index.js
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, args) => {
      args.push('--headless')
  })
}

Args after push:

[
  '--test-type',
  '--ignore-certificate-errors',
  '--start-maximized',
  '--silent-debugger-extension-api',
  '--no-default-browser-check',
  '--no-first-run',
  '--noerrdialogs',
  '--enable-fixed-layout',
  '--disable-popup-blocking',
  '--disable-password-generation',
  '--disable-save-password-bubble',
  '--disable-single-click-autofill',
  '--disable-prompt-on-repos',
  '--disable-background-timer-throttling',
  '--disable-renderer-backgrounding',
  '--disable-renderer-throttling',
  '--disable-restore-session-state',
  '--disable-translate',
  '--disable-new-profile-management',
  '--disable-new-avatar-menu',
  '--allow-insecure-localhost',
  '--reduce-security-for-testing',
  '--enable-automation',
  '--disable-device-discovery-notifications',
  '--disable-infobars',
  '--autoplay-policy=no-user-gesture-required',
  '--disable-site-isolation-trials',
  '--metrics-recording-only',
  '--disable-prompt-on-repost',
  '--disable-hang-monitor',
  '--disable-sync',
  '--disable-web-resources',
  '--safebrowsing-disable-auto-update',
  '--safebrowsing-disable-download-protection',
  '--disable-client-side-phishing-detection',
  '--disable-component-update',
  '--disable-default-apps',
  '--use-fake-ui-for-media-stream',
  '--use-fake-device-for-media-stream',
  '--disable-ipc-flooding-protection',
  '--disable-backgrounding-occluded-window',
  '--disable-breakpad',
  '--password-store=basic',
  '--use-mock-keychain',
  '--disable-gpu',
  '--no-sandbox',
  '--proxy-server=http://localhost:42825',
  '--proxy-bypass-list=<-loopback>',
  '--remote-debugging-port=42993',
  '--headless'
  ]

My chrome version is Google Chrome 78.0.3904.108.

@gabbersepp
Copy link
Contributor

gabbersepp commented Dec 19, 2019

@flotwig I also have the same problem as @rpocase @WinstonN .
My args :

["--test-type","--ignore-certificate-errors","--start-maximized","--silent-debugger-extension-api","--no-default-browser-check","--no-first-run","--noerrdialogs","--enable-fixed-layout","--disable-popup-blocking","--disable-password-generation","--disable-save-password-bubble","--disable-single-click-autofill","--disable-prompt-on-repos","--disable-background-timer-throttling","--disable-renderer-backgrounding","--disable-renderer-throttling","--disable-restore-session-state","--disable-translate","--disable-new-profile-management","--disable-new-avatar-menu","--allow-insecure-localhost","--reduce-security-for-testing","--enable-automation","--disable-device-discovery-notifications","--disable-infobars","--autoplay-policy=no-user-gesture-required","--disable-site-isolation-trials","--metrics-recording-only","--disable-prompt-on-repost","--disable-hang-monitor","--disable-sync","--disable-web-resources","--safebrowsing-disable-auto-update","--safebrowsing-disable-download-protection","--disable-client-side-phishing-detection","--disable-component-update","--disable-default-apps","--use-fake-ui-for-media-stream","--use-fake-device-for-media-stream","--disable-ipc-flooding-protection","--disable-backgrounding-occluded-window","--disable-breakpad","--password-store=basic","--use-mock-keychain","--proxy-server=http://localhost:51619","--proxy-bypass-list=<-loopback>","--remote-debugging-port=51622","--headless"]

@flotwig If i call ./chrome.exe and pass the same params, no window gets opened

@WinstonN
Copy link

WinstonN commented Dec 20, 2019

@flotwig apologies for the late reply
My chrome version is Version 78.0.3904.108 (Official Build) (64-bit)

@flotwig
Copy link
Contributor

flotwig commented Dec 20, 2019

Hey @WinstonN @gabbersepp @rpocase, this was a bug in Cypress and will be fixed in the next release.

@xdumaine
Copy link
Contributor

@flotwig is there a workaround that works on os x until the fix is released? I just ran into this this morning

@flotwig
Copy link
Contributor

flotwig commented Dec 20, 2019

@xdumaine Try #5949 (comment)

@xdumaine
Copy link
Contributor

xdumaine commented Dec 20, 2019

Yeah, no luck with that unfortunately, it still runs headed. Even if I always push --headless - Chrome 79, OS X 10.14.6.

As a sidenote, typescript doesn't like the action before:browser:launch nvm on the sidenote, I found our custom typings to add it to, but yeah, doesn't seem to be in the default types

If it's helpful, we're using cypress.run() from a script, not launching cypress from cli

@eaustin
Copy link

eaustin commented Dec 23, 2019

I'm seeing the same behavior as @xdumaine. We are also using cypress.run() from a script, not launching cypress from cli

@jennifer-shehane
Copy link
Member

Pending Release

The code for this is done in cypress-io/cypress#5953, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 26, 2019

Released in 3.8.1.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 30, 2019
@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release and removed type: regression A bug that didn't appear until a specific Cy version release existing workaround labels May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0
Projects
None yet
10 participants