I am trying to run k6 script.
First getting an error as GoError: To run browser tests set env var K6_BROWSER_ENABLED=true
To resolve the above issue I try to run the script using $Env: K6_BROWSER_ENABLED=‘true’; k6 run browser-test.js
But again getting an error
Need help
Hi @ankushakhotele1, welcome to the community forum!
Please share more information with us:
Which K6 version do you use?
Can you share the test script with us?
Thanks
Hi @bandorko
k6 version is 0.45.1
and I am using code from official site
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://test.k6.io/’);
page.screenshot({ path: ‘screenshots/screenshot.png’ });
} finally {
page.close();
}
}
It doesn’t work for me either with the v0.45.1. The best you can do is to upgrade k6 to the latest version (v0.52.0 currently), but your script works from the version v0.46.0. If you have to stick to the v0.45.1, the API is a bit different for that. You can find an example for that version here: launch([options])
Please let me know if it helps.
I tried but again getting an error
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
default: 1 iterations for each of 1 VUs (maxDuration: 10ms, gracefulStop: 30s)
ERRO[0000] Uncaught (in promise) GoError: launching browser: exec: “/Applications/Google Chro me”: executable file not found in %PATH%
at github.com/grafana/k6-browser/browser.mapBrowserType. fune? (native)
r=per-vu-iterations scenario=default
DEBU[0000] Regular duration is done, waiting for iterations to gracefully finish executor=per-vi
executor=default startTime=0s type per-
DEBU[0000] Stopping vus and vux max metrics emission… phase=execution-scheduler-init
cenario=default | |
---|---|
DEBU[0000] Executor finished successfully | |
DEBU[0000] teardown() is not defined or not exported, skipping! | |
DEBU[0000] Test finished cleanly | |
DEBU[0000] Metrics emission of VUs and VUsMax metrics stopped | |
DEBU[0000] Releasing signal trap… | |
DEBU[0000] Sending usage report… | |
DEBU[0000] Waiting for metric processing to finish… | |
DEBU[0000] Metrics processing finished! | |
DEBU[0000] Stopping outputs…• | |
DEBU[0000] Stopping 1 outputs… | |
DEBU[0000] | Stopping.• |
DEBU[0000] Stopped! | |
DEBU[0000] Generating the end-of-test summary… |
component=output -manager
component=metrics-engine-ingester component-metrics-engine-ingester
Ln 21, Col 21
Spaces: 2
UTF-8
@ankushakhotele1: I assume, you tried to run the example I linked as is, but it is just an example.
I modified your script to be able to run with v0.45.1
import { chromium } from 'k6/experimental/browser';
export const options = {
scenarios: {
ui: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
}
export default async function () {
const browser = chromium.launch()
const context = browser.newContext();
const page = context.newPage();
try {
await page.goto('https://test.k6.io/');
page.screenshot({ path: 'screenshots/screenshot.png' });
} finally {
page.close();
}
}
Please try this one with v0.45.1, but I suggest to upgrade your k6 to the most recent version and use your original script with it.
I have updated the k6 and it is working fine now.
Thank you so much for the help