Project 35: Chrome Browser Testing Automation

Project 35: Chrome Browser Testing Automation

Build an agent that uses Chrome browser integration to perform visual regression testing, accessibility audits, and end-to-end user flow testing with AI-powered assertions that understand page content semantically.

Quick Reference

Attribute Value
Difficulty Advanced (Level 3)
Time Estimate 1-2 weeks
Primary Language TypeScript
Alternative Languages Python, JavaScript
Prerequisites Projects 1-5, 20 (Web Scraper with Browser MCP)
Key Topics Browser automation, visual regression, accessibility auditing, AI-powered assertions
Kiro CLI Concepts Chrome MCP, computer use, screenshot analysis, hooks
Main Book Reference โ€œWeb Application Testing with Puppeteerโ€ by Jay Huang

1. Learning Objectives

By completing this project, you will:

  1. Master Chrome browser automation through MCP: Control browser sessions, navigate pages, and interact with elements programmatically
  2. Implement visual regression testing: Capture screenshots, compare against baselines, and detect visual changes
  3. Build accessibility auditing systems: Analyze pages for WCAG compliance using DOM analysis and AI interpretation
  4. Create AI-powered assertions: Use natural language to describe expected behaviors and let AI verify them
  5. Generate comprehensive test reports: Produce human-readable reports with screenshots, findings, and recommendations

2. Deep Theoretical Foundation

2.1 The Evolution of Browser Testing

Browser testing has evolved through several paradigms, each building on the previous:

                    BROWSER TESTING EVOLUTION

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                                          โ”‚
    โ”‚   GENERATION 1: Record and Playback                                     โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                     โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ€ข Selenium IDE, record mouse clicks                                   โ”‚
    โ”‚   โ€ข Brittle - breaks with any UI change                                 โ”‚
    โ”‚   โ€ข No understanding of what's being tested                             โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   GENERATION 2: Programmatic Automation                                 โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                 โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ€ข Selenium WebDriver, Puppeteer, Playwright                           โ”‚
    โ”‚   โ€ข Code-based selectors (CSS, XPath)                                   โ”‚
    โ”‚   โ€ข Still requires explicit assertions                                  โ”‚
    โ”‚   โ€ข Maintenance burden with UI changes                                  โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   GENERATION 3: Visual Testing                                          โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                          โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ€ข Percy, Chromatic, Applitools                                        โ”‚
    โ”‚   โ€ข Screenshot comparison                                                โ”‚
    โ”‚   โ€ข Catches visual regressions                                          โ”‚
    โ”‚   โ€ข Can't verify behavior                                               โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   GENERATION 4: AI-Powered Testing (THIS PROJECT)                       โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                      โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ€ข Natural language test descriptions                                  โ”‚
    โ”‚   โ€ข Semantic understanding of pages                                     โ”‚
    โ”‚   โ€ข Self-healing selectors                                              โ”‚
    โ”‚   โ€ข Intelligent assertions                                              โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Example:                                                              โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚  "Verify the checkout button is prominently displayed           โ”‚   โ”‚
    โ”‚   โ”‚   and enabled when items are in the cart"                       โ”‚   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ”‚  AI interprets:                                                  โ”‚   โ”‚
    โ”‚   โ”‚  โ€ข Find checkout button (semantic search, not CSS selector)     โ”‚   โ”‚
    โ”‚   โ”‚  โ€ข Check visibility and prominence (size, color, position)      โ”‚   โ”‚
    โ”‚   โ”‚  โ€ข Verify enabled state (not disabled, clickable)               โ”‚   โ”‚
    โ”‚   โ”‚  โ€ข Check cart state (items present in cart indicator)           โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2.2 Chrome DevTools Protocol (CDP)

