Launch browser with non incognito mode

Hi Team,

I am trying to simulate a scenario where i have to open new session (without incognig).

Can you help to guide me to get it working

Hi @arvind_patel, welcome to the forum! :wave:

If I understand correctly what you are trying to achieve is to create a new browser window that would inherit the session data already present in the browser instance? Is that correct?

If that is the case, unfortunately this is currently not supported, as, by default, when opening a new page, k6 browser implicitly creates a new browser context. We have a similar issue reported that you can use to keep track of this functionality.

2 Likes

I got a workaround by creating chrome user profile before launching tests

2 Likes

Here is another case that ruins a tester life…
My test consist a step that a file is downloaded. In incognito mode, a download verification modal is displayed and asks user where to download. In non-incognito mode it’s not displayed and download starts right away. I’m setting "K6_BROWSER_ARGS=‘disable-model-download-verification’ " but it doesn’t work and disappear. So my work is ruined and I got stuck here for 10 hours! I’ve tried to apply many sort of workarounds but strictly limited to browser context. Is it really hard for you to give option to developers to switch between modes?!

1 Like

Hi @ozgurcubuk,

We would like to get a better understanding of your use case. Do you have a test script that is pointing to a publicly accessible website?

Cheers,
Ankur

1 Like

Hello @ankur,

I’m currently using k6/experimental/browser to conduct tests on a local HTML file that embeds an iframe. The iframe is responsible for loading a report, and my objective is to gather data on the number of xmlhttprequest the iframe is issuing.

Under normal circumstances, attempting such an operation would result in a cross-origin CORS issue. To prevent this, I’ve set the environment variable like below

$env:K6_BROWSER_ARGS =‘disable-web-security,user-data-dir=“./temp-chrome-profile”’;

This is intended to disable web security features for testing purposes in the browser to allow cross-origin access to the iframe content.

However the browser is always launching in Incognito mode. My understanding is that certain flags, potentially including --disable-web-security, may not be fully respected in Incognito mode, which could be contributing to the difficulties I’m facing.

Is there any workaround on how to open the browser not in Incognito mode?

Thank you

Hi @krikeri,

Welcome to the forum!

Thank you for the detailed request and feedback. I’ve taken a look to see whether there is a way to open a browserContext in non incognito mode, unfortunately (as far as I can tell) there isn’t a way. We can start chrome without the no-startup-window flag which seems to open a window in non incognito mode but currently the k6 browser module cannot work with that window.

Have you had any luck in accomplishing the same thing using other frontend tools? I’d be keen to know if there is a tool that can run a test without incognito enabled.

Cheers,
Ankur

Hello @ankur,

Thank you for the explanation. I haven’t had a chance to test this myself, but based on the discussion in Issue #8836, it seems that Puppeteer opens a browser in non-incognito mode by default.

Cheers

Hi @krikeri,

thanks for the heads up on that! I took a quick look at Puppeteer and tried to replicate it in the k6 browser module. While my experiments showed some promising results where I was able to run a test in a non incognito window, for a final solution, it requires further discussion and possibly quite a lot of changes and many more test runs to validate the solution.

I’ve added a bit more detail in this comment on issue #891.

I can’t say when we will be able to take this further as we have quite a few other things to look into at the moment.

Thanks again for the feedback!
Ankur

1 Like