I am getting the below error while running a simple sample script.
ERRO[0000] TypeError: Object has no member 'launch'
at file:///Users/afsalbacker/Desktop/k6/browser.js:4:34(8)
at native executor=per-vu-iterations scenario=default source=stacktrace
My code is:
import launcher from ‘k6/x/browser’;
export default function () {
const browser = launcher.launch('chromium',{ headless: false });
const context = browser.newContext();
const page = context.newPage();
page.goto('https://ecommerce.k6.io', { waitUntil: 'networkidle' })
}
My browser does not load because of this.
s
ankur
November 24, 2022, 3:32pm
2
Hi @gm4afsal ,
Welcome to the forums!
It looks like you are using a newer version of xk6-browser
which contains a breaking change where the imports have changed.
Which version of xk6-browser
are you running or what commands did you run to build a binary?
For the latest release of xk6-browser
, this script should work:
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({ headless: false });
const context = browser.newContext();
const page = context.newPage();
page.goto('https://test.k6.io', { waitUntil: 'networkidle' })
.finally(() => {
page.close();
browser.close();
});
}
Cheers,
Ankur