Webapp testing

From seaworld008/Commonly-used-high-value-skills · View interactive version

Webapp testing is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Use when testing local web applications with Playwright, verifying frontend behavior, debugging UI issues, capturing screenshots, inspecting browser logs, or validating user flows.

How to use this skill

Skill file

Web Application Testing

To test local web applications, write native Python Playwright scripts.

Helper Scripts Available:

Current implementation uses shell=True, unread stdout/stderr pipes and

termination of the shell Popen only. Verbose logs can block and descendants

may survive. Use only reviewed commands in authorized environments; prefer

existing servers or a host runner that consumes logs and manages its process

group. Confirm owned descendants exit; the helper alone does not prove cleanup.

Usually inspect --help for usage. Read source first when side effects,

modification scope or lifecycle handling need review; do not execute an unknown

helper merely to avoid reading it.

Decision Tree: Choosing Your Approach

User task → 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 the target element/app-ready signal
            2. Take screenshot or inspect DOM
            3. Identify selectors from rendered state
            4. Execute actions with discovered selectors

Example: Using with_server.py

To start a server, run --help first, then use the helper:

Single server:

python scripts/with_server.py --server "npm run dev" --port 5173 -- python your_automation.py

Multiple servers (e.g., backend + frontend):

python scripts/with_server.py \
  --server "cd backend && python server.py" --port 3000 \
  --server "cd frontend && npm run dev" --port 5173 \
  -- python your_automation.py

Keep browser logic in the automation script. The helper starts servers and

attempts cleanup; verify its owned descendants exit as noted above:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True) # Always launch chromium in headless mode
    page = browser.new_page()
    page.goto('http://localhost:5173') # Server already running and ready
    page.get_by_role('button', name='Submit').wait_for(state='visible')
    # Replace with this app's ready marker/expected response and assert its state
    # ... your automation logic
    browser.close()

Reconnaissance-Then-Action Pattern

  1. Inspect rendered DOM:

```python

page.screenshot(path='/tmp/inspect.png', full_page=True)

content = page.content()

page.locator('button').all()

```

  1. Identify selectors from inspection results
  1. Execute actions using discovered selectors

Common Pitfall

Wait for the target element, application-ready marker or expected response

before inspecting the relevant state. Use networkidle only when appropriate

for that page; polling may prevent it, and network quiet does not prove UI readiness.

Best Practices

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.