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 neo355/grafana#2
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 neo355/grafana#2

Comments

@Waterstraal
Copy link

@Waterstraal Waterstraal commented Dec 13, 2019

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

This comment has been minimized.

Copy link

@karol-f karol-f commented Dec 13, 2019

Same on OSX

@knagarajan1984

This comment has been minimized.

Copy link

@knagarajan1984 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

This comment has been minimized.

Copy link
Member

@jennifer-shehane jennifer-shehane commented Dec 13, 2019

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

@flotwig

This comment has been minimized.

Copy link
Member

@flotwig 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.

@flotwig

This comment has been minimized.

Copy link
Member

@flotwig 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')
	}
}
@WinstonN

This comment has been minimized.

Copy link

@WinstonN 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

This comment has been minimized.

Copy link
Member

@flotwig 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

This comment has been minimized.

Copy link

@cypress-bot 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

This comment has been minimized.

Copy link

@rpocase 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

This comment has been minimized.

Copy link
Contributor

@gabbersepp 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

This comment has been minimized.

Copy link

@WinstonN 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

This comment has been minimized.

Copy link
Member

@flotwig flotwig commented Dec 20, 2019

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

@xdumaine

This comment has been minimized.

Copy link

@xdumaine xdumaine commented Dec 20, 2019

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

@flotwig

This comment has been minimized.

Copy link
Member

@flotwig flotwig commented Dec 20, 2019

@xdumaine

This comment has been minimized.

Copy link

@xdumaine 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

This comment has been minimized.

Copy link

@eaustin 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

This comment has been minimized.

Copy link
Member

@jennifer-shehane jennifer-shehane commented Dec 24, 2019

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

This comment has been minimized.

Copy link

@cypress-bot 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
10 participants
You can’t perform that action at this time.