The Chrome MCP uses CDP to control the browser. Understanding CDP is essential:

                    CHROME DEVTOOLS PROTOCOL ARCHITECTURE

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                                          โ”‚
    โ”‚   KIRO CLI                    CHROME MCP                    CHROME      โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                    โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                    โ”€โ”€โ”€โ”€โ”€โ”€      โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚          โ”‚   Commands    โ”‚          โ”‚    CDP        โ”‚          โ”‚   โ”‚
    โ”‚   โ”‚  Agent   โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ โ”‚   MCP    โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ โ”‚ Browser  โ”‚   โ”‚
    โ”‚   โ”‚          โ”‚               โ”‚  Server  โ”‚               โ”‚          โ”‚   โ”‚
    โ”‚   โ”‚          โ”‚ โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚          โ”‚ โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”‚          โ”‚   โ”‚
    โ”‚   โ”‚          โ”‚   Results     โ”‚          โ”‚    Events     โ”‚          โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   CDP DOMAINS (commonly used):                                          โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                         โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Page Domain                                                           โ”‚
    โ”‚   โ”œโ”€โ”€ navigate(url)           โ†’ Load a page                            โ”‚
    โ”‚   โ”œโ”€โ”€ captureScreenshot()     โ†’ Take screenshot                        โ”‚
    โ”‚   โ””โ”€โ”€ getFrameTree()          โ†’ Get frame structure                    โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   DOM Domain                                                            โ”‚
    โ”‚   โ”œโ”€โ”€ getDocument()           โ†’ Get DOM tree                           โ”‚
    โ”‚   โ”œโ”€โ”€ querySelector()         โ†’ Find element                           โ”‚
    โ”‚   โ””โ”€โ”€ getBoxModel()           โ†’ Element dimensions                     โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Input Domain                                                          โ”‚
    โ”‚   โ”œโ”€โ”€ dispatchMouseEvent()    โ†’ Mouse actions                          โ”‚
    โ”‚   โ”œโ”€โ”€ dispatchKeyEvent()      โ†’ Keyboard input                         โ”‚
    โ”‚   โ””โ”€โ”€ setFiles()              โ†’ File upload                            โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Accessibility Domain                                                  โ”‚
    โ”‚   โ”œโ”€โ”€ getFullAXTree()         โ†’ Accessibility tree                     โ”‚
    โ”‚   โ””โ”€โ”€ queryAXTree()           โ†’ Query by role/name                     โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Runtime Domain                                                        โ”‚
    โ”‚   โ”œโ”€โ”€ evaluate()              โ†’ Execute JavaScript                     โ”‚
    โ”‚   โ””โ”€โ”€ callFunctionOn()        โ†’ Call function on object                โ”‚
    โ”‚                                                                          โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2.3 Visual Regression Testing Patterns

Visual regression testing catches unintended visual changes:

                    VISUAL REGRESSION TESTING WORKFLOW

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                                          โ”‚
    โ”‚   BASELINE CAPTURE                                                       โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                      โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   1. Navigate to page                                                   โ”‚
    โ”‚   2. Wait for stable state (no animations, loaded images)               โ”‚
    โ”‚   3. Capture screenshot                                                 โ”‚
    โ”‚   4. Store as baseline with metadata                                    โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚  Baseline: /products page                                        โ”‚   โ”‚
    โ”‚   โ”‚  Captured: 2024-12-22T10:30:00Z                                 โ”‚   โ”‚
    โ”‚   โ”‚  Viewport: 1920x1080                                             โ”‚   โ”‚
    โ”‚   โ”‚  File: baselines/products-desktop.png                           โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   COMPARISON                                                             โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                            โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
    โ”‚   โ”‚    Baseline     โ”‚    โ”‚    Current      โ”‚    โ”‚    Diff         โ”‚    โ”‚
    โ”‚   โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚
    โ”‚   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚    โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚    โ”‚
    โ”‚   โ”‚  โ”‚ Header    โ”‚  โ”‚    โ”‚  โ”‚ Header    โ”‚  โ”‚    โ”‚  โ”‚ โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ โ”‚  โ”‚    โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”‚ vs โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”‚ =  โ”‚  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค  โ”‚    โ”‚
    โ”‚   โ”‚  โ”‚ Products  โ”‚  โ”‚    โ”‚  โ”‚ Products  โ”‚  โ”‚    โ”‚  โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  โ”‚  โ”‚    โ”‚
    โ”‚   โ”‚  โ”‚ [A] [B]   โ”‚  โ”‚    โ”‚  โ”‚ [A] [B] [C]โ”‚  โ”‚    โ”‚  โ”‚       [C]โ”‚  โ”‚    โ”‚
    โ”‚   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚    โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚    โ”‚
    โ”‚   โ”‚                 โ”‚    โ”‚                 โ”‚    โ”‚   New element!  โ”‚    โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Diff Algorithm:                                                       โ”‚
    โ”‚   โ€ข Pixel-by-pixel comparison                                           โ”‚
    โ”‚   โ€ข Perceptual hashing for fuzzy matching                               โ”‚
    โ”‚   โ€ข Ignore regions for dynamic content                                  โ”‚
    โ”‚   โ€ข Tolerance threshold for anti-aliasing                               โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   DECISION MATRIX                                                        โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                       โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Diff Percentage    Action              Example                        โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€     โ”‚
    โ”‚   0%                 PASS                No changes                     โ”‚
    โ”‚   0.1% - 1%          REVIEW              Minor shift, anti-aliasing    โ”‚
    โ”‚   1% - 5%            WARNING             Layout change, new element    โ”‚
    โ”‚   > 5%               FAIL                Major redesign                โ”‚
    โ”‚                                                                          โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2.4 Accessibility Auditing with WCAG

