aemerson-commits/shareable-skills/webapp-testing
Claude Code and agent skill by aemerson-commits/shareable-skills
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Toolkit for interacting with and testing web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
Install
npx vskill@latest install aemerson-commits/shareable-skills/webapp-testingSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as aemerson-commits/shareable-skills/webapp-testing.
Web Application Testing
Browser Session Safety (MANDATORY)
Chrome cleanup safety: Never broad-scope-kill Chrome processes. Only close pages you opened via a specific page ID. "Browser already running" errors from chrome-devtools MCP mean the MCP profile is in use — reuse it, open an isolated context, or ask the user to close that window.
chrome-devtools MCP — "browser already running" recovery
The chrome-devtools MCP server attaches to a persistent profile so auth SSO stays logged in. It does not close that browser at session end, so orphaned chrome.exe processes accumulate and keep the profile locked. A fresh session's first MCP call then fails with "browser already running ... Use --isolated", and list_pages / navigate_page may all fail until the server establishes its own connection — this is the recurring intermittent failure.
Prefer the Playwright temp-script for deployed-page verification. The headless loop below (throwaway context + auth cookie injection) has none of these failure modes — no persistent profile, no lock collision, no auth bounce. Use the chrome-devtools MCP only for interactive single-page poking, not routine post-deploy checks.
Driving a long console page (a cloud console, an admin panel, any long form): call take_snapshot with filePath set to a scratch file, grep that file for the role and label you need (add |error|already to the pattern), then click or fill by the uid it returns. Take a new snapshot after every step, because uids change and an old one points at nothing. Never type keys until the snapshot shows the target field focused: with no field focused, the keys go to the page as keyboard shortcuts, which can fire console actions and mistype an identifier.
Recovery when the MCP IS needed and the lock is stuck:
- Try
list_pages→select_pagefirst — if the running browser belongs to this
MCP server you can simply reuse it (no kill needed).
- If
list_pagesalso fails, an orphaned Chrome holds the lock. Kill ONLY the
MCP-profile Chrome processes (never broad-kill): ``powershell Get-CimInstance Win32_Process -Filter "Name='chrome.exe'" | Where-Object { $_.CommandLine -like '*chrome-devtools-mcp*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force } ` Then retry navigate_page`. This filter matches only chrome-devtools-mcp processes — the user's real Chrome is untouched.
- Do NOT use
new_pagewithisolatedContextfor auth-gated pages — an
isolated context carries no auth cookie and bounces to the login page. Isolated contexts only work for public URLs.
- A secondary MCP server using a separate profile is not auth-logged-in by
default — only a real fallback after a one-time manual login in that profile.
Permanent prevention (optional): aSessionEndhook that runs the kill commandabove would stop orphans from accumulating between sessions. Not yet wired —ask the user before adding it tosettings.json.
To test web applications, write native Playwright scripts (Node.js or Python, depending on your environment).
Helper Scripts Available:
scripts/cf-session.py- Legacy persistent sessions (cookie-based, requires manual login)scripts/with_server.py- Manages server lifecycle (supports multiple servers)
Always run scripts with `--help` first to see usage. DO NOT read the source until you try running the script first and find that a customized solution is absolutely necessary. These scripts can be very large and thus pollute your context window. They exist to be called directly as black-box scripts rather than ingested into your context window.
Temp Playwright Script Iteration Loop (canonical)
For any visual UI verification, the reliable loop is:
- Write a temp script at
/tmp/verify-<feature>.mjs:
``js import { chromium } from 'playwright'; const browser = await chromium.launch({ headless: true }); const ctx = await browser.newContext(); // CF Access service-token cookie injection (required for CF Access-protected apps) await ctx.addCookies([{ name: 'CF_Authorization', value: process.env.CF_ACCESS_TOKEN, domain: '{{your-app}}.example.com', path: '/' }]); const page = await ctx.newPage(); await page.goto('https://{{your-app}}.example.com/dashboard'); await page.screenshot({ path: '/tmp/screenshots/verify-1.png', fullPage: true }); await browser.close(); ``
- Run the script with credentials injected from your secrets manager.
- Read the screenshot with the
Readtool — visually verify.
- Edit the script (add selectors, clicks, state capture) — re-run — re-read screenshot.
This beats the MCP chrome-devtools flow for scripted multi-step verification because the temp script is version-controllable (paste into the session notes) and re-runnable in the background. CF Access cookie injection (exchange service-token headers for CF_Authorization cookie via ctx.addCookies()) is required for CF-Access-protected apps — this beats the MCP because cookies are injected pre-navigation.
For CSS/layout work: Read screenshot → Grep CSS class usage → Edit → npm run build → re-screenshot → repeat (2–3 rounds typical). The same Write→Screenshot→Read→iterate cycle applies to email-HTML composition (generate HTML draft → screenshot via Playwright → iterate on the template).
See references/iteration-loops.md for the full temp-script template, CF Access cookie injection detail, CSS debug loop, email-HTML composition loop, and minified deployed-bundle grep technique.
Decision Tree: Choosing Your Approach
CF Access Bypass — Choose Your Pattern
Two working patterns. Pick based on what you're doing:
| Pattern | Best for | Why | |
|---|---|---|---|
| `CF_Authorization` cookie injection (simplest) | Visual verification, multi-page flows, SPAs | Cookie fires on every request including SPA fetch() — no route intercepts needed | |
| `extraHTTPHeaders` + route intercepts | Full admin impersonation (identity, groups, admin flag) | Lets you mock identity + auth endpoints for admin-only UI |
Pattern A — Cookie Injection (PREFERRED for visual checks)
Under the hood: call the target URL with CF-Access-Client-Id + CF-Access-Client-Secret headers, extract the CF_Authorization JWT from the Set-Cookie response header, then inject it into a Playwright context before the first navigation. Subsequent fetch() calls in the SPA automatically include the cookie.
Why this beats chrome-devtools MCP: The MCP can't set cookies _before_ the first request, so CF Access redirects to cloudflareaccess.com before any JS runs. Playwright's context.addCookies() is pre-navigation, so the browser sends CF_Authorization on the first GET.
NOTE: If you previously referenced a reusable helper script for this flow, write the cookie-exchange inline or store the snippet in a temp file for one-off runs.
Pattern B — extraHTTPHeaders + Route Intercepts
For all CF Access-protected sites, use the service token. This requires no manual login — set headers on the browser context and all requests authenticate automatically.
Server-side `ALLOW_SERVICE_TOKEN_AUTH`: On dev projects, an env var like ALLOW_SERVICE_TOKEN_AUTH=true lets the auth middleware trust a CF-Access-Authenticated-User-Email header without a real JWT. Set only on dev — never on production.
Credentials: Load from your secrets manager (environment variables, encrypted .env, etc.). Never hardcode credentials in scripts or skills.
Credential Loading
Basic Usage (Node.js CJS)
Full Admin Access (Route Intercepts + Header Injection)
Service token extraHTTPHeaders only apply to page navigation, NOT to SPA fetch() calls. To get full admin access with live API data, you need two layers:
- Specific intercepts (register FIRST) — mock identity, group membership, admin status, tab visibility
- Catch-all header injection (register LAST) — inject service token headers into ALL
fetch()calls
CRITICAL: Playwright routes match LIFO (last registered first). The catch-all must use route.fallback() for URLs handled by specific intercepts, otherwise it steals the request.
Finding the real `isAdmin` source: Many SPAs have a consolidated auth-init endpoint (e.g. /api/auth-init) that returns role flags in one payload. Intercept this rather than individual check endpoints to reliably flip admin status for RBAC UI tests.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/webapp-testing/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aemerson-commits/shareable-skills/webapp-testing)