Skip to content
Monitoring
Skill

/k6-browser-test

Generate a working k6 browser test (k6/browser) from a plain-language description of a user journey — no CSS selectors or technical detail needed. Explores the LIVE target site with a throwaway k6/browser session to discover real, verified selectors

From plugin
skills
31353 skills

Claude Code

$ npx -y skills add grafana/skills --skill k6-browser-test --agent claude-code

SKILL.md

k6-browser-test.SKILL.md
name: k6-browser-test
description: >-
  Generate a working k6 browser test (k6/browser) from a plain-language
  description of a user journey — no CSS selectors or technical detail needed.
  Explores the LIVE target site with a throwaway k6/browser session to discover
  real, verified selectors (getByRole/getByLabel/getByText, etc.), dismisses
  cookie/consent banners, then writes a functional or load test
  using expect() from k6-testing (Web-Vitals thresholds for load).
  Looks up k6/browser APIs via `k6 x docs`; validates
  with `k6 run`. Use when the user wants to write, author, or generate a k6
  browser/UI or load test with a real browser, or says
  things like "write a browser test for…", "test this login/checkout/search
  flow with k6", "click through my site and verify…", or describes navigating a
  site in prose. For a full multi-test performance suite use
  k6-perf-test-website; for HTTP/protocol (non-browser) tests use the general
  k6 skills; for browser or scripted checks in Grafana Cloud Synthetic
  Monitoring, use synthetic-monitoring-checks.
license: Apache-2.0
metadata:
  author: grafana-labs

k6 Browser Test (from prose, with live exploration)

Turn a plain-language user journey into a working, validated `k6/browser` functional test. The user describes what to do the way they'd tell a friend ("go to the site, log in, add a pizza to the cart, check the cart shows one item") — **you** discover the real selectors by driving the live site, so the user never has to supply a CSS selector, XPath, or `data-testid`.

> **Agent-agnostic:** steps describe capabilities ("run a k6 script", "write a > file"), not specific tools. Use whatever your harness provides. The only hard > dependencies are the `k6` binary with browser support and a POSIX shell — no > MCP, no Node, no Playwright.

What this skill produces (and what it doesn't)

  • **Produces:** one `k6/browser` test file — functional by default (single

iteration, `expect()` assertions), or a browser *load* test (scenarios + Web-Vitals thresholds) when the user asks for load/performance.

  • **Not in scope:** protocol/HTTP tests, HAR recording, or multi-test load

suites with SLOs. If the user wants a full performance suite, hand off to **k6-perf-test-website**. If they want HTTP/gRPC/WS, use the general k6 skills. If the script is destined for Grafana Cloud Synthetic Monitoring (a browser or scripted check), also reference the **synthetic-monitoring-checks** skill — it owns the SM check lifecycle (create/update, cadence, probe locations).

Prerequisites

  • `k6 v1.2+` (`k6 version`) — the `getBy*` locator API this skill relies on

landed in v1.2.0 — plus a Chromium-based browser installed on this machine (e.g. Google Chrome) — k6 does **not** bundle one. Point `K6_BROWSER_EXECUTABLE_PATH` at a non-default install location.

  • A POSIX shell (`bash`/`zsh`) — the exploration loop uses `mktemp`, `cp`, and

`env`. (Only the final `k6 run` in Step 7 has a PowerShell form.)

  • **k6 v2+ is needed only for Step 5's `k6 x docs`** (automatic extension

resolution, no custom build). Verify once that it prints markdown; on v1.x — or if it misbehaves — use the fallbacks in [Step 5](#step-5-fill-api-gaps-with-k6-x-docs-only-if-needed). Everything else works the same.

  • Network access from this host to the target site.

---

Step 1: Understand the journey

Restate the user's prose as an explicit, ordered step list and **echo it back** before exploring — a wrong reading is cheap to fix now, expensive after a script is written. Capture:

  • **Target URL** (the entry point).
  • **Ordered actions** ("click X", "type Y in the search box", "open the first

result").

  • **The assertion(s)** — what proves success ("the cart shows 1 item", "the

page title contains 'Dashboard'", "'Rated!' appears").

  • **Credentials**, if a login is involved. Take them via environment variables

(`__ENV.TEST_USERNAME` / `__ENV.TEST_PASSWORD` / `__ENV.TEST_TOKEN`) — never hardcode. Avoid reserved names: in zsh (default macOS shell) `USERNAME` is bound to the OS user, so `USERNAME=… k6 run` is silently ignored — use `env TEST_USERNAME=… TEST_PASSWORD=… k6 run …`.

  • **Destructive actions** (place order, delete, send). Confirm with the user

before performing these during exploration, and prefer a safe stopping point. If you can't ask (non-interactive run): proceed through the step only against a demo/sandbox with no real fulfillment (e.g. saucedemo) and state why it's safe; against anything that looks real, stop before the step and surface it.

Example restatement:

> 1. Open `https://www.saucedemo.com` > 2. Log in as the standard user (creds via env) > 3. Add the first product to the cart > 4. **Assert:** the cart badge shows `1`

---

Step 2: Explore the live site to resolve selectors

This is the heart of the skill and what makes the output reliable. **Read [`references/explore.md`](references/explore.md)** for the full procedure.

Preflight once before the first run: `k6 version` (this skill needs v1.2+). If the first explorer run fails at browser launch ("browser not found" / executable-path errors), k6 couldn't find a Chromium — install Google Chrome or point `K6_BROWSER_EXECUTABLE_PATH` at one, then re-run. Catching this now beats a confusing failure mid-exploration.

In short:

1. Copy [`scripts/explore.template.js`](scripts/explore.template.js) to a **unique temp path** — `EXPLORER="$(mktemp -d)/explore.js"` — never a fixed name like `/tmp/explore.js` (why: [`references/explore.md`](references/explore.md)). Never save it to the user's project. 2. Run it headless against the target: `K6_BROWSER_HEADLESS=true TARGET=<url> k6 run "$EXPLORER"` 3. Read the `EXPLORE_CANDIDATES` line — a JSON list of visible elements with their naming signals (`text`, `ariaLabel`, `placeholder`, `label`, `value`, `testid`, `dataTest`, `nameAttr`, `role`). The signal→locator table in [`references/explore.md`](ref

Read more
@grafana
Ships withskills

Public skills for working with Grafana, Prometheus, Loki, Tempo, Pyroscope, k6, and the broader LGTM observability stack. Compatible with Claude Code, Cursor, Codex, and any tool supporting the Agent Skills open standard.

Stars on GitHub

Momentum

stars in total
313
Star history of grafana/skills on GitHub, a chart by star-history.com

Other skills on skills.

admission-control

admission-control

Use when the user asks to "write a validator", "add validation", "implement admission control", "write a mutating webhook", "add…

@grafana@grafanaInstall Skill
app-sdk-concepts

app-sdk-concepts

Use when starting any grafana-app-sdk work — scaffolding a Grafana app, initializing a Grafana App Platform app, picking a…

@grafana@grafanaInstall Skill
cue-kind-definition

cue-kind-definition

Author CUE kind definitions for grafana-app-sdk apps - schemas, versioning, field constraints, named type definitions, custom…

@grafana@grafanaInstall Skill
reconciler-logic

reconciler-logic

Implement reconcilers and watchers for grafana-app-sdk apps — write `TypedReconciler[*MyKind]` reconcile functions, apply…

@grafana@grafanaInstall Skill
adaptive-metrics

adaptive-metrics

Cut Grafana Cloud Metrics cost by shrinking active-series count with Adaptive Metrics aggregation rules — auto-recommendations…

@grafana@grafanaInstall Skill
admin

admin

Manage Grafana Cloud accounts — organizations, stacks, RBAC roles and assignments, SSO/SAML/OAuth/GitHub auth, service accounts…

@grafana@grafanaInstall Skill

More skills from other plugins.

agentdb-advanced

agentdb-advanced

Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid…

ruview2d104k
@ruvnet@ruvnetInstall Skill
install

install

Kubeshark installation and deployment skill. Use this skill whenever the user wants to install Kubeshark, deploy Kubeshark to a…

@kubeshark@kubesharkInstall Skill
scan

scan

Scan a project with sentrux to get structural health grades (A-F) across 14 dimensions including coupling, cycles, cohesion, dead…

sentrux8mo3.3k
@sentrux@sentruxInstall Skill
phone-input

phone-input

Call the user on the phone for real-time voice conversations. Use this when you need input, want to report on completed work, or…

callme7mo2.7k
@zeframlou@zeframlouInstall Skill

Questions about k6-browser-test.

Which coding agents can use k6-browser-test?
k6-browser-test installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.