Playwright CLI QA Workflows
These specs are lightweight, readable automation scripts for Playwright CLI. Each spec is a Markdown file with runnable playwright-cli code blocks.
Running a spec
scripts/playwright-run-spec.sh docs/specs/admin-smoke.md
The runner executes fenced code blocks marked with playwright-cli and ignores all other content.
Spec format
- Use a fenced code block starting with ` ```playwright-cli`.
- Use
step "<label>"to name the next CLI action. - Use
cli <command> ...to invoke Playwright CLI commands. - Use
open_browserto open the browser withBASE_URLand optional args.
Each step label applies to the next cli call.
Example
step "Open admin"
open_browser
step "Check dashboard"
cli run-code "$(cat <<'EOF'
async page => {
await page.getByRole('heading', { name: 'Dashboard', level: 2 }).waitFor();
}
EOF
)"
Environment variables
BASE_URL(defaulthttp://localhost:8081)PLAYWRIGHT_OPEN_ARGS(example:--headed)ARTIFACT_ROOT(defaultartifacts/playwright)FLOW_NAME(defaults to spec filename without.md)PLAYWRIGHT_CLI_PKG(default@playwright/cli@0.1.0)PLAYWRIGHT_CLI_CMD(optional override path to a CLI binary)
Artifacts and a report.txt file are written under:
artifacts/playwright/<flow>__<timestamp>/
Notes
- The function passed to
run-coderuns in the Playwright (Node.js) context and controls thepageobject. Usepage.evaluate(...)to run code in the browser context, and pass values via shell variables or function arguments.