Web Content Accessibility Guidelines (WCAG) define standards for accessible web content:

                    WCAG COMPLIANCE LEVELS

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                                          โ”‚
    โ”‚   LEVEL A (Minimum)                                                     โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                     โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Must-have accessibility features:                                     โ”‚
    โ”‚   โ€ข All images have alt text                                            โ”‚
    โ”‚   โ€ข Form inputs have labels                                             โ”‚
    โ”‚   โ€ข Links have descriptive text                                         โ”‚
    โ”‚   โ€ข Page has proper heading structure                                   โ”‚
    โ”‚   โ€ข Keyboard navigation works                                           โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   AI Check:                                                              โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚  [A11y] Checking Level A compliance...                          โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Images: 12 found, 2 missing alt text โœ—                    โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Forms: 5 inputs, all labeled โœ“                            โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Links: 23 found, 1 empty text โœ—                           โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Headings: Proper h1โ†’h2โ†’h3 structure โœ“                     โ”‚   โ”‚
    โ”‚   โ”‚  โ””โ”€โ”€ Keyboard: All interactive elements focusable โœ“            โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   LEVEL AA (Standard)                                                   โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                   โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Enhanced accessibility:                                                โ”‚
    โ”‚   โ€ข Color contrast ratio โ‰ฅ 4.5:1 (normal text)                         โ”‚
    โ”‚   โ€ข Color contrast ratio โ‰ฅ 3:1 (large text)                            โ”‚
    โ”‚   โ€ข Text resizable to 200% without loss                                โ”‚
    โ”‚   โ€ข Focus indicators visible                                            โ”‚
    โ”‚   โ€ข Error messages descriptive                                          โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   AI Check:                                                              โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚  [A11y] Checking Level AA compliance...                         โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Contrast: 3 elements below ratio โœ—                        โ”‚   โ”‚
    โ”‚   โ”‚  โ”‚   โ””โ”€โ”€ .button-secondary: 2.8:1 (needs 4.5:1)               โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Text resize: Layout intact at 200% โœ“                      โ”‚   โ”‚
    โ”‚   โ”‚  โ”œโ”€โ”€ Focus: All elements have visible focus โœ“                  โ”‚   โ”‚
    โ”‚   โ”‚  โ””โ”€โ”€ Errors: 2 forms have generic error text โœ—                 โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   LEVEL AAA (Enhanced)                                                  โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                  โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Highest accessibility:                                                 โ”‚
    โ”‚   โ€ข Color contrast ratio โ‰ฅ 7:1 (normal text)                           โ”‚
    โ”‚   โ€ข Sign language for video content                                     โ”‚
    โ”‚   โ€ข Extended audio descriptions                                         โ”‚
    โ”‚   โ€ข Reading level appropriate                                           โ”‚
    โ”‚                                                                          โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2.5 AI-Powered Assertions

