Skip to content

Ciaran11221/ai-test-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Test Agent

An AI-powered test automation agent built with LangGraph, Playwright, and Google Gemini 1.5 Flash.

Give it a URL and a plain-English goal. It plans the steps, drives a real browser, observes what it finds, and generates a ready-to-run pytest file — autonomously. Completely free to run.


Demo (for employers — no setup required)

  1. Unzip the AI-Test-Agent folder
  2. Double-click AI-Test-Agent.exe
  3. Paste your free Gemini API key (get one free at aistudio.google.com — no credit card)
  4. Hit Run Agent — the pre-filled SauceDemo login example works immediately

The browser window is shown by default so you can watch the agent work in real time.


How it works

User: "Test the login flow with valid and invalid credentials"
             ↓
     ┌───────────────────────────────────────────┐
     │           LangGraph StateGraph            │
     │                                           │
     │  plan ──► execute ──► execute ──► ...     │
     │               ↑           │               │
     │               └───────────┘               │
     │                     ↓                     │
     │               generate                    │
     └───────────────────────────────────────────┘
             ↓
     test_login.py  (complete pytest + Playwright file)
Node What it does
plan Gemini breaks the goal into 4–6 ordered test steps
execute Gemini reads the page, picks a browser action, Playwright runs it
generate Gemini writes a complete pytest + Playwright test file from observations

Tech stack

Tool Purpose
LangGraph Stateful multi-step agent graph
LangChain LLM abstraction layer
Gemini 1.5 Flash Free AI reasoning (15 req/min, no credit card)
Playwright Real browser automation
pytest Generated test runner
CustomTkinter Modern dark-mode GUI
PyInstaller Windows EXE packaging

Getting a free Gemini API key

  1. Go to aistudio.google.com
  2. Sign in with a Google account
  3. Click Get API KeyCreate API Key
  4. Copy and paste it into the app

Free tier: 15 requests/minute, 1 million tokens/day. More than enough.


Building the EXE yourself

# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/ai-test-agent.git
cd ai-test-agent

# 2. Create a virtual environment
python -m venv venv
venv\Scripts\activate

# 3. Run the build script
build.bat

Running in development

pip install -r requirements.txt
playwright install chromium
python main.py

Optional: store your API key as an environment variable

The app auto-reads GEMINI_API_KEY from your environment so you never have to paste it manually:

# Run once in PowerShell as admin
[System.Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "your-key-here", "Machine")

Project structure

ai-test-agent/
├── main.py          # CustomTkinter GUI and entry point
├── agent.py         # LangGraph graph: plan → execute → generate
├── browser.py       # Playwright wrapper (the agent's hands)
├── requirements.txt
├── build.bat        # One-click Windows EXE builder
├── .gitignore       # Keeps secrets and build output off GitHub
└── README.md

Related project

Generated pytest files are compatible with the test-automation framework.

About

AI agent that autonomously plans, executes, and generates Playwright pytest test files from a plain-English goal — built with LangGraph, Playwright, and Gemini.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors