// Automated webapp testing with Playwright. Server management, UI testing, visual debugging, and reconnaissance-first approach.
| name | webapp-testing |
| version | 2.0.0 |
| category | testing |
| description | Automated webapp testing with Playwright. Server management, UI testing, visual debugging, and reconnaissance-first approach. |
| license | Complete terms in LICENSE.txt |
| progressive_disclosure | {"entry_point":{"summary":"Reconnaissance before action: verify server state and page load before testing","when_to_use":"When testing web applications with Playwright. Server verification, UI testing, frontend debugging.","quick_start":"1. Check server with lsof 2. Start with with_server.py 3. Wait for networkidle 4. Screenshot and verify"},"references":["playwright-patterns.md","server-management.md","reconnaissance-pattern.md","decision-tree.md","troubleshooting.md"]} |
Core Principle: Reconnaissance Before Action
Automated webapp testing using Playwright with a focus on verifying system state (server status, page load, element presence) before taking any action. This ensures reliable, debuggable tests that fail for clear reasons.
Key capabilities:
Not suitable for: Unit testing (use Jest/pytest), load testing, or API-only testing.
RECONNAISSANCE BEFORE ACTION
Never execute test actions without first:
lsof -i :PORT and curl checkspage.wait_for_load_state('networkidle')Why: Tests fail mysteriously when servers aren't ready, selectors break when DOM is still building, and 5 seconds of reconnaissance saves 30 minutes of debugging.
lsof -i :3000 -sTCP:LISTEN # Check server listening
curl -f http://localhost:3000/health # Test response
# Single server
python scripts/with_server.py --server "npm run dev" --port 5173 -- python test.py
# Multiple servers (backend + frontend)
python scripts/with_server.py \
--server "cd backend && python server.py" --port 3000 \
--server "cd frontend && npm run dev" --port 5173 \
-- python test.py
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
# 1. Navigate and wait
page.goto('http://localhost:5173')
page.wait_for_load_state('networkidle') # CRITICAL
# 2. Reconnaissance
page.screenshot(path='/tmp/before.png', full_page=True)
buttons = page.locator('button').all()
print(f"Found {len(buttons)} buttons")
# 3. Execute
page.click('button.submit')
# 4. Verify
page.wait_for_selector('.success-message')
page.screenshot(path='/tmp/after.png', full_page=True)
browser.close()
Review console output, check for errors, verify state changes, examine screenshots.
Server Management - Check โ Start โ Wait โ Test โ Cleanup
with_server.py for automatic lifecycle managementlsof, test with curlReconnaissance - Inspect โ Understand โ Act โ Verify
Wait Strategy - Load โ Idle โ Element โ Action
networkidle on dynamic appsSelector Priority - data-testid > role > text > CSS > XPath
[data-testid="submit"] - most stablerole=button[name="Submit"] - semantictext=Submit - readablebutton.submit - acceptableโ Testing without server verification - Always check lsof and curl first
โ Ignoring timeout errors - TimeoutError means something is wrong, investigate
โ Not waiting for networkidle - Dynamic apps need full page load
โ Poor selector strategies - Use data-testid for stability
โ Missing network verification - Check API responses complete
โ Incomplete cleanup - Close browsers, stop servers properly
playwright-patterns.md - Complete Playwright reference Selectors, waits, interactions, assertions, test organization, network interception, screenshots, debugging
server-management.md - Server lifecycle and operations with_server.py usage, manual management, port management, process control, environment config, health checks
reconnaissance-pattern.md - Philosophy and practice Why reconnaissance first, complete process, server checks, network diagnostics, DOM inspection, log analysis
decision-tree.md - Flowcharts for every scenario New test decisions, server state paths, test failure diagnosis, debugging flows, selector/wait strategies
troubleshooting.md - Solutions to common problems Timeout issues, selector problems, server crashes, network errors, environment config, debugging workflow
Examples (examples/ directory):
element_discovery.py - Discovering page elementsstatic_html_automation.py - Testing local HTML filesconsole_logging.py - Capturing console outputScripts (scripts/ directory):
with_server.py - Server lifecycle management (run with --help first)Mandatory: verification-before-completion Recommended: systematic-debugging, test-driven-development Related: playwright-testing, selenium-automation
The reconnaissance-then-action pattern is not optional - it's the foundation of reliable webapp testing.