Traditional assertions are brittle. AI-powered assertions understand intent:

                    TRADITIONAL VS AI-POWERED ASSERTIONS

    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                                          โ”‚
    โ”‚   TRADITIONAL ASSERTION                                                 โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                 โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   expect(page.locator('.btn-checkout')).toBeVisible()                   โ”‚
    โ”‚   expect(page.locator('.btn-checkout')).toBeEnabled()                   โ”‚
    โ”‚   expect(page.locator('.cart-count')).toHaveText('3')                   โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Problems:                                                              โ”‚
    โ”‚   โ€ข Class name changes break tests                                      โ”‚
    โ”‚   โ€ข Doesn't verify visual prominence                                    โ”‚
    โ”‚   โ€ข Can't handle dynamic content                                        โ”‚
    โ”‚   โ€ข No semantic understanding                                           โ”‚
    โ”‚                                                                          โ”‚
    โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
    โ”‚                                                                          โ”‚
    โ”‚   AI-POWERED ASSERTION                                                   โ”‚
    โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                                                  โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   "The checkout button should be prominently displayed,                 โ”‚
    โ”‚    enabled, and the cart should show items are present"                 โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   AI Analysis:                                                           โ”‚
    โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ”‚  1. Find checkout button (semantic search)                      โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Look for button with text containing "checkout"         โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Or button with aria-label related to checkout           โ”‚   โ”‚
    โ”‚   โ”‚     โ””โ”€โ”€ Found: <button class="primary-action">Checkout</button> โ”‚   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ”‚  2. Verify "prominently displayed"                              โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Size: 200x50px (larger than average button)            โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Position: Above fold, right side (common CTA position) โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Color: High contrast #FF6B00 on white                  โ”‚   โ”‚
    โ”‚   โ”‚     โ””โ”€โ”€ Result: PROMINENT โœ“                                    โ”‚   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ”‚  3. Verify "enabled"                                            โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Check: not [disabled] attribute                        โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Check: aria-disabled !== "true"                        โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Check: opacity > 0.5                                   โ”‚   โ”‚
    โ”‚   โ”‚     โ””โ”€โ”€ Result: ENABLED โœ“                                      โ”‚   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ”‚  4. Verify "cart shows items"                                   โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Find cart indicator (icon with number/badge)           โ”‚   โ”‚
    โ”‚   โ”‚     โ”œโ”€โ”€ Check badge shows number > 0                           โ”‚   โ”‚
    โ”‚   โ”‚     โ””โ”€โ”€ Result: HAS ITEMS โœ“                                    โ”‚   โ”‚
    โ”‚   โ”‚                                                                  โ”‚   โ”‚
    โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
    โ”‚                                                                          โ”‚
    โ”‚   Benefits:                                                              โ”‚
    โ”‚   โ€ข Self-healing (finds elements by intent, not selector)               โ”‚
    โ”‚   โ€ข Verifies visual aspects (prominence, visibility)                    โ”‚
    โ”‚   โ€ข Understands semantic meaning                                        โ”‚
    โ”‚   โ€ข Natural language documentation                                      โ”‚
    โ”‚                                                                          โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

3. Complete Project Specification

3.1 What You Will Build

A Kiro CLI agent that:

  1. Controls Chrome browser sessions through MCP
  2. Executes user flows with natural language descriptions
  3. Performs visual regression testing with baseline comparison
  4. Runs accessibility audits against WCAG guidelines
  5. Uses AI to interpret pages and verify assertions
  6. Generates comprehensive HTML reports with screenshots

3.2 Functional Requirements

Requirement Description
Browser Control Navigate, click, type, scroll through Chrome MCP
User Flow Testing Execute multi-step test scenarios
Visual Regression Compare screenshots against baselines
Accessibility Audit Check WCAG A/AA compliance
AI Assertions Verify expectations using natural language
Report Generation Create HTML reports with findings
Baseline Management Create, update, and manage visual baselines

3.3 Non-Functional Requirements

  • Reliability: Handle flaky tests with smart waits and retries
  • Performance: Complete full test suite in reasonable time
  • Maintainability: Natural language tests are self-documenting
  • Portability: Tests work across different environments

4. Solution Architecture

