playwright-mcp-ui-testing
AI-driven browser UI testing using the Playwright MCP server. Guides the sqa-engineer to perform autonomous browser interactions, assertions, and evidence capture through the Playwright MCP tools. Use ONLY when the change involves UI or frontend components.
- License 许可
- GPL-3.0
- 最近更新
- 2026-06-06
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- playwright-mcp-ui-testing
- description
- AI-driven browser UI testing using the Playwright MCP server. Guides the sqa-engineer to perform autonomous browser interactions, assertions, and evidence capture through the Playwright MCP tools. Use ONLY when the change involves UI or frontend components.
03 SKILL.md 正文
playwright-mcp-ui-testing
This skill guides the sqa-engineer agent to perform AI-driven UI tests using the Playwright MCP server (@playwright/mcp). The agent uses MCP browser tools to navigate, interact, observe, and assert UI behavior autonomously — without writing coded test files. This skill is ONLY invoked when the software change involves UI or frontend components.
Prerequisites
Before invoking this skill:
- Confirm the change is UI/frontend-related. If not, skip this skill entirely.
- The Playwright MCP server is already available via the docker MCP gateway (configured in
.mcp.json). No additional setup is required — all browser tools are available with themcp__docker-mcp-gateway__prefix. - Ensure the application is running (start via
dotnet runor via the Aspire AppHost insamples/AppHost). - Discover the service URL (check Aspire dashboard at
http://localhost:15888or use the configuredlaunchUrl).
Phase 0 — Context Load (silent)
- Read
CLAUDE.mdto understand the component under test. - Read the spec file at
docs/specs/<feature-slug>.spec.mdif it exists. - Load persistent memory:
Skill("manage-memory", args: "sqa-engineer"). - Identify which UI routes/components were changed by the software-engineer.
Phase 1 — Test Case Design
Design UI test cases based on user flows and acceptance criteria before interacting with the browser. For each test case specify:
- Scenario name (maps to an AC ID if available, e.g.,
[AC-2] Submit form with valid data) - Starting URL
- Steps (navigation, interactions, form inputs)
- Expected outcome (element visible, text present, URL changed, etc.)
- Evidence (screenshot filename)
Phase 2 — AI-Driven Browser Execution
Execute each test case using the Playwright MCP tools. Follow the SAA pattern (Snapshot → Act → Snapshot) for every interaction:
Core Tool Reference
All browser tools are invoked via the docker MCP gateway. Use the exact tool names below:
| Tool | Purpose |
|---|---|
mcp__docker-mcp-gateway__browser_navigate |
Navigate to a URL |
mcp__docker-mcp-gateway__browser_snapshot |
Capture accessibility tree — use this for all assertions |
mcp__docker-mcp-gateway__browser_take_screenshot |
Capture screenshot as evidence |
mcp__docker-mcp-gateway__browser_click |
Click an element by ARIA ref |
mcp__docker-mcp-gateway__browser_type |
Type into a focused element |
mcp__docker-mcp-gateway__browser_fill_form |
Fill a form field |
mcp__docker-mcp-gateway__browser_press_key |
Press keyboard key (Enter, Tab, Escape, etc.) |
mcp__docker-mcp-gateway__browser_select_option |
Select a dropdown option |
mcp__docker-mcp-gateway__browser_wait_for |
Wait for element/condition |
mcp__docker-mcp-gateway__browser_console_messages |
Retrieve browser console log |
mcp__docker-mcp-gateway__browser_network_requests |
List intercepted network requests |
mcp__docker-mcp-gateway__browser_hover |
Hover over an element |
mcp__docker-mcp-gateway__browser_drag / mcp__docker-mcp-gateway__browser_drop |
Drag and drop |
mcp__docker-mcp-gateway__browser_handle_dialog |
Handle JS alert/confirm/prompt dialogs |
mcp__docker-mcp-gateway__browser_eval |
Execute JavaScript (escape hatch — requires justification) |
mcp__docker-mcp-gateway__browser_tabs |
List open browser tabs |
mcp__docker-mcp-gateway__browser_resize |
Resize the browser window |
mcp__docker-mcp-gateway__browser_navigate_back |
Navigate back |
mcp__docker-mcp-gateway__browser_network_request |
Inspect a specific network request |
SAA Pattern (Mandatory for every interaction)
Step 1: mcp__docker-mcp-gateway__browser_snapshot → read current state, identify ARIA refs
Step 2: mcp__docker-mcp-gateway__browser_click / browser_type / browser_fill_form → perform the interaction
Step 3: mcp__docker-mcp-gateway__browser_snapshot → verify state changed as expected
Never skip the post-action snapshot — it is the assertion.
Evidence Capture
After each test case (pass or fail), capture a screenshot:
Tool: mcp__docker-mcp-gateway__browser_take_screenshot
Also capture console errors:
Tool: mcp__docker-mcp-gateway__browser_console_messages
Treat any [error] level entries as implicit test failures.
Phase 3 — Test Report
Produce a structured test report:
## AI-Driven UI Test Report
### Application: <app name and URL>
### Date: <ISO date>
| Scenario | AC ID | Steps | Result | Evidence |
|----------|-------|-------|--------|----------|
| Submit valid form | AC-2 | 3 | ✅ PASS | screenshots/submit-valid-pass.png |
| Submit empty form | AC-3 | 2 | ❌ FAIL | screenshots/submit-empty-fail.png |
### Console Errors Found
- [None] / [list any errors]
### Network Errors Found
- [None] / [list any 4xx/5xx responses]
### Summary: N passed, M failed
Rules and Constraints
- Snapshot mode is preferred over vision mode — cheaper, faster, no vision model required.
- Never use
mcp__docker-mcp-gateway__browser_evalas a shortcut to set state directly. Use actual UI flows. Document any unavoidable use in the test report. - Flaky timing: always use
browser_wait_forafter navigation/form submission — never assume instant rendering. - ARIA anchoring: if UI elements lack proper ARIA labels/roles, surface it as a bug to the software-engineer and request semantic markup fixes before retesting.
- Screenshots are mandatory evidence — never submit a test report without screenshot files.
- This skill produces a report, not test code. The
write-testsskill produces.cstest files. This skill produces browser interaction results and a markdown report.
Escape Hatches (Require Justification in Report)
mcp__docker-mcp-gateway__browser_eval/mcp__docker-mcp-gateway__browser_run_code_unsafe: only when no combination of interaction tools can achieve the required state.- If visual/CSS rendering testing is needed, capture multiple screenshots with
mcp__docker-mcp-gateway__browser_take_screenshotat different viewports usingmcp__docker-mcp-gateway__browser_resize.
04 同仓库更多 Skills
write-tests
Test implementation skill for HypermediaEngine. Takes a confirmed test plan from design-test-cases and produces compilable, runnable xUnit tests following project conventions. Validates coverage quality through mutation testing. Invoked by the sqa-engineer agent after the test plan is approved.
write-documentation
Structured documentation writing workflow for HypermediaEngine. Writes or updates README.md files at the repo root and in each project directory (src/, tests/, samples/, etc.) based on current implementation, ADRs, and architecture decisions.
write-adr
Writes a numbered Architecture Decision Record (ADR) for a significant architectural choice in the HypermediaEngine project. Invoked by the software-architect agent whenever a consequential design decision is made or ratified. Saves the ADR to docs/architecture/decisions/.
tunit-playwright-ui-testing
Comprehensive guidance for writing coded end-to-end UI tests in C# using TUnit.Playwright. Tests inherit from PageTest — the base class manages all browser lifecycle. Covers NuGet setup, PageTest inheritance, Page Object Model, browser configuration, parallelism limiting, and CI integration. Based on the official TUnit docs at https://tunit.dev/docs/examples/playwright.
triage
Task classification, decomposition, dependency mapping, and routing skill. Invoked by the triage-agent to break any user request into discrete, independently-routable work items with assigned priorities and agent chains.
system-design
Expert system design skill. Use PROACTIVELY to design systems, review architectures, and assist software engineers in learning design principles and implementing them in the code with design patterns.