Error trying to use browser module: "browser not found in registry"

Trying to use the browser module but getting this error:

ERRO[0001] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module

Running k6 on Windows 10, version:

k6.exe v0.52.0 (go1.22.2, windows/amd64)
Extensions:
xk6-output-influxdb v0.4.3, xk6-influxdb [output]
xk6-sql v0.4.0, k6/x/sql [js]

I run it like this:

k6 run .\BrowserTest.js

This is my script

import { browser } from ‘k6/browser’;

let sharedContext;

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

export function setup() {
sharedContext = browser.newContext();
}

export default async function () {
const page = await browser.newPage();
try {
await page.goto(‘https://test.k6.io/’);
} finally {
page.close();
}
}

export function teardown() {
sharedContext.close();
}

Hi @mmcdonald2 , welcome to the community forum!

It works for me if I remove the browser.newContext(); call from the setup() function

1 Like

That worked, thank you!

1 Like