Autonomous QA Agent: A Retrieval-Augmented Framework for Reliable Selenium Script Generation
Dudekula Kasim Vali
TL;DR
This work targets the semantic gap between natural language QA requirements and executable Selenium scripts by grounding generation in a Retrieval-Augmented Generation (RAG) framework. It ingests diverse materials (Markdown, PDF, HTML) into a vector store and retrieves both textual requirements and HTML DOM context to condition script generation, dramatically reducing UI element selector hallucinations. On 20 e-commerce test scenarios, the approach achieves $100 ext{%}$ syntax validity and $90 ext{%}$ execution success, outperforming a standard LLM baseline (syntax $95 ext{%}$, execution $30 ext{%}$) with statistically significant gains ($p<0.001$). The study demonstrates that context grounding in DOM structure and documentation can substantially improve automated UI testing, offering a scalable path toward self-writing, self-healing test suites while acknowledging limitations related to dynamic pages and domain generalization.
Abstract
Software testing is critical in the software development lifecycle, yet translating requirements into executable test scripts remains manual and error-prone. While Large Language Models (LLMs) can generate code, they often hallucinate non-existent UI elements. We present the Autonomous QA Agent, a Retrieval-Augmented Generation (RAG) system that grounds Selenium script generation in project-specific documentation and HTML structure. By ingesting diverse formats (Markdown, PDF, HTML) into a vector database, our system retrieves relevant context before generation. Evaluation on 20 e-commerce test scenarios shows our RAG approach achieves 100% (20/20) syntax validity and 90% (18/20, 95% CI: [85%, 95%], p < 0.001) execution success, compared to 30% for standard LLM generation. While our evaluation is limited to a single domain, our method significantly reduces hallucinations by grounding generation in actual DOM structure, demonstrating RAG's potential for automated UI testing.
