Unable to use k6/browser in version 0.55.1 as suggested by previous releases

Hi,

My K6 version 0.55
and the below script is working fine.
import {browser} from ‘k6/experimental/browser’;
import {sleep} from ‘k6’;

export const options = {
scenarios: {
perftest: {
executor: ‘per-vu-iterations’,
options: {
browser: {
type: ‘chromium’,
},
},
},
},
}

export default async function(){
const page = browser.newPage();
try{
const response = await page.goto(‘https://testorg.stotte.no’,{waitUntil:‘networkidle’});
sleep(4);
console.log(‘Status Code:’, response.status());
}finally{
page.close();
}
}

However if I change the browser import statement to k6/browser then I see below error

ERRO[0001] Uncaught (in promise) TypeError: Object has no member ‘close’
running at default (file:///C:/Users/UX510727/K6/PageLoad1.js:24:15(33)) executor=per-vu-iterations scenario=perftest

 data_sent............: 0 B 0 B/s
 iteration_duration...: avg=506µs min=506µs med=506µs max=506µs p(90)=506µs p(95)=506µs
 iterations...........: 1   0.741877/s
 vus..................: 1   min=1      max=1
 vus_max..............: 1   min=1      max=1

As per latest version update, I should be able to use k6/browser right ? please help me.

Hey @bharatj903,
welcome to the community forum :tada:

This case is well documented on the documentation. Please check it out Migrating browser scripts to k6 v0.52 | Grafana k6 documentation.

I hope it helps.

1 Like

thank you so much for the prompt help. I was able to fix it with the link you shared. One related question to this script, can I use handle summary function to fetch html report from the above script ??