Skip to content

ArpitK24/BugFlow

Repository files navigation

🤖 Autonomous QA Agent

An AI-powered autonomous testing tool that uses Playwright, LangGraph, and Google's Gemini models to navigate and verify web applications just like a human tester.


🎯 Project Purpose

Traditional QA automation is brittle and requires constant maintenance when UI changes. The Autonomous QA Agent solves this by using Generative AI to:

  • Understand Goals: Not just selectors. You give it a high-level goal (e.g., "Verify the login fails with wrong credentials"), and it figures out how to do it.
  • Self-Correct: If an action fails or the page state changes unexpectedly, the agent re-plans its next step.
  • Visual Verification: Uses Gemini Vision to "look" at the page and confirm if an action had the intended effect or if the goal was achieved.

🚀 How It Works

The agent runs on a state machine built with LangGraph. Every cycle involves three main stages:

  1. Planning: The agent analyzes its history and the current page to decide the next best action.
  2. Execution: It uses Playwright to interact with the browser (click, fill, navigate, etc.).
  3. Verification: It captures "before" and "after" screenshots and uses Gemini Vision to verify the success of the action and check if the overall goal is met.

Visual Workflow

graph TD
    Start((Start)) --> Planner[Planner Node]
    Planner -->|Next Action| Executor[Executor Node]
    Executor -->|Action Result| Verifier[Verifier Node]
    Verifier -->|Goal Met| End((END))
    Verifier -->|Goal Not Met| Planner
Loading

📂 Project Structure

Directory/File Description
app/agent/ Core logic: nodes.py (logic), graph.py (flow), state.py (memory).
app/tools/ Browser capabilities: navigation.py, observation.py, wait.py.
app/core/ Infrastructure: config.py (env), database.py (SQLAlchemy/SQLite).
app/models/ Database schema: db.py (TestRuns and TestSteps).
app/main.py FastAPI entry point and API endpoints.
screenshots/ Storage for visual proof captured during test runs.

🛠️ Installation & Setup

Prerequisites

  • Python 3.10+
  • A Google Gemini API Key

Step 1: Clone & Install Dependencies

# Clone the repository
git clone https://github.com/ArpitK24/Autonomus-Agent-Agentic-workflow-.git

# Install Python packages
pip install fastapi uvicorn playwright langchain langgraph langchain-google-genai sqlalchemy aiosqlite python-dotenv google-generativeai

# Install Playwright browser
python -m playwright install chromium

Step 2: Configure Environment

Create a .env file in the root directory:

GEMINI_API_KEY=your_gemini_api_key_here
HEADLESS=False

🏃 Launching the Agent

1. Start the API Server

# Set PYTHONPATH to root and run uvicorn
$env:PYTHONPATH="."; python -m uvicorn app.main:app --port 8000 --host 0.0.0.0

2. Trigger a Test Run

Send a POST request to /api/v1/run-test:

{
  "url": "https://www.google.com",
  "goal": "Verify the search bar is present and accessible"
}

📊 Monitoring Results

  • Console: Live updates of the agent's thoughts and actions.
  • Database: Check qa_agent.db for a full history of runs and steps.
  • Visuals: Review the screenshots/ folder for UUID-labeled images of every interaction.

⚖️ Built With

About

An AI tool that autonomously tests web applications by controlling a headless browser.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages