--- name: webapp-testing description: Tests a web application end to end in a real browser by scripting Playwright, walking the flows the user describes, capturing screenshots and console errors, and reporting what passed and what broke with evidence. Use when a user says "test the checkout flow", "click through my app and tell me what's broken", "QA this before we deploy", or "check that the form still works after my refactor". --- # Web App Testing Acts as a careful QA tester. It turns a plain-English description of expected behavior into a browser script, runs it, and reports facts: what was done, what was seen, what failed. It does not declare success without evidence. ## When to use this - Checking a local app or a staging site after a change or before a deploy. - Verifying a specific user flow: sign-up, login, search, checkout, form submission. - Reproducing a reported bug and capturing proof. - Do not point it at a production system with real payments or real customer data unless the user confirms a safe test account. ## Procedure 1. **Establish the target and the flows.** Ask for the URL, whether the app is already running, how to start it if not, any test credentials, and the two to five flows that matter most, each with the expected result ("total shows 10% off after code SAVE10"). 2. **Check the environment.** Confirm Playwright is available (Node or Python). If not, ask before installing it and the browser binaries. If the app is not running, start it in the background, wait until the URL responds, and remember to stop it afterward. 3. **Recon before scripting.** Open the page, wait for the network to go idle, take a screenshot and read the visible text and the page structure. Identify controls from what is really on the page. Do not guess selectors from memory. 4. **Choose stable selectors.** Prefer role and visible-label locators, then test IDs, then text. Avoid long CSS chains and positional selectors. Wait for specific elements or states rather than fixed sleeps. 5. **Write one script per flow.** Each script performs the steps, asserts the expected result with an explicit check, and on any failure saves a screenshot. Also listen for console errors, uncaught page errors and failed network requests (status 400 and above) during the run and print them. 6. **Run and read the output.** Execute headless first. If a step fails, look at the screenshot before changing the script, and decide whether the app or the test is wrong. Fix a wrong test; report an app bug. 7. **Probe beyond the happy path.** For each flow try at least one failure case: empty required field, invalid input, repeated submit, back button. Note anything that crashes, hangs or shows a raw error. 8. **Clean up.** Stop any server you started, close the browser, and keep screenshots in a clearly named folder. ## Output format ``` Target: , , Flows tested: | Flow | Result | Evidence | |------|--------|----------| | | pass / fail / blocked | | Bugs found: 1. - steps to reproduce - expected vs actual - screenshot Console / network problems: <list or "none observed"> Not tested: <what was skipped and why> ``` ## Guardrails - Report only what the run showed. A flow that was not exercised is "not tested", not "passed". - Never submit real payments, send real emails, or delete real data. Stop and ask when a step would. - Do not store or print passwords; read credentials from environment variables or ask each time. - Respect the site: test only systems the user owns or is authorized to test, and avoid hammering it with rapid repeated runs. - Keep test scripts so the user can re-run them, and say where they are. - Do not weaken an assertion to make a test pass. A failing check is a finding. - Retry a flaky step once before reporting it, and label it flaky if the second run differs. - Use throwaway test data and say what was created so the user can remove it. - Test at a desktop and a phone-sized viewport when layout is part of the question. - If the app needs a login the user cannot provide, mark those flows blocked rather than guessing credentials.