AI-assisted workflow for exploring websites, designing tests, generating Playwright code, and running tests from a Streamlit chat UI.
- Explore: Playwright crawls the target URL, parses DOM with BeautifulSoup, and gathers interactive elements plus inferred flows (login, contact, cart, etc.).
- Plan: LLM proposes structured JSON test plans from exploration data.
- Refine plan: Natural-language edits (add/remove/change tests) before code generation.
- Generate code: Single-file Python tests using Playwright + pytest +
expect(). - Run: Executes generated scripts with streamed stdout; saves logs and optional recordings under
evidence/. - Observability: Sidebar shows estimated tokens, call counts, last latency, and phase durations.
Python, Streamlit, Playwright, LangChain (Groq / Ollama / Gemini), BeautifulSoup, pandas, pytest.
- Python 3.10+ recommended
- Playwright Chromium installed
cd gen-ai
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS / Linux
pip install -r requirements.txt
playwright install chromiumCreate a .env file (same folder as app.py):
# Provider: google | ollama | groq
LLM_PROVIDER=google
# Google Gemini
GOOGLE_API_KEY=your_key
GEMINI_MODEL=gemini-2.0-flash
# Ollama (local)
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=deepseek-coder
# Groq
GROQ_API_KEY=your_key
GROQ_MODEL=llama-3.3-70b-versatilestreamlit run app.pySet Target URL in the sidebar, then use the chat, for example:
ExplorePlan- Optional:
Add a test for …/Remove TC… Generate CodeRun- On failure:
Fix Errorsor describe changes (Change locator …)
gen-ai/
├── app.py # Streamlit UI and command routing
├── modules/
│ ├── explorer.py # Site crawl + element extraction
│ ├── generator.py # Plan/code generation + refine/update
│ ├── verifier.py # Run script, stream logs, evidence
│ └── llm.py # LLM wrapper + setup_llm()
├── evidence/ # Logs / recordings (created at runtime)
├── requirements.txt
└── README.md
- Free-tier LLMs: Configure Gemini free tier, Groq free tier, or local Ollama per course constraints.
- Generated tests open a visible browser by default (
headless=False); verifier patches code when needed. - For large sites, exploration truncates elements per page (see
explorer.py).
Academic / course use unless otherwise specified.