1.8Exercises
Beginner: Write a Playwright test that captures a full-page screenshot of a login page and compares it against a saved baseline using toHaveScreenshot(). Disable animations before capture.
Intermediate: Implement the stabilizeForScreenshot() function from Section 1.6 and use it in a test suite that captures screenshots of five different pages. Configure different mismatch thresholds for each page based on how much dynamic content it contains.
Advanced: Build a complete AI visual triage pipeline. Capture screenshots in Playwright, perform pixel diff, and for any diffs above 0.1%, send the baseline and current screenshots to a multimodal AI model (such as Claude Opus 4.8 or GPT-5.5, current as of July 2026) with the prompt pattern from Section 1.4. Parse the AI response to automatically approve, flag, or block the build.