How do we open a incognito window using 'New Context' keyword of Browser library?

‘New Context’ keyword does not launch incognito window even when we pass ‘–incognito’ option through args. It is understood that ‘New Context’ opens up a fresh browser with no cookies, extensions etc., However, It still recognizes SSO credentials and takes us to landing page of our application.

We have a config named ‘incognito’ and Our requirement is to open a normal browser window if the config value is false and it should take our SSO credentials since it is a normal browser window. If incognito == true, It should open incognito window which should redirect us to SSO login page where we need to enter credentials

Could someone assist me on opening a incognito using New Context keyword?

@yadubhushan Strange. If I do the following

test
New Browser headless=False
New Context
New Page https://login.microsoft.com
Login With Account
New Context
New Page https://login.microsoft.com
Sleep 5s

Then I have to login again in the newly opened browser window

@falcon030 Thanks for the response

Ours is SSO enabled application and it automatically logs in by recognizing my profile when I hit the URL. However, It asks me to login explicitly when I launch the URL in incognito window manually. I have been exploring if I can launch incognito window using New Context, but no luck so far

So when you do this

New Browser  headless=False
New Context  
New Page  $your_url
Sleep   5s

It automatically logs in?

That’s correct. If I do it in incognito window (manually), It does not

And if you try this?

 New Browser  headless=False    args=['--auth-server-allowlist="*"']
1 Like

See Playwright is launching SSO in incognito mode · Issue #15367 · microsoft/playwright · GitHub

2 Likes

@falcon030 Nice. It worked. I shall go through the link. Meanwhile, Could you explain what does this option do?

As far as I understand it allows all servers for Negotiate Auth servers.
https://peter.sh/experiments/chromium-command-line-switches/#auth-server-allowlist

@falcon030 Thanks