Running Chrome Headless AND Incognito?

1,294 views
Skip to first unread message

Ory Zaidenvorm

unread,
Jun 13, 2022, 11:10:55 PM6/13/22
to ChromeDriver Users
Hey all,

We've encountered an issue where it does not seem that running Chrome in Headless AND Incognito mode works. The symptom is that due to corporate SSO, when not running in incognito OKTA will auto sign the user in based on their corporate credentials. So in normal Chrome setting the incognito option solves this issue. However in Headless, even with the incognito option, SSO is still triggered and the user gets auto signed in.

Some information on our setup: 
- Selenium C# implementation
- Chrome v102

Our code to instantiate ChromeDriver:
ChromeOptions CHLOptions = new ChromeOptions();
string userAgent =
    "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36";
CHLOptions.AddAdditionalChromeOption("useAutomationExtension", false);
CHLOptions.AddArgument("--incognito");
CHLOptions.AddArgument("start-maximized");
CHLOptions.AddArgument("ignore-certificate-errors");
CHLOptions.AddArguments("headless");
CHLOptions.AddArgument("window-size=1600,1200");
CHLOptions.AddArgument("no-sandbox");
CHLOptions.AddArgument("enable-logging");
CHLOptions.AddArgument(userAgent);
driver = new ChromeDriver(CHLOptions);


I've searched both here and in StackOverflow and found the following threads:

