Redirect does not work with httpCredentials

The code being tested has js that redirects the user, using
document.location = "http://localhost/somePage.html";
But nothing happens, it sits there with a page loading in the browser (running headless:false)

Note: testing this in a browser, not through k6 runs as expected, it redirects to somepage.html

And it tried this on a server that does not have basic auth, and it redirects as expected.

Otherwise, many thanks for the k6 tool in general.

import { browser } from 'k6/experimental/browser';
import { sleep } from 'k6';

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

export default async function () {
  const page = browser.newPage({
    "httpCredentials": {
      "username": __ENV.STAGING_WEB_USER,
      "password": __ENV.STAGING_WEB_PASSWORD,

  try {
    await page.goto('http://localhost/img/test-redir.html');
  } finally {

I created a simple version of the page to demonstrate test-redir.html

	test redirect
                document.location = "http://localhost/somePage.html";

1 Like

Hi @kevindrew,

Thank you for providing the test script and HTML page. We’re able to reproduce the issue, and it looks like a bug. I’ve reported the issue on our repository here.

Thank you

1 Like