I try to set up browser tests with k6. However it always failed with browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module.
k6 version
0.46.0
OS
macOS 13.4.1
Docker version and image (if applicable)
grafana/k6:0.46.0-with-browser
Steps to reproduce the problem
Start k6 in docker using below command
docker run --rm --cap-add=SYS_ADMIN \
--entrypoint sh \
-it grafana/k6:0.46.0-with-browser
Add example script with browser set up (below is script content)
ERRO[0003] process with PID 22 unexpectedly ended: signal: trace/breakpoint trap category=browser elapsed="0 ms" source=browser
ERRO[0003] Uncaught (in promise) GoError: browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module
running at github.com/grafana/xk6-browser/browser.mapBrowser.func6 (native)
ui [at file:///home/k6/script.js:20:15(4) executor=shared-iterations scenario=ui
When you run the test script what command do you use?
Some command line arguments do not currently work when working with browser tests such as -u (--vus), -i (--iterations), and -d (--duration). You can set these up in the scenario itself (reference).
I can see that you are using --vus and --duration as command line args. They currently do not work with browser tests. You can instead add these to the scenario itself (reference).
I was able to run the test script you’ve provided with the latest release of k6 (v0.46.0) with k6 run test.js
I’ve replicated the issue that you are having on a mac running on a ARM processor when working with the specified (grafana/k6:0.46.0-with-browser) docker image. That docker image has been built for AMD64 processors and it unfortunately Chrome within the docker image is unable to start up. The error message you are seeing is incorrect and we need to fix that; i have opened a new issue to track this.
If you are reliant on working with a docker image you will need to either build your own image from scratch on your Mac, or use the image on a machine running a AMD64 processor. We have a issue to track the progress of the ARM images here.
Lastly, restart Docker, and please try the following command:
# set the platform to linux/amd64
$ docker run --rm -i --cap-add=SYS_ADMIN --platform linux/amd64 grafana/k6:master-with-browser run -q - <examples/locator.js
This runs the locator test script (it should exist in the examples folder).