Configuring Authentication Options for Chromium in K6 Browser Script

Dear all,

I am reaching out for assistance with a specific behavior I’ve encountered in my K6 script that utilizes the experimental browser feature. In my setup, when executing the script, it bypasses the authentication step and automatically logs into the application. I suspect this automatic login is facilitated by OIDC (OpenID Connect) configurations.

To provide a bit more context, in my Playwright scripts, I am able to control this behavior by specifying launch options for Chromium, as shown below:

{
name: ‘chromium-local’,
use: {
…devices[‘Desktop Chrome’],
headless: false,
launchOptions: {
args: [‘–auth-server-whitelist=“*”’],
},
},
}

These settings effectively prompt for manual username and password input, preventing automatic sign-in. I am seeking to replicate this manual login process in my K6 script, ensuring it does not automatically authenticate. Below is the script where I wish to incorporate similar behavior:

import { browser } from ‘k6/experimental/browser’;

export const options = {
scenarios: {
ui: {
executor: ‘shared-iterations’,
options: {
browser: {
type: ‘chromium’,
},
},
},
},
}

export default async function () {
const page = browser.newPage();

try {
await page.goto(‘https://endurance.internal.epo.org/inbox-osa/inbox/’, { waitUntil: ‘networkidle’ });
page.screenshot({ path: ‘screenshots/screenshot.png’ });
} finally {
page.close();
}
}

I would greatly appreciate any guidance on configuring the K6 browser script to prompt for a username and password instead of auto-authenticating. Specifically, I’m looking for ways to pass Chromium launch arguments (similar to my Playwright setup) or any other recommended approach to achieve this.

Thank you in advance for your assistance.

Hi @pbains1

You can configure chromium with environment variables.
Try something like this:

K6_BROWSER_HEADLESS=false K6_BROWSER_ARGS="auth-server-whitelist=*" k6 run script.js

Hello bandorko,

Thanks for you quick reply. I have tried a few things such as:

$env:K6_BROWSER_ARGS=“auth-server-whitelist=”
$env:K6_BROWSER_ARGS=“auth-server-allowlist="
$env:K6_BROWSER_ARGS="disable-auth-server-allowlist=

But browser authentication is not disabled, the user is automatically logged in. Have you managed to get something working?

Any update on this configuration, me too face the same issue how can we bypass the credentials using k6 browser , in playwright we did by setting the HTTP credentials in browser context options is it possible in k6?