Skip to main content

An autonomous self-healing agent for Playwright tests with AI-powered Root Cause Analysis.

Project description

Healix

Healix is an intelligent web automation agent that self-heals broken selectors and adapts to dynamic web pages using AI-powered DOM analysis.

๐ŸŽฏ The Problem

Web automation is fragile. Selectors break when:

  • Developers change class names
  • DOM structure shifts
  • Content loads dynamically
  • A/B tests alter page layouts

๐Ÿš€ The Solution

Healix uses an agentic loop to automatically detect and fix selector failures:

  1. Observe - Analyze the current page state and DOM
  2. Reason - Use AI to determine the correct selector/action
  3. Act - Execute the corrected action
  4. Verify - Confirm the action succeeded
  5. Learn - Cache successful fixes for future use

Operational Workflow

flowchart TD
    subgraph Execution["Test Execution Layer"]
        Start(["๐Ÿ’ฅ Test Failure Detected"])
        RetryCache(["โ™ป๏ธ Re-run with Cache"])
        RetryAI(["โšก Re-run with AI Fix"])
    end

    subgraph Persistence["Persistence Layer"]
        CheckCache{"๐Ÿง  Check Cache"}
        ApplyCache["๐Ÿ“ฅ Apply Cached Selector"]
        UpdateCache[("๐Ÿ’พ Update Cache")]
    end

    subgraph Intelligence["AI Intelligence Layer"]
        CleanDOM["๐Ÿงผ DOM Scrubbing & Minification"]
        AskOllama["๐Ÿค– Query Ollama (qwen2.5-coder)"]
        Analyze["๐Ÿ“Š Confidence Scoring"]
    end

    subgraph Feedback["Reporting Layer"]
        Success(["โœ… Healing Successful"])
        Manual(["โš ๏ธ Manual Review Required"])
        Proposal[("๐Ÿ“ Log Code Proposal")]
    end

    %% Flow Logic
    Start --> CheckCache
    
    CheckCache -- "Hit" --> ApplyCache
    ApplyCache --> RetryCache
    
    CheckCache -- "Miss" --> CleanDOM
    
    RetryCache -- "Success" --> Success
    RetryCache -- "Fail" --> CleanDOM
    
    CleanDOM --> AskOllama
    AskOllama --> Analyze
    
    Analyze -- "High Confidence" --> RetryAI
    Analyze -- "Low Confidence" --> Manual
    
    RetryAI -- "Success" --> UpdateCache
    UpdateCache --> Success
    
    RetryAI -- "Fail" --> Manual
    
    Success --> Proposal
    Manual --> Proposal
    Proposal --> End(["๐Ÿ Action Complete"])

    %% Premium Styling
    classDef startEnd fill:#f8fafc,stroke:#64748b,stroke-width:2px,color:#1e293b
    classDef intelligence fill:#eff6ff,stroke:#3b82f6,stroke-width:2px,color:#1e3a8a
    classDef persistence fill:#ecfdf5,stroke:#10b981,stroke-width:2px,color:#064e3b
    classDef execution fill:#fff7ed,stroke:#f59e0b,stroke-width:2px,color:#7c2d12
    classDef feedback fill:#faf5ff,stroke:#a855f7,stroke-width:2px,color:#581c87
    classDef decision fill:#ffffff,stroke:#334155,stroke-width:2px,stroke-dasharray: 5 5

    class Start,End startEnd
    class CleanDOM,AskOllama,Analyze intelligence
    class CheckCache,ApplyCache,UpdateCache persistence
    class RetryCache,RetryAI execution
    class Success,Manual,Proposal,GenerateFeedback feedback
    class CheckCache,Analyze decision

๐Ÿ—๏ธ Architecture

