Introduction
Web forms serve as the primary interface for user interaction in modern web applications, facilitating critical tasks such as authentication, profile management, and financial transactions. Ensuring the robustness of these forms is paramount; however, automated testing remains a significant challenge due to the need for deep contextual awareness. Traditional automation tools often struggle to distinguish between semantically different input fields (e.g., a username vs. a credit card number) based solely on HTML tags.
This empirical study investigates the potential of Large Language Models (LLMs) to bridge this gap. By evaluating 11 different LLMs across 146 diverse web forms, the researchers aimed to identify the most effective models and strategies for generating valid, submittable test cases.
Methodology: The Five-Step Framework
The researchers proposed a systematic approach to transform raw web forms into executable test scripts. This process involves five distinct stages designed to optimize the information provided to the LLM while minimizing "noise" that could lead to token limit exhaustion or hallucinations.
- HTML Pruning: An algorithm strips non-essential attributes (e.g.,
class,data-id) while preserving critical semantic markers likeid,name,type, andplaceholder. - Context Construction: The study compared three methods for data representation: Raw HTML (RH-P), LLM-Processed JSON (LH-P), and Parser-Processed JSON (PH-P). The PH-P method, utilizing a deterministic Java-based parser (Jsoup), proved most effective by providing a structured, error-free representation.
- Prompt Design: A multi-faceted prompt structure was employed, including Global, Task, Note, Instruction, and Objective components to guide the LLM's output.
- LLM Communication: The constructed context and prompts were sent to various LLMs to generate test data.
- Test Insertion: The generated values were automatically inserted into the target web forms.
Execution and Evaluation
To validate the generated tests, the study utilized a real-world execution environment. As shown in Figure 2, an automated test script interacts with a Web Driver, which in turn manages a real browser instance to execute the web-form tests and evaluate the results.
The evaluation spanned 146 web forms from 30 open-source Java applications, categorized into functional types such as authentication, content management, and transactions. In total, 14,454 individual tests were generated and executed to ensure statistical robustness.
Key Findings
The empirical results highlighted a significant performance gap between leading models and their competitors:
- GPT-4 Dominance: GPT-4 emerged as the clear leader, achieving a Successfully-Submitted Rate (SSR) of 99.54% when paired with the PH-P strategy.
- Structure is Key: The Parser-Processed (PH-P) strategy (70.63% average SSR) significantly outperformed Raw HTML (60.21%) and LLM-processed HTML (50.27%). This underscores the importance of providing LLMs with deterministic, structured data rather than raw code.
- Logical vs. Visual Reasoning: Interestingly, vision-optimized models like GLM-4V failed entirely. This suggests that web-form testing is primarily a task of structural logic and semantic understanding rather than visual pattern recognition.
Conclusion and Future Directions
While LLMs, particularly GPT-4, show immense promise for automating web-form testing, challenges remain regarding data privacy and the handling of highly dynamic content (e.g., React-based forms). Future research should focus on fine-tuning open-source models to ensure data security and expanding the scope to include "negative testing"—generating invalid inputs to probe for security vulnerabilities and error-handling flaws.
Summary updated