4.1 System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       CHROME BROWSER TESTING AGENT                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚                           CLI INTERFACE                                  โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ”‚   kiro-cli chat                                                         โ”‚ โ”‚
โ”‚  โ”‚   > "Test the checkout flow on staging.example.com"                     โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                       โ”‚                                       โ”‚
โ”‚                                       โ–ผ                                       โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚                         TEST ORCHESTRATOR                                โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ Flow Parser    โ”‚  โ”‚ Test Executor  โ”‚  โ”‚ Result         โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚                โ”‚  โ”‚                โ”‚  โ”‚ Aggregator     โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Parse steps  โ”‚  โ”‚ โ€ข Run tests    โ”‚  โ”‚                โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Extract      โ”‚  โ”‚ โ€ข Capture      โ”‚  โ”‚ โ€ข Collect      โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚   assertions   โ”‚  โ”‚   screenshots  โ”‚  โ”‚   results      โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Build plan   โ”‚  โ”‚ โ€ข Verify       โ”‚  โ”‚ โ€ข Generate     โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚                โ”‚  โ”‚   assertions   โ”‚  โ”‚   report       โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                 โ”‚                                             โ”‚
โ”‚                                 โ–ผ                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚                        TESTING COMPONENTS                                โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ Visual Tester  โ”‚  โ”‚ A11y Auditor   โ”‚  โ”‚ AI Asserter    โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚                โ”‚  โ”‚                โ”‚  โ”‚                โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Screenshot   โ”‚  โ”‚ โ€ข DOM analysis โ”‚  โ”‚ โ€ข NL parsing   โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Baseline     โ”‚  โ”‚ โ€ข WCAG checks  โ”‚  โ”‚ โ€ข Screenshot   โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚   comparison   โ”‚  โ”‚ โ€ข AXE-core     โ”‚  โ”‚   analysis     โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚ โ€ข Diff report  โ”‚  โ”‚   integration  โ”‚  โ”‚ โ€ข Semantic     โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ”‚                โ”‚  โ”‚                โ”‚  โ”‚   verification โ”‚            โ”‚ โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                 โ”‚                                             โ”‚
โ”‚                                 โ–ผ                                             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚                          CHROME MCP                                      โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚ Navigation   โ”‚  โ”‚ Interaction  โ”‚  โ”‚ Analysis     โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚              โ”‚  โ”‚              โ”‚  โ”‚              โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚ โ€ข Navigate   โ”‚  โ”‚ โ€ข Click      โ”‚  โ”‚ โ€ข Screenshot โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚ โ€ข Wait       โ”‚  โ”‚ โ€ข Type       โ”‚  โ”‚ โ€ข DOM tree   โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚ โ€ข Reload     โ”‚  โ”‚ โ€ข Scroll     โ”‚  โ”‚ โ€ข A11y tree  โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ”‚              โ”‚  โ”‚ โ€ข Select     โ”‚  โ”‚ โ€ข Evaluate   โ”‚                 โ”‚ โ”‚
โ”‚  โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚ โ”‚
โ”‚  โ”‚                                                                          โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                                               โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

4.2 Test Flow Data Structures

// Core types for browser testing

interface TestFlow {
  name: string;
  description: string;
  baseUrl: string;
  steps: TestStep[];
  config: TestConfig;
}

interface TestStep {
  id: string;
  description: string;  // Natural language description
  action?: ActionSpec;
  assertion?: AssertionSpec;
  visual?: VisualSpec;
  accessibility?: AccessibilitySpec;
}

interface ActionSpec {
  type: 'navigate' | 'click' | 'type' | 'scroll' | 'wait' | 'select';
  target?: string;  // CSS selector, text, or natural language description
  value?: string;
  options?: {
    timeout?: number;
    waitFor?: 'visible' | 'hidden' | 'stable';
  };
}

interface AssertionSpec {
  type: 'ai' | 'element' | 'text' | 'url';
  description: string;  // Natural language for AI assertions
  selector?: string;
  expected?: string | RegExp;
}

interface VisualSpec {
  type: 'full-page' | 'element' | 'viewport';
  selector?: string;
  baseline?: string;
  threshold?: number;  // 0-1, percentage of allowed difference
  ignoreRegions?: { x: number; y: number; width: number; height: number }[];
}

interface AccessibilitySpec {
  level: 'A' | 'AA' | 'AAA';
  rules?: string[];  // Specific rules to check
  exclude?: string[];  // Rules to skip
}

interface TestConfig {
  viewport: { width: number; height: number };
  timeout: number;
  retries: number;
  screenshotOnFailure: boolean;
  recordVideo: boolean;
}

interface TestResult {
  flow: string;
  status: 'passed' | 'failed' | 'skipped';
  duration: number;
  steps: StepResult[];
  screenshots: Screenshot[];
  accessibility?: AccessibilityResult;
  visual?: VisualResult;
}

interface StepResult {
  step: TestStep;
  status: 'passed' | 'failed' | 'skipped';
  duration: number;
  error?: string;
  screenshot?: string;
  aiAnalysis?: string;
}