healix/
โ”œโ”€โ”€ .github/                   # CI/CD workflows
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ main.yml           # Automated test runs
โ”œโ”€โ”€ src/                       # Source code for the library
โ”‚   โ””โ”€โ”€ healix/
โ”‚       โ”œโ”€โ”€ __init__.py        # Makes it a package
โ”‚       โ”œโ”€โ”€ engine.py          # The core Healix class
โ”‚       โ””โ”€โ”€ utilities/         # Helper functions
โ”‚           โ”œโ”€โ”€ __init__.py
โ”‚           โ””โ”€โ”€ dom_scrubber.py # BeautifulSoup logic
โ”œโ”€โ”€ tests/                     # Test suites to verify Healix
โ”‚   โ”œโ”€โ”€ integration/
โ”‚   โ”‚   โ””โ”€โ”€ test_login.py      # Demo test case
โ”‚   โ””โ”€โ”€ unit/
โ”‚       โ””โ”€โ”€ test_engine.py     # Testing the AI logic/cleaner
โ”œโ”€โ”€ data/                      # Local data storage
โ”‚   โ””โ”€โ”€ healix_cache.json      # Persistent cache for fixes
โ”œโ”€โ”€ docker/                    # Containerized environments
โ”‚   โ””โ”€โ”€ Dockerfile
โ”œโ”€โ”€ .gitignore                 # Ignore __pycache__ and local config
โ”œโ”€โ”€ requirements.txt           # Dependencies
โ””โ”€โ”€ README.md                  # This file

๐Ÿ› ๏ธ Installation

# Clone the repository
git clone <repository-url>
cd healix

# Install dependencies
pip install -r requirements.txt

# Install Playwright browsers
playwright install chromium

๐Ÿšฆ Quick Start

import asyncio
from playwright.async_api import async_playwright
from healix.engine import smart_click

async def test_healix_agent():
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=False)
        page = await browser.new_page()
        
        await page.goto("https://example.com")
        
        # Healix will automatically fix broken selectors
        await smart_click(page, "#broken-selector")
        
        await browser.close()

if __name__ == "__main__":
    asyncio.run(test_healix_agent())

๐Ÿง  How It Works

DOM Cleaning & Privacy

  • Strips scripts, styles, and heavy elements to save tokens
  • Masks PII (Personally Identifiable Information) for privacy
  • Focuses on actionable elements (buttons, links, inputs)

AI-Powered Reasoning

  • Uses local LLM (Ollama) for selector analysis
  • Considers both technical errors and visible page state
  • Returns confidence scores and explanations

Persistent Learning

  • Caches successful fixes in healix_cache.json
  • Gets faster over time as it learns common patterns
  • Maintains context across test runs

๐Ÿ”ง Configuration

Healix uses Ollama for local AI inference:

from healix.engine import Healix

# Default model: qwen2.5-coder:7b
healix = Healix(model="your-preferred-model")

Make sure Ollama is running:

ollama serve

๐Ÿงช Testing

# Run all tests
pytest tests/

# Run with coverage
pytest tests/ --cov=src/healix --cov-report=html

# Run integration tests (requires browser)
pytest tests/integration/

๐Ÿณ Docker Support

# Build the container
docker build -t healix .

# Run tests in container
docker run healix

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

๐Ÿ“„ License

[Add your license here]

๐Ÿ”ฎ Roadmap

  • Support for more AI models (OpenAI, Anthropic)
  • Visual regression testing
  • Multi-browser support expansion
  • Performance optimization for large-scale testing
  • Plugin system for custom healing strategies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

healix_ai-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

healix_ai-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file healix_ai-0.1.0.tar.gz.

File metadata

  • Download URL: healix_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for healix_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 44dac58af04a51073fee93f1f34b782ad3da6cf7148369db34ac7d4c9a62761f
MD5 775f7722ece4d8202feb1fba2bbdc68e
BLAKE2b-256 aa1ce24e94146940fc04d3eb9b5bc7fcd82ced9f0477d47c0408b7395b1ddb9b

See more details on using hashes here.

File details

Details for the file healix_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: healix_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for healix_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c94c7c6d45739a2610d51cd736c94bbfc6deb1c69bb56292a7af985058eb8f99
MD5 139b7368a91285916232ae3d1ff2276f
BLAKE2b-256 bcaf28d4b7339d457ba4be200735bc00332f104e3b3d8fa9d2abb12318faa5c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page