But both of them (aside from giving us an indication we're not alone in our woes) give no more information on why it happens or how to solve it.

So my questions are:
1. Is anyone running successfully Chrome in Headless AND Incognito modes?
2. Is there some limitation on headless to be run with other options such as incognito?

Any thoughts appreciated, before I go ahead and raise it as an issue.

Cheers,
Ory

Troy Kerr

unread,
Jun 28, 2022, 9:40:47 PM6/28/22
to ChromeDriver Users
Having the same issue and came across this thread while looking for a solution. I am using Cypress but the same issue, I need to run tests incognito and it doesn't seem to work in headless mode.

Mathias Bynens

unread,
Jun 29, 2022, 3:00:23 AM6/29/22
to Troy Kerr, ChromeDriver Users, Peter Kvitek, Andrey Kosyakov
Peter, does this ring any bells?

--
You received this message because you are subscribed to the Google Groups "ChromeDriver Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-us...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chromedriver-users/21392c86-7291-4c0f-9572-5f3fd09ac3b0n%40googlegroups.com.

Peter Kvitek

unread,
Jun 29, 2022, 12:29:03 PM6/29/22
to Mathias Bynens, Troy Kerr, ChromeDriver Users, Andrey Kosyakov
It does: a lot of --incognito functionality is implemented on the //chrome/browser/ side, so it is not present when the //headless browser is running.

Their best bet for now would be running Chrome in native headless mode using --incognito --headless=chrome

/Peter

Andrey Kosyakov

unread,
Jun 29, 2022, 9:11:38 PM6/29/22
to Peter Kvitek, Mathias Bynens, Troy Kerr, ChromeDriver Users
--incognito switch itself is not supported by headless as Peter stated, because this is a chrome flag (headless is a different browser). That said, most of the actual functionality is in the content layer, the incognito mode itself is supported and is actually the default, unless --user-data-dir is passed explicitly (in other words, we won't re-use chrome browser profile by default). Is chromedriver adding --user-data-dir by chance?

Best regards,
Andrey.

Troy Kerr

unread,
Jun 29, 2022, 11:24:24 PM6/29/22
to Andrey Kosyakov, Peter Kvitek, Mathias Bynens, ChromeDriver Users
I kind of jumped in on this thread with a similar issue but I'm not using chromedriver. We are using Cypress which I believe is just using the chrome executable. Here are the switches Cypress is using when running headless:

  '--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-single-click-autofill',

  '--disable-prompt-on-repos',

  '--disable-background-timer-throttling',

  '--disable-renderer-backgrounding',

  '--disable-renderer-throttling',

  '--disable-backgrounding-occluded-windows',

  '--disable-restore-session-state',

  '--disable-new-profile-management',

  '--disable-new-avatar-menu',

  '--allow-insecure-localhost',

  '--reduce-security-for-testing',

  '--enable-automation',

  '--disable-print-preview',

  '--disable-device-discovery-notifications',

  '--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-download-protection',

  '--disable-client-side-phishing-detection',

  '--disable-component-update',

  "--simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT'",

  '--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-dev-shm-usage',

  '--proxy-server=http://localhost:52405',

  '--disable-web-security',

  '--allow-running-insecure-content',

  '--proxy-bypass-list=<-loopback>',

  '--headless',

  '--window-size=1280,720',

  '--force-device-scale-factor=1',

  '--remote-debugging-port=52412',

  '--remote-debugging-address=127.0.0.1',

  

I added '--incognito', to try and get it to run headless and incognito but it wasn't working the same is when --headed

So then after your last email I added '--headless=chrome' and now it is working for me as I expected with the incognito.

Thanks, 
Troy


From: Andrey Kosyakov
Sent: Wednesday, June 29, 2022 8:11 PM
To: Peter Kvitek
Cc: Mathias Bynens; Troy Kerr; ChromeDriver Users
Subject: Re: Running Chrome Headless AND Incognito?

Vladimir Nechaev

unread,
Jun 30, 2022, 1:47:36 AM6/30/22
to ChromeDriver Users
ChromeDriver adds --user-data-dir argument pointing to a unique temporary directory unless user manually specify another path: https://source.chromium.org/chromium/chromium/src/+/main:chrome/test/chromedriver/chrome_launcher.cc;drc=8e71b8677f674bab739791d555b1bc32df30c392;l=201

Peter Kvitek

unread,
Jul 11, 2022, 4:26:31 PM7/11/22
to Andrey Kosyakov, Mathias Bynens, Troy Kerr, ChromeDriver Users
This change adds --incognito switch handling to traditional headless mode. If this switch is specified, the default incognito mode will not be automatically disabled when --user-data-dir is present.

/Peter

Space Soft System

unread,
Jul 14, 2022, 5:40:10 AM7/14/22
to Peter Kvitek, Andrey Kosyakov, Mathias Bynens, Troy Kerr, ChromeDriver Users
  hello sir / madam

We have tried many times to contact you. I am Microsoft Visual Basic 2019 developer , and I am just learning Whatsapp automation. I use google search and youtube for whatsapp automation code and javascript code. 75% my code done for whatsapp automation but now i want add whatsapp button message like https://github.com/adiwajshing/Baileys 

adiwajshing Baileys use node js but i want same function in microsoft visual basic 2019 

its possible , if yes then please share code 

i send same mail to https://visualstudio.microsoft.com/vs/support/# but no any update tile now , today i send again , 


please reply me as soon as possible




--
===============================================
Space Soft System
Software Development Work
Software Sales & Service

Cell 73546-73546

Space Soft System

unread,
Jul 14, 2022, 5:41:18 AM7/14/22
to Vladimir Nechaev, ChromeDriver Users
  hello sir / madam

We have tried many times to contact you. I am Microsoft Visual Basic 2019 developer , and I am just learning Whatsapp automation. I use google search and youtube for whatsapp automation code and javascript code. 75% my code done for whatsapp automation but now i want add whatsapp button message like https://github.com/adiwajshing/Baileys 

adiwajshing Baileys use node js but i want same function in microsoft visual basic 2019 

its possible , if yes then please share code 

i send same mail to https://visualstudio.microsoft.com/vs/support/# but no any update tile now , today i send again , 


please reply me as soon as possible


vignesh iyer

unread,
Jul 20, 2023, 4:37:56 AM7/20/23
to ChromeDriver Users
Incognito mode is default in headless chrome. I need to disable it. Please let me know how to do it.

Thanks
Vignesh

Reply all
Reply to author
Forward
0 new messages