Playwright E2E Testing (HMIS)
Full operational workflow lives in
Playwright E2E Testing Workflow —
read it before driving the browser. This skill is the entry point and adds the
rebuild/redeploy and permission context.
For general MCP tool mechanics (tool reference, clicking/dropdown/file-upload
patterns, common errors) see the companion
the workflow doc above is HMIS-specific; the guide is generic Playwright MCP usage.
🚨 Never navigate by URL
Only ever type a URL for the application root / login page. Every inner page
must be reached by clicking through the menus, exactly as a user would. Real
users have no other way in — some terminals are kiosks with no address bar.
This is not cosmetic. HMIS pages are backed by @SessionScoped controllers whose
state is set by the navigation method (toSearchServiceBill(),
toManageDepartmentPreferences(), …), not by the page. Load the page by URL and
that state is null, or a lazily-created transient placeholder — so the page can
500, render blank, or run pathologically slowly in a way no user can ever hit.
Anything you observe that way is an artifact, not a defect.
Establish the menu path before testing and record it in the issue/PR in the
form the user can follow, e.g. *Menu → Inpatient → Search → Service Bill → set
From Date → Search Bill → click Bill No → Return*. If no menu path exists, that
is the finding — the page is unreachable in production. Do not fall back to the
URL to get on with the test. See
§2.
If the Playwright MCP server shows as unavailable
An MCP server that failed to connect at session start (e.g. a system-reminder
saying playwright (CONNECT_TIMEOUT) or similar) will not self-heal
mid-session — a session's MCP connections are established once at startup, so
retrying a Playwright tool call again later in the same session wastes a
round-trip and always fails the same way.
Instead, immediately and without asking the user, run:
claude mcp list
This performs a fresh, independent health check outside the current session's
stale connection state. claude mcp list reports one of several distinct
statuses per server — treat each differently rather than collapsing them into
a binary "healthy or not":
✔ Connected— the server is actually reachable; the earlier failure
was specific to this session's startup timing, not a real outage. Tell the
user briefly that the initial connection attempt timed out but the server
is confirmed healthy, then fall back to claude-in-chrome for this
session (per [[feedback-prefer-playwright-over-claude-in-chrome]] project
memory) and recommend starting a fresh session next time to pick up the
working connection.
! Needs authentication— not an outage; the server needs a sign-in or
header the current session hasn't provided. Tell the user it needs
re-authentication (/mcp panel or claude mcp login) rather than treating
it as down.
⏸ Pending approval— project-scoped server awaiting manual approval;
tell the user to run claude interactively to approve it, not a real
outage either.
! Connected · tools fetch failed— the connection itself works but
tool listing errored; this is a real (if partial) problem worth surfacing,
distinct from a clean outage.
✘ Failed to connect/✘ Connection error— only these two count
as a genuine outage. Say so explicitly and ask the user how to proceed (fix
the server, proceed with claude-in-chrome, or skip live browser testing)
rather than silently substituting one tool for the other.
(Statuses per the Claude Code MCP docs as of this writing — reconfirm against
current documentation if claude mcp list's output format has changed.)
Never silently swap in claude-in-chrome without first running this check and
telling the user which case applies — claude-in-chrome cannot handle native
confirm()/alert()/prompt() dialogs (they freeze the extension), which
HMIS billing/save flows trigger routinely, so the substitution carries real
risk the user should know about upfront.
Workflow
A coordinating session may hand the browser work (steps 3-7) to the
hmis-qa-verifier subagent, which preloads this skill and returns a PASS/FAIL
table. If you are that subagent, skip this paragraph.
- Confirm the target with the user: which feature/page, which local
deployment URL, and whether the code under test is already deployed.
- If not yet deployed, rebuild and redeploy — see
A redeploy invalidates the session, so this must happen before login.
- Login + department selection — see
§1.
Then reach the page under test through the menus only — never by URL
(see above).
- Drive the feature using accessibility snapshots (
browser_snapshot)
to locate elements, real key events for PrimeFaces inputs (§3), and
browser_handle_dialog for confirm() guards (§4). Wait on the expected
result (browser_wait_for) rather than fixed sleeps (§5a). Watch for
(required-field validation blocking unrelated nav buttons),
(p:selectOneMenu click-option pattern), and
(non-AJAX search clicks that time out but still succeed).
If a click "succeeds" but nothing happens (no POST, menu/accordion
won't open), check devicePixelRatio first — a zoomed MCP profile
makes clicks no-ops. Switch to the local Node rig; see
§146.
- If the DB lacks suitable test data, generate it through the app — see
§15.
Never fall back to "code looks correct" as evidence.
Then leave it there. Test records are not litter — do not clean up, and
do not offer to, unless explicitly asked; just say what you created. A
request to test is also never a request to test in production: if a
verification step is about to write to a production environment, stop and
confirm the target. See
§15a.
- Verify in the database — read-only
mysqlqueries against the local
DB per §6.
Credentials come from C:\Credentials\ (outside the repo).
- Capture evidence outside the repo: pass
browser_take_screenshotan
absolute filename in the machine's out-of-repo directory (two-tier temp
policy in CLAUDE.md), since Playwright MCP otherwise writes to
.playwright-mcp/ inside the repo. Then follow
for anything destined for the wiki/issue. Remove temp screenshots from the
repo afterward.
- If Playwright can't find a control, treat it as a product accessibility gap
(§7) — fix the page, not the test.
- If a report is slow or times out while you test, file a GitHub issue for it
(fast DTO-based report as the default, legacy report kept for cross-check).
See the performance-optimization skill.
Required permissions
This skill needs, beyond the defaults:
- The full
mcp__playwright__*tool set (browser automation). - Maven
clean packageand Payaraasadmin redeploy/deploy/undeployfor
the local rebuild step (paths in CLAUDE.md § Local build tools).
mysqlread access to the local database for verification queries.
If any of these prompt for approval, the user's settings.local.json should
already allow them for this project — flag it if a prompt appears repeatedly.