playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Question] chrome runs headless with empty `launchOptions`

Open archlichking opened this issue 5 years ago • 2 comments

I have an entry in projects below

{
      name: 'chrome@pixel 4',
      use: {
        browserName: 'chromium',
        ...devices['Pixel 4'],
        channel: 'chrome',
      },
    },

If I trigger a test with it, chrome runs headed. Here is the command line args that I captured via DEBUG=pw:browser*

/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/var/folders/bg/y8y9z76d4n9369vjhdptdp1w0000gp/T/playwright_chromiumdev_profile-NYI9HC --enable-use-zoom-for-dsf=false --remote-debugging-pipe --no-sandbox --no-startup-window

However if I trigger a test with following entry in projects

{
      name: 'chrome@pixel 4',
      use: {
        browserName: 'chromium',
        ...devices['Pixel 4'],
        channel: 'chrome',
        launchOptions: {
            // setting args or not all results in extra command line args 
            args: ['some_other_arg']
        },
      },
    },

It seems that playwright adds several extra command line args to chrome

/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=/var/folders/bg/y8y9z76d4n9369vjhdptdp1w0000gp/T/playwright_chromiumdev_profile-ygtfwh --enable-use-zoom-for-dsf=false --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --disable-es3-gl-context-for-testing --no-startup-window

to be more specific, here are the extras

--headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4

I meant to set some extra command line args but found this accidentally. Is this behavior expected?

archlichking avatar Aug 11 '21 00:08 archlichking

If I trigger a test with it, chrome runs headed.

@archlichking I failed to repro this. Here's what I did:

test.spec.js
const { test, expect } = require('@playwright/test');

test('basic test', async ({ page }, workerInfo) => {
  await page.goto('https://playwright.dev/');
  const name = await page.innerText('.navbar__title');
  expect(name).toBe('Playwright');
});
playwright.config.js
const {devices} = require('@playwright/test');

module.exports = {
  projects: [
    {
      name: 'chrome@pixel 4',
      use: {
        browserName: 'chromium',
        ...devices['Pixel 4'],
        channel: 'chrome',
      },
    },
  ],
};

Running npx playwright test runs the test headless for me. Does it not for you?

aslushnikov avatar Aug 12 '21 09:08 aslushnikov

Hi @aslushnikov thanks for looking into this, it's working for me too today. Not sure why it didn't yesterday but we're all good now.

archlichking avatar Aug 12 '21 22:08 archlichking