# ๐ŸŒ AI Web Tester ### *The Autonomous Eyes & Hands for AI Coding Agents in the Browser* [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg?style=flat-square&logo=typescript)](https://www.typescriptlang.org/) [![Playwright](https://img.shields.io/badge/Playwright-1.49-green.svg?style=flat-square&logo=playwright)](https://playwright.dev/) [![Model Context Protocol](https://img.shields.io/badge/MCP-Protocol-purple.svg?style=flat-square)](https://modelcontextprotocol.io/) [![M8ven Verified](https://m8ven.ai/badge/mcp/siamalsobari-ai-web-tester-a1ng3r?variant=verified)](https://m8ven.ai/mcp/siamalsobari-ai-web-tester-a1ng3r) [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20.x-339933.svg?style=flat-square&logo=nodedotjs)](https://nodejs.org/) [![License](https://img.shields.io/badge/License-MIT-orange.svg?style=flat-square)](LICENSE)

Give your AI coding assistant (OpenCode, Antigravity, Claude Code, Cursor, Windsurf) the power to interact with, explore, test, and fix real web applications like a Senior QA Engineer.

> [!IMPORTANT] > ๐Ÿ“– **Looking for step-by-step setup instructions or local development setup?** Check out the [**Complete Installation & Setup Guide (INSTALL.md)**](INSTALL.md) for 1-command installer wizards, agent-specific guides (OpenCode, Antigravity, Claude Code, Cursor, Windsurf), and troubleshooting tips. --- ## ๐Ÿ’ก The Missing Piece in AI Coding AI coding agents can write complex code, refactor components, and fix syntax errors. But there has always been a fundamental blind spot: **AI agents cannot see or experience the application running in a real browser.** A login page might have clean code, yet: * The submit button fails to trigger in specific browser states. * An unhandled JavaScript exception silently crashes the React hydration root. * Form validation passes invalid email formats or crashes on edge-case inputs. * Dynamic modals or infinite scrolls break user navigation. **`ai-web-tester` bridges this gap.** It acts as the high-speed sensory and motor system for AI agents, allowing them to autonomously open URLs (localhost or live), test multi-step user scenarios, catch runtime errors, take visual snapshots of bugs, and compile professional Markdown reports. --- ## โšก Key Highlights ### 1. ๐Ÿง  Senior QA Testing Matrices Built-in Your AI agent doesn't just "click a button" โ€” it executes comprehensive, multi-layer test matrices: * **Empty / Required Field Validation**: Checks HTML5 & custom error states when mandatory fields are omitted. * **Format Violations & Boundary Limits**: Tests invalid email syntax, password length boundaries, and type constraints. * **Wrong Credentials & State Integrity**: Verifies 401 alert banners and error handling without application crashes. * **Security & Injection Guardrails**: Evaluates handling of special characters, SQLi patterns (`' OR '1'='1`), and XSS strings. * **Happy Path (End-to-End Success)**: Completes full user flows and validates state changes, cookies, and redirects. ### 2. ๐Ÿชถ >90% Token Reduction (Semantic State Compression) Raw HTML DOM dumps consume tens of thousands of LLM tokens and cause selector hallucinations. **`ai-web-tester` prunes the DOM and extracts a clean, numbered Accessibility (ARIA) Tree**: ```text ๐ŸŒ Current Page: "Customer Portal" [1] textbox "Email" (required, placeholder="name@domain.com") [2] textbox "Password" (type=password) [3] button "Sign In" [4] link "Forgot Password?" ``` The AI agent interacts simply by referencing deterministic IDs: `click(ref=3)` or `fill(ref=1, "admin@test.com")`. ### 3. ๐Ÿš€ Lightweight & Headless by Default Runs entirely in the background using headless Chromium. It consumes minimal RAM and CPU, ensuring your computer stays fast and quiet while your agent audits your application. ### 4. ๐Ÿ“ธ Smart Error-Triggered Screenshots No wasted disk space or clutter. Screenshots are captured **automatically only when an anomaly occurs** (console error, network 500, unhandled exception, or broken selector) and saved directly into `./artifacts/` with direct clickable links in the report. ### 5. ๐Ÿšจ 360ยฐ Runtime Telemetry & Crash Watchdog Silently observes browser lifecycle events: * **`console.error` & `console.warn`** interceptor with precise stack traces. * **Unhandled JavaScript runtime exceptions** (`pageerror`). * **Failed HTTP network responses** (`4xx` / `5xx`) and broken asset requests. * **Main-thread freeze & infinite loop detection** via watchdog timeout guards. ### 6. ๐Ÿ“„ Automated Markdown (.md) Test Reports Compiles test results into standardized, human-readable Markdown documents with YAML frontmatter at `./test-reports/report-[runId].md`: * Overall status (`PASSED`, `FAILED`, `WARNING`) and duration metrics. * Complete step-by-step audit log with `โœ…` and `โŒ` status indicators. * Exact error traces and reproduction steps. * Embedded links to screenshot artifacts. * Actionable fix recommendations for the developer or AI agent. --- ## ๐Ÿง™ 1-Command Universal Setup Wizard Easily configure `ai-web-tester` for any AI agent on your machine with one interactive command: ```bash node dist/cli.js init ``` Or target a specific agent directly: ```bash # For OpenCode node dist/cli.js init -a opencode # For Antigravity node dist/cli.js init -a antigravity # For Claude Code / Claude Desktop node dist/cli.js init -a claude # For Cursor node dist/cli.js init -a cursor # For Windsurf / Roo Code node dist/cli.js init -a windsurf # For ALL agents at once node dist/cli.js init -a antigravity opencode claude cursor windsurf ``` --- ## ๐Ÿค– Supported AI Agent Ecosystems | Agent | Configuration Location | Integration Type | | :--- | :--- | :--- | | **OpenCode** | `~/.config/opencode/config.json` | Native MCP + Skills | | **Antigravity** | `~/.gemini/config/mcp_config.json` | Native MCP + Global Skills | | **Claude Code / Desktop** | `claude_desktop_config.json` | Stdio MCP Server | | **Cursor** | `~/.cursor/mcp.json` | Project / Global MCP | | **Windsurf / Roo Code** | `~/.codeium/windsurf/mcp_config.json` | Universal MCP | --- ## ๐Ÿ› ๏ธ Model Context Protocol (MCP) Tools When connected via MCP, your AI coding agent gains access to **26 specialized enterprise-grade tools**: ```text โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ AI Web Tester MCP Engine โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ–ผ โ–ผ โ–ผ โ–ผ Browser & Act Assertions & Perf Crawl & A11y Telemetry & Reports (open, act, (assert, assert_perf, (crawl, audit_a11y, (console_logs, fill_form, tabs) wait_for, extract) screenshot, mock) network_logs, md/html/junit) ``` | Tool Name | Key Parameters | Description | | :--- | :--- | :--- | | `browser_open` | `url` *(required)*, `headless?`, `device?`, `browser?`, `storageState?`, `replayHar?`, `networkProfile?`, `recordTrace?`, `recordVideo?`, `recordHar?`, `sessionId?` | Opens the target URL in Chromium/Firefox/WebKit, applies device presets, loads auth states, and returns initial ARIA state. | | `browser_act` | `action` *(click, fill, hover, press, select, scroll, upload, download, switch_tab, screenshot)*, `ref?`, `value?`, `filePaths?`, `screenshotName?`, `sessionId?` | Executes an interaction on a referenced element with retry logic, full-spectrum self-healing, or file I/O. | | `browser_fill_form` | `formRef?`, `mode?` *('valid' \| 'fuzz')*, `overrides?`, `sessionId?` | Smart form auto-filler and security fuzzer (optionally scoped to `formRef`). | | `browser_assert` | `kind` *(visible, hidden, exists, text, value, contains, enabled, disabled, checked, count)*, `ref?`, `expected?`, `operator?`, `sessionId?` | Asserts live DOM state and records `ASSERTION_FAILURE` issues on mismatch. | | `browser_assert_perf` | `metric` *(fcp, load, ttfb, domContentLoaded, dcl)*, `thresholdMs`, `operator?`, `sessionId?` | Enforces Web Vitals performance budgets. | | `browser_inspect` | `sessionId?` | Refreshes and returns the active page state, interactive refs, and captured runtime errors. | | `browser_console_logs` | `limit?`, `type?` *('all' \| 'error' \| 'warning' \| 'info' \| 'log')*, `sessionId?` | Queries recent browser console logs on demand. | | `browser_network_logs` | `limit?`, `failedOnly?`, `sessionId?` | Queries recent HTTP requests, status codes, and latencies. | | `browser_switch_tab` | `tabIndex?`, `sessionId?` | Switches active browser focus between multiple tabs or OAuth popups, or lists all open tabs. | | `browser_save_auth` | `path?`, `sessionId?` | Saves active browser session cookies and localStorage to JSON for re-use in future tests. | | `browser_mock` | `urlPattern`, `status?`, `body?`, `contentType?`, `sessionId?` | Mocks network routes to simulate error states (e.g. 401/500) without backend changes. | | `browser_mock_reset` | `urlPattern?`, `sessionId?` | Clears all mocked routes or a specific URL pattern. | | `browser_audit_a11y` | `sessionId?` | Runs an automated WCAG 2.1 AA accessibility audit via `axe-core` and returns findings. | | `browser_crawl` | `url` *(required)*, `maxDepth?`, `maxPages?`, `storageState?` | Autonomously explores internal routes, maps sitemap hierarchy, and identifies broken 4xx/5xx links. | | `browser_screenshot` | `name?`, `fullPage?`, `compareBaseline?`, `threshold?`, `sessionId?` | Captures a visual screenshot and optionally runs `pixelmatch` visual regression diffing. | | `browser_live_screenshot` | `fullPage?`, `sessionId?` | Returns a live base64 PNG screenshot for dashboards without writing to disk. | | `browser_report` | `title?`, `outputPath?`, `sessionId?` | Compiles test execution history, telemetry, and screenshots into a structured `.md` report. | | `browser_report_junit` | `outputPath?`, `sessionId?` | Generates a JUnit XML report for CI/CD systems. | | `browser_report_html` | `outputPath?`, `sessionId?` | Generates a self-contained styled HTML test report. | | `browser_generate_scenario` | `name?`, `sessionId?` | Exports the active session's actions into a replayable YAML scenario file. | | `browser_run_scenario` | `path` | Replays a YAML test scenario with data-driven concurrency, hooks, and semantic selectors. | | `browser_sessions` | _(none)_ | Lists all active isolated multi-sessions. | | `browser_health` | _(none)_ | Reports browser engine status, version, open pages, and artifact disk usage. | | `browser_wait_for` | `ref`, `state?`, `timeoutMs?`, `sessionId?` | Waits deterministically for an element to become visible, hidden, attached, or detached. | | `browser_extract` | `ref`, `attribute?` *('text' \| 'value' \| 'html' \| 'href')*, `sessionId?` | Extracts element text, value, HTML, or href for chaining. | | `browser_close` | `sessionId?` | Safely terminates the browser session and frees all system memory. | --- ## ๐Ÿ–ฅ๏ธ Standalone CLI Usage You can also run automated browser tests directly from your terminal: ```bash # 1. Diagnose Node.js, Playwright browser engine & agent integrations node dist/cli.js doctor # 2. Quick inspection of interactive elements on any page (with optional device preset) node dist/cli.js open http://localhost:3000 -d "iPhone 15" # 3. Run automated health check & compile Markdown/HTML/JUnit reports with Playwright trace node dist/cli.js test http://localhost:3000 --title "Homepage Smoke Test" --trace --html --junit # 4. Autonomously crawl internal website routes & build sitemap node dist/cli.js crawl http://localhost:3000 --depth 3 --pages 20 # 5. Auto-generate, record, or run replayable YAML scenarios node dist/cli.js generate http://localhost:3000 -o scenarios/smoke.yaml node dist/cli.js record http://localhost:3000 -o scenarios/recorded.yaml node dist/cli.js run scenarios/smoke.yaml # 6. Interactive QA REPL shell node dist/cli.js repl # 7. Start local interactive web dashboard (defaults to 127.0.0.1:3100) node dist/cli.js ui --port 3100 --host 127.0.0.1 # 8. Clean temporary artifacts & test reports node dist/cli.js clean # 9. Start the MCP Server over stdio manually node dist/cli.js serve-mcp # 10. Configure or uninstall AI agent integrations node dist/cli.js init node dist/cli.js uninstall ``` --- ## ๐Ÿ“‹ Sample Markdown Test Report Output When your test finishes, `ai-web-tester` generates a report like this: ```markdown --- test_run_id: "rep-1723651234-a8f2" title: "Authentication Flow - Senior QA Matrix" target_url: "http://localhost:3000/login" status: "PASSED" duration_ms: 3420 total_steps: 5 passed_steps: 5 failed_steps: 0 issues_count: 0 timestamp: "2026-08-14T23:45:00.000Z" --- # ๐Ÿ“‹ Laporan Hasil Pengujian: Authentication Flow - Senior QA Matrix ## ๐Ÿ“Š Ringkasan Eksekusi * **Target URL**: `http://localhost:3000/login` * **Status Keseluruhan**: โœ… PASSED * **Durasi Pengujian**: 3.42 detik (3420 ms) * **Total Langkah**: 5 (โœ… 5 Passed | โŒ 0 Failed) * **Total Isu/Error**: 0 --- ## ๐Ÿšถ Urutan Langkah Pengujian (Execution Steps) โœ… **Step 1**: `CLICK` on [ref=3] (button "Sign In") โ€” *Tested empty field validation* โœ… **Step 2**: `FILL` on [ref=1] with value `"invalid-email"` โ€” *Tested invalid email format* โœ… **Step 3**: `FILL` on [ref=1] with value `"' OR '1'='1"` โ€” *Tested security edge cases* โœ… **Step 4**: `FILL` on [ref=1] with value `"valid@company.com"` โœ… **Step 5**: `FILL` on [ref=2] with value `"secretpass123"` --- ## ๐Ÿšจ Temuan Masalah & Error (Issues & Anomalies) โœ… *No runtime errors, console errors, or failed network responses detected.* --- ## ๐Ÿ’ก Rekomendasi untuk AI Coding Agent / Developer - Semua langkah pengujian berhasil dijalankan tanpa terdeteksi anomali. ``` --- ## ๐Ÿ—๏ธ Architecture & Engineering Principles Built with clean **Hexagonal Architecture (Ports and Adapters)**: * **Domain Core**: Pure domain models (`Session`, `Action`, `PageState`, `Issue`, `TestReport`) free from third-party framework dependencies. * **Outbound Infrastructure**: High-resilience Playwright driver with smart auto-waiting, auto-scrolling, telemetry observers, and a Handlebars Markdown report generator. * **Inbound Interfaces**: First-class Model Context Protocol (MCP) server over standard input/output (`stdio`) and Commander CLI runner. * **Anti-Zombie Browser Protection**: Signal traps on `SIGINT`, `SIGTERM`, `SIGHUP`, and uncaught exceptions guarantee that headless Chromium processes are never orphaned in system memory. --- ## ๐Ÿงช Development & Contribution ```bash # Install dependencies npm install # Download Chromium browser npx playwright install chromium # Run full unit & E2E integration test suite npm test # Run strict TypeScript typechecking npm run typecheck # Build ESM & TypeScript declaration bundles npm run build ``` --- ## ๐Ÿ“„ License Distributed under the **MIT License**. See `LICENSE` for more information.