interface VisualResult {
  baseline: string;
  current: string;
  diff?: string;
  diffPercentage: number;
  status: 'match' | 'mismatch' | 'new-baseline';
}

interface AccessibilityResult {
  level: 'A' | 'AA' | 'AAA';
  score: number;  // 0-100
  issues: AccessibilityIssue[];
}

interface AccessibilityIssue {
  rule: string;
  impact: 'critical' | 'serious' | 'moderate' | 'minor';
  element: string;
  description: string;
  fix: string;
}

5. Phased Implementation Guide

Phase 1: Browser Control Foundation (Days 1-3)

Goals:

  • Establish Chrome MCP connection
  • Implement basic navigation and interaction
  • Capture screenshots

Tasks:

  1. Set up Chrome MCP integration
  2. Implement navigate, click, type actions
  3. Add screenshot capture
  4. Build wait/stability detection
  5. Create simple test runner

Milestone Checkpoint:

$ kiro-cli chat
> "Navigate to https://example.com and take a screenshot"

[Chrome MCP] Connecting to browser...
โœ“ Chrome session established
โœ“ Navigating to https://example.com
โœ“ Page loaded (1.2s)
โœ“ Screenshot captured: screenshot-20241222-103000.png

Hint 1: Use networkidle wait condition to ensure all resources are loaded before screenshots.

Phase 2: User Flow Testing (Days 4-6)

Goals:

  • Parse natural language test descriptions
  • Execute multi-step flows
  • Report step-by-step results

Tasks:

  1. Create test flow parser
  2. Implement step execution engine
  3. Add error handling and retries
  4. Build result aggregation
  5. Create console progress output

Milestone Checkpoint:

> "Test the login flow:
   1. Navigate to /login
   2. Enter email 'test@example.com'
   3. Enter password 'password123'
   4. Click the login button
   5. Verify redirect to dashboard"

[Test: Login Flow]
โ”œโ”€โ”€ Step 1: Navigate to /login โœ“
โ”œโ”€โ”€ Step 2: Enter email 'test@example.com' โœ“
โ”œโ”€โ”€ Step 3: Enter password โœ“
โ”œโ”€โ”€ Step 4: Click login button โœ“
โ””โ”€โ”€ Step 5: Verify redirect to dashboard โœ“

Flow completed: 5/5 steps passed (2.3s)

Hint 2: For finding elements, try multiple strategies in order: exact text, aria-label, placeholder, then CSS selector.

Phase 3: Visual Regression (Days 7-9)

Goals:

  • Implement baseline management
  • Build image comparison
  • Generate visual diff reports

Tasks:

  1. Create baseline storage system
  2. Implement pixel-by-pixel comparison
  3. Add perceptual diff algorithm
  4. Build ignore region support
  5. Generate HTML diff reports

Milestone Checkpoint:

> "Run visual regression on /products page"

[Visual Test: /products]
โ”œโ”€โ”€ Baseline: baselines/products-desktop.png
โ”œโ”€โ”€ Current: current/products-desktop.png
โ”œโ”€โ”€ Comparing...
โ”‚
โ”‚   Diff: 3.2% (threshold: 1%)
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   โ”‚  Changes detected:                                      โ”‚
โ”‚   โ”‚  โ€ข New element at (850, 320): "Sale" badge             โ”‚
โ”‚   โ”‚  โ€ข Price changed: $29.99 โ†’ $24.99                      โ”‚
โ”‚   โ”‚  โ€ข Layout shift: Product grid moved 5px right          โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ””โ”€โ”€ Status: FAILED (above threshold)

Generated: reports/visual-diff-products.html

Hint 3: Use a tolerance of 0.1% for anti-aliasing differences, but flag anything above 1% for human review.

Phase 4: Accessibility Auditing (Days 10-11)

Goals:

  • Implement WCAG checks
  • Integrate with accessibility tree
  • Generate compliance reports

Tasks:

  1. Build accessibility tree analyzer
  2. Implement WCAG rule checks
  3. Add contrast ratio calculation
  4. Create issue categorization
  5. Generate accessibility report

Milestone Checkpoint:

> "Run accessibility audit on /checkout"

