aemerson-commits/shareable-skills/webapp-testing

Claude Code and agent skill by aemerson-commits/shareable-skills

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

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-testing

Semi-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:

  1. Try list_pages → select_page first — if the running browser belongs to this

MCP server you can simply reuse it (no kill needed).

  1. If list_pages also 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.

  1. Do NOT use new_page with isolatedContext for auth-gated pages — an

isolated context carries no auth cookie and bounces to the login page. Isolated contexts only work for public URLs.

  1. 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): a SessionEnd hook that runs the kill command
above would stop orphans from accumulating between sessions. Not yet wired —
ask the user before adding it to settings.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:

  1. 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(); ``

  1. Run the script with credentials injected from your secrets manager.
  1. Read the screenshot with the Read tool — visually verify.
  1. 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

User task → Is the target behind CF Access (dev/prod sites)?
├─ Yes → Use CF Access Service Token (PREFERRED — no manual login needed)
│ 1. Set extraHTTPHeaders with CF_ACCESS_CLIENT_ID + CF_ACCESS_CLIENT_SECRET
│ 2. Navigate freely — all requests auto-authenticate
│ 3. See "CF Access Bypass" section below
│
└─ No → Is it behind another auth (SSO, API key, etc.)?
├─ Yes → Use service token / API key headers (PREFERRED)
│ See "Service Token Authentication" below
│
└─ No → Is it static HTML?
├─ Yes → Read HTML file directly to identify selectors
│ ├─ Success → Write Playwright script using selectors
│ └─ Fails/Incomplete → Treat as dynamic (below)
│
└─ No (dynamic webapp) → Is the server already running?
├─ No → Run: python scripts/with_server.py --help
│ Then use the helper + write simplified Playwright script
│
└─ Yes → Reconnaissance-then-action:
1. Navigate and wait for networkidle
2. Take screenshot or inspect DOM
3. Identify selectors from rendered state
4. Execute actions with discovered selectors

CF Access Bypass — Choose Your Pattern

Two working patterns. Pick based on what you're doing:

PatternBest forWhy
`CF_Authorization` cookie injection (simplest)Visual verification, multi-page flows, SPAsCookie fires on every request including SPA fetch() — no route intercepts needed
`extraHTTPHeaders` + route interceptsFull 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.

javascript
const { chromium } = require('playwright')
// Exchange service-token headers for CF_Authorization cookie
const CF_ID = process.env.CF_ACCESS_CLIENT_ID
const CF_SECRET = process.env.CF_ACCESS_CLIENT_SECRET
const res = await fetch('https://{{your-app}}.example.com/', {
headers: { 'CF-Access-Client-Id': CF_ID, 'CF-Access-Client-Secret': CF_SECRET },
redirect: 'manual',
})
const setCookie = res.headers.get('set-cookie') || ''
const cfAuth = /CF_Authorization=([^;]+)/.exec(setCookie)?.[1]
const browser = await chromium.launch({ headless: true })
const context = await browser.newContext()
await context.addCookies([{ name: 'CF_Authorization', value: cfAuth, domain: '{{your-app}}.example.com', path: '/' }])
const page = await context.newPage()
await page.goto('https://{{your-app}}.example.com/admin')

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
bash
# Shell — load from environment
CF_ID=$CF_ACCESS_CLIENT_ID
CF_SECRET=$CF_ACCESS_CLIENT_SECRET
javascript
// Node.js — read from process.env (set before running)
const CF_HEADERS = {
'CF-Access-Client-Id': process.env.CF_ACCESS_CLIENT_ID,
'CF-Access-Client-Secret': process.env.CF_ACCESS_CLIENT_SECRET,
'CF-Access-Authenticated-User-Email': 'test-user@example.com',
};
Basic Usage (Node.js CJS)
javascript
const { chromium } = require('playwright');
const CF_HEADERS = {
'CF-Access-Client-Id': process.env.CF_ACCESS_CLIENT_ID,
'CF-Access-Client-Secret': process.env.CF_ACCESS_CLIENT_SECRET,
'CF-Access-Authenticated-User-Email': 'test-user@example.com',
};
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
extraHTTPHeaders: CF_HEADERS,
viewport: { width: 1920, height: 1080 },
});
const page = await context.newPage();
await page.goto('https://{{your-app}}.example.com/', { waitUntil: 'domcontentloaded' });
await page.waitForTimeout(3000);
await page.screenshot({ path: 'screenshots/app.png' });
await browser.close();
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:

  1. Specific intercepts (register FIRST) — mock identity, group membership, admin status, tab visibility
  2. 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/aemerson-commits/shareable-skills/webapp-testing/badge)](https://verified-skill.com/skills/aemerson-commits/shareable-skills/webapp-testing)

Something wrong with this skill or its page? Tell us.