Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Browser options
To enable browser testing, add the browser configuration within the options property of the
Scenario options.
export const options = {
scenarios: {
foo: {
executor: 'shared-iterations',
options: {
browser: {
type: 'chromium',
},
},
},
},
};Script options
Environment variable options
You can customize the behavior of the browser module by passing environment variables.
Note
Customizing browser options via environment variables is unsupported when running browser tests in Grafana Cloud k6.
The following command passes the browser options as environment variables to launch a headful browser with custom arguments.
$ K6_BROWSER_HEADLESS=false K6_BROWSER_ARGS='show-property-changed-rects' k6 run script.js# WARNING!
# The grafana/k6:master-with-browser image launches a Chrome browser by setting the
# 'no-sandbox' argument. Only use it with trustworthy websites.
#
# As an alternative, you can use a Docker SECCOMP profile instead, and overwrite the
# Chrome arguments to not use 'no-sandbox' such as:
# docker container run --rm -i -e K6_BROWSER_ARGS='' --security-opt seccomp=$(pwd)/chrome.json grafana/k6:master-with-browser run - <script.js
#
# You can find an example of a hardened SECCOMP profile in:
# https://raw.githubusercontent.com/jfrazelle/dotfiles/master/etc/docker/seccomp/chrome.json.
docker run --rm -i -e K6_BROWSER_HEADLESS=false -e K6_BROWSER_ARGS='show-property-changed-rects' grafana/k6:master-with-browser run - <script.jsC:\k6> set "K6_BROWSER_HEADLESS=false" && set "K6_BROWSER_ARGS='show-property-changed-rects' " && k6 run script.jsPS C:\k6> $env:K6_BROWSER_HEADLESS="false" ; $env:K6_BROWSER_ARGS='show-property-changed-rects' ; k6 run script.jsDefault arguments
List of default arguments included when launching the browser process. You can pass one or more of the arguments to the K6_BROWSER_IGNORE_DEFAULT_ARGS environment variable when starting a test for the ones you want to ignore.
Note
The starting ‘–’ have been omitted from the argument names in these lists.
Additionally, the following arguments are set in headless mode (when K6_BROWSER_HEADLESS is true, which is the default option):