[Accessibility Audit: /checkout]
โ”œโ”€โ”€ Level: AA
โ”œโ”€โ”€ Score: 87/100
โ”‚
โ”œโ”€โ”€ Issues Found: 6
โ”‚   โ”œโ”€โ”€ CRITICAL (1)
โ”‚   โ”‚   โ””โ”€โ”€ Form input missing label: #card-number
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ SERIOUS (2)
โ”‚   โ”‚   โ”œโ”€โ”€ Contrast ratio 2.8:1 on .hint-text (needs 4.5:1)
โ”‚   โ”‚   โ””โ”€โ”€ Focus not visible on .link-terms
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ MODERATE (2)
โ”‚   โ”‚   โ”œโ”€โ”€ Missing heading structure (h1 โ†’ h3, skipped h2)
โ”‚   โ”‚   โ””โ”€โ”€ Tab order not logical in address form
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ MINOR (1)
โ”‚       โ””โ”€โ”€ Image without alt: decorative-border.png
โ”‚
โ””โ”€โ”€ Report: reports/a11y-checkout.html

Phase 5: AI-Powered Assertions (Days 12-14)

Goals:

  • Implement natural language assertion parsing
  • Use AI to analyze screenshots
  • Build semantic element finding

Tasks:

  1. Create assertion parser
  2. Implement screenshot analysis with AI
  3. Build semantic element finder
  4. Add confidence scoring
  5. Create detailed assertion reports

Milestone Checkpoint:

> "Verify the checkout button is prominent and enabled when cart has items"

[AI Assertion]
โ”œโ”€โ”€ Analyzing page...
โ”‚
โ”œโ”€โ”€ Finding checkout button:
โ”‚   โ””โ”€โ”€ Found: <button>Proceed to Checkout</button> at (1050, 450)
โ”‚
โ”œโ”€โ”€ Checking prominence:
โ”‚   โ”œโ”€โ”€ Size: 200x48px (large for context) โœ“
โ”‚   โ”œโ”€โ”€ Position: Above fold, primary action area โœ“
โ”‚   โ”œโ”€โ”€ Color: High contrast #FF6B00 on white โœ“
โ”‚   โ””โ”€โ”€ Result: PROMINENT โœ“
โ”‚
โ”œโ”€โ”€ Checking enabled state:
โ”‚   โ”œโ”€โ”€ Disabled attribute: false โœ“
โ”‚   โ”œโ”€โ”€ Aria-disabled: not set โœ“
โ”‚   โ”œโ”€โ”€ Visual opacity: 100% โœ“
โ”‚   โ””โ”€โ”€ Result: ENABLED โœ“
โ”‚
โ”œโ”€โ”€ Checking cart state:
โ”‚   โ”œโ”€โ”€ Cart icon found at (1150, 25)
โ”‚   โ”œโ”€โ”€ Badge shows "3" items
โ”‚   โ””โ”€โ”€ Result: HAS ITEMS โœ“
โ”‚
โ””โ”€โ”€ Assertion: PASSED โœ“

6. Testing Strategy

6.1 Testing the Test Framework

describe('VisualComparison', () => {
  it('should detect no difference for identical images', async () => {
    const baseline = await loadImage('test-fixtures/page-a.png');
    const current = await loadImage('test-fixtures/page-a.png');

    const result = await compareImages(baseline, current);

    expect(result.diffPercentage).toBe(0);
    expect(result.status).toBe('match');
  });

  it('should detect differences above threshold', async () => {
    const baseline = await loadImage('test-fixtures/page-a.png');
    const current = await loadImage('test-fixtures/page-b.png');

    const result = await compareImages(baseline, current, { threshold: 0.01 });

    expect(result.diffPercentage).toBeGreaterThan(0.01);
    expect(result.status).toBe('mismatch');
  });

  it('should ignore specified regions', async () => {
    const baseline = await loadImage('test-fixtures/with-date.png');
    const current = await loadImage('test-fixtures/with-different-date.png');

    const result = await compareImages(baseline, current, {
      ignoreRegions: [{ x: 10, y: 10, width: 100, height: 20 }]
    });

    expect(result.status).toBe('match');
  });
});

6.2 Accessibility Audit Tests

