← Back to AI

Autonomous QA Agent (Mac M3 Local Edition)

Enterprise-Grade Local QA Engineer Agent — Python, Playwright, Robot Framework, and Local LLM แบบ 100% On-Premise

1. System Overview & Core Capabilities

  • Target Hardware & Environment: Apple Silicon Mac M3 (16GB Unified Memory), macOS, Python 3.11+, Ollama
  • Testing Engine: Robot Framework (robotframework-browser ขับเคลื่อนด้วย Playwright Node.js Engine)
  • Intelligence Layer: Ollama (qwen2.5-coder:7b) พร้อม Dynamic Few-Shot Prompting
  • Architecture Pattern: Page Object Model (POM) แยกชั้นชัดเจนระหว่าง Pages (Locators & Low-level Actions) และ Suites (High-level Business Scenarios)

Key Differentiators (Enterprise Features)

  • Headless DOM Pruner: สกัด Accessibility/Interactive Tree จากหน้าเว็บจริง ย่อ HTML 50KB เหลือ < 1,000 Tokens เพื่อตัดปัญหาโมเดลหลอน Selector
  • AST & Dry-run Linter: ตรวจสอบโครงสร้าง Whitespace และความถูกต้องของ Keyword ล่วงหน้าด้วย robot.api.parsing ก่อนเปิดเบราว์เซอร์จริง
  • Execution Parser & Taxonomy: สกัดอ่าน output.xml เพื่อแยกแยะระหว่าง Application Bug (Actual != Expected) และ Script Flakiness (Selector หาย / Timeout)
  • Bounded Self-Healing: กลไกวนลูปแก้ไขตัวเองอัตโนมัติสูงสุด 3 รอบ พร้อมบันทึก Screenshots และ Traces ยืนยันผล

2. System Architecture Blueprint

[Input: Test Spec (Markdown/Text) + Target URL]
                       │
                       ▼
         ┌───────────────────────────┐
         │   Test Case Normalizer    │ ◄─── Pydantic Schema
         └─────────────┬─────────────┘
                       │
        ┌──────────────┴──────────────┐
        ▼                             ▼
┌──────────────────┐        ┌──────────────────┐
│ DOM Tree Pruner  │        │ Keyword Registry │
│  (Playwright)    │        │  (Whitelisted)   │
└───────┬──────────┘        └─────────┬────────┘
        │                             │
        └──────────────┬──────────────┘
                       ▼
         ┌───────────────────────────┐
         │   Few-Shot Synthesizer    │ ◄─── Ollama (qwen2.5-coder:7b)
         │  (POM Generator Engine)   │
         └─────────────┬─────────────┘
                       │
                       ▼
         ┌───────────────────────────┐
         │    Robot AST Validator    │ ◄─── robot.api.parsing & --dryrun
         └─────────────┬─────────────┘
                       │
                       ▼
         ┌───────────────────────────┐
         │ Headless Execution Engine │ ◄─── Playwright + Subprocess
         └─────────────┬─────────────┘
                       │
                       ▼
         ┌───────────────────────────┐
         │ Actual vs Expected Parser │ ◄─── output.xml Evaluation
         └─────────────┬─────────────┘
                       │
            [Fail: Locator Error] ──► Self-Healing Loop (Max 3)
            [Fail: Assertion]     ──► UI Defect Bug Report
            [Pass]                ──► Summary Dashboard

3. Directory Layout Specification

qa-agent/
├── config/
│   └── default_settings.yaml       # Base URL, Timeout, Browser Type, Headless Flags
├── core/
│   ├── normalizer.py               # Pydantic Input Parser & Intent Extractor
│   ├── dom_crawler.py              # Playwright Headless Interactive Tree Pruner
│   ├── synthesizer.py              # Ollama Engine & Prompt Assembly
│   ├── validator.py                # Robot AST Linter & Subprocess Dry-run
│   ├── runner.py                   # Subprocess Execution Controller
│   ├── result_parser.py            # XML Log Parser (Actual vs Expected)
│   ├── self_healing.py             # Autonomous Selector Healing Loop
│   └── reporter.py                 # Summary Generator & Rich Terminal Dashboard
├── resources/
│   ├── common/
│   │   └── browser_lifecycle.robot # Setup Browser, Teardown, Auto-Screenshot
│   └── pages/                      # Page Object Model (Generated Locators & Actions)
├── tests/
│   └── suites/                     # Test Cases (.robot)
├── results/                        # Reports, Traces, Screenshots, XML Logs
├── cli.py                          # Unified Command-Line Interface Entrypoint
└── requirements.txt                # Python Dependencies

4. 14-Day Production Roadmap

วันที่ 1–14 ยังเป็นแผนหลักสูตร — หน้าบทเรียนรายวันจะลิงก์เมื่อไฟล์พร้อม

Phase 1: Architecture Blueprint, Scaffolding & Browser Runtime

  • Day 1: Project Scaffolding & Enterprise Directory Architecture — สร้างโครงสร้างระดับโปรดักชัน ติดตั้ง robotframework-browser และรัน rfbrowser init บน Mac M3
  • Day 2: Test Case Specification Schema & Pydantic Normalizer — สร้าง core/normalizer.py สกัด Intent แยก Preconditions, Actions, Assertions
  • Day 3: Standard DSL & Page Object Model Rule Engine — แยกคู่ไฟล์ pages/<name>_page.robot และ suites/<name>_test.robot

Phase 2: Autonomous DOM Perception & Test Synthesis

  • Day 4: Headless DOM Pruning & Interactive Tree Builder — core/dom_crawler.py กรอง Interactive Elements (< 1,000 Tokens)
  • Day 5: Prompt Assembly & Few-Shot Ingestion Engine — core/synthesizer.py สั่ง qwen2.5-coder:7b สังเคราะห์ POM
  • Day 6: Robot AST Parser & Subprocess Dry-Run Validator — core/validator.py และ robot --dryrun
  • Day 7: Milestone 1 — Deterministic Code Generation Testbed

Phase 3: Execution Engine, Assertion Engine & Self-Healing

  • Day 8: Subprocess Headless Execution Controller — core/runner.py
  • Day 9: XML Execution Parser & Actual vs Expected Evaluator — core/result_parser.py
  • Day 10: Artifact Harvesting (Screenshots, Traces & Failure Snapshots)
  • Day 11: The Autonomous Self-Healing Loop — สูงสุด 3 รอบ

Phase 4: CLI Cockpit, Verification Reports & Packaging

  • Day 12: Comprehensive QA Verification Report Generator — core/reporter.py
  • Day 13: Terminal Cockpit Interface (Rich CLI)
  • Day 14: System Packaging & End-to-End Simulation Milestone — qa-agent run ...

บทเรียนรายวันกำลังจะมา