describe('AccessibilityAuditor', () => {
  it('should detect missing alt text', async () => {
    const html = `
      <img src="photo.jpg">
      <img src="icon.png" alt="">
      <img src="logo.png" alt="Company Logo">
    `;

    const issues = await auditAccessibility(html, { level: 'A' });

    expect(issues).toContainEqual(expect.objectContaining({
      rule: 'img-alt',
      impact: 'critical'
    }));
    expect(issues.filter(i => i.rule === 'img-alt')).toHaveLength(2);
  });

  it('should check contrast ratios', async () => {
    const html = `
      <p style="color: #777; background: #fff;">Low contrast text</p>
    `;

    const issues = await auditAccessibility(html, { level: 'AA' });

    expect(issues).toContainEqual(expect.objectContaining({
      rule: 'color-contrast',
      impact: 'serious'
    }));
  });
});

7. Common Pitfalls and Debugging

7.1 Common Issues

Pitfall Symptom Solution
Flaky tests Random failures Add smart waits, use stable selectors
Screenshot timing Captures mid-animation Wait for networkidle + animation complete
Element not found Selector breaks Use semantic finding (text, role, label)
Baseline drift Too many false positives Update baselines intentionally, use ignore regions
Slow tests Suite takes too long Parallelize, reuse browser sessions

7.2 Debugging Strategies

1. Enable verbose logging:

> "Run tests with debug output"

[DEBUG] Navigating to /products
[DEBUG] Waiting for networkidle...
[DEBUG] Network idle after 1.2s
[DEBUG] Finding element: "Add to Cart button"
[DEBUG] Strategy 1 (text): Found 0 matches
[DEBUG] Strategy 2 (aria-label): Found 3 matches
[DEBUG] Strategy 3 (role=button): Found 1 match (best fit)
[DEBUG] Clicking element at (450, 320)

2. Capture failure screenshots:

[FAILED] Step 3: Click checkout button

Failure details:
โ”œโ”€โ”€ Error: Element not interactable
โ”œโ”€โ”€ Element: <button disabled>Checkout</button>
โ”œโ”€โ”€ Reason: Button is disabled (cart is empty)
โ””โ”€โ”€ Screenshot: failures/checkout-step3.png

3. Interactive debugging:

> "Pause test and let me inspect the page"

[PAUSED] Test paused at step 3
Browser window is visible for inspection.
Type 'continue' to resume or 'abort' to stop.

8. Extensions and Challenges

8.1 Beginner Extensions

  • Add support for mobile viewport testing
  • Implement cookie consent handling
  • Create reusable test snippets library

8.2 Intermediate Extensions

  • Build cross-browser testing (Firefox, Safari)
  • Add video recording of test runs
  • Implement parallel test execution

8.3 Advanced Extensions

  • Machine learning for flaky test detection
  • Auto-generate tests from user session recordings
  • Self-healing selector system

9. Real-World Connections

9.1 Industry Tools

Tool Similar Pattern Company
Percy Visual regression BrowserStack
Applitools Visual AI testing Applitools
Playwright Browser automation Microsoft
Cypress E2E testing Cypress.io
Axe Accessibility testing Deque

9.2 Professional Applications

  • CI/CD Integration: Run visual and accessibility tests on every PR
  • Design Systems: Ensure component consistency across updates
  • Compliance: Maintain WCAG compliance for legal requirements
  • Regression Prevention: Catch unintended changes before production

10. Self-Assessment Checklist

Understanding Verification

  • I understand Chrome DevTools Protocol basics
  • I can explain visual regression testing workflow
  • I know WCAG A, AA, AAA levels
  • I understand AI-powered vs traditional assertions
  • I can describe baseline management strategies

Implementation Verification

  • Browser control works (navigate, click, type)
  • Multi-step test flows execute correctly
  • Visual comparison detects differences
  • Accessibility audit finds issues
  • AI assertions interpret page content

Integration Verification

  • Full test suite runs on a real website
  • Reports are generated with useful information
  • Baseline management works correctly
  • Tests are stable (not flaky)

11. Completion Criteria

Minimum Viable Completion

  • Control Chrome through MCP
  • Execute basic user flows
  • Capture and compare screenshots
  • Run simple accessibility checks
  • Generate text-based reports

Full Completion

  • AI-powered semantic assertions
  • Full visual regression with diffs
  • Comprehensive accessibility auditing
  • HTML reports with screenshots
  • Baseline management system

Excellence (Going Above and Beyond)

  • Cross-browser support
  • Video recording
  • Self-healing selectors
  • Parallel execution
  • CI/CD integration templates

This guide was expanded from LEARN_KIRO_CLI_MASTERY.md. For the complete learning path, see the README.