Research on Test Case and Script Generation for Web Applications Based on Large Language Models
摘要
随着软件系统复杂度的不断提升,传统测试用例生成方法主要依赖人工编写,存在效率低、覆盖不全、难以适应快速迭代等问题.大语言模型为自动化测试生成提供了新的可能,但其在真实场景下的有效性、稳定性与实用性尚未得到系统评估.本文针对该问题,选取 ChatGPT、DeepSeek 和豆包 3 种主流大语言模型,结合Selenium与 Python构建自动化测试框架,在 139 邮箱、189 邮箱、穷游网及马蜂窝等典型 Web应用上开展实验.通过自动提取 UI 元素、生成测试数据与脚本,并结合人工审查与多维指标评估,系统分析各模型在测试数据有效性、脚本准确性、用例覆盖度与缺陷发现等方面的表现.实验结果表明,不同模型在测试生成中具有明显的能力分化:豆包在用例生成效率与中文场景通过率方面表现最优,ChatGPT 在复杂逻辑与边界场景覆盖上更具优势,DeepSeek 则在脚本代码质量与结构规范性上领先.研究进一步提出多模型协同与迭代优化策略,有效提升了生成脚本的可用性与场景适应性.本工作不仅验证了大语言模型在提升测试效率与覆盖范围方面的潜力,也揭示了其在输出一致性、复杂交互理解等方面的局限,为LLM(large language models)在软件测试中的实用化提供了实验依据与优化路径.
With the increasing complexity of software systems,traditional test case generation methods predominantly rely on manual creation,which suffers from inefficiency,insufficient coverage,and challenges in keeping pace with rapid iterations.Large language models(LLMs)offer new potential for automated test generation;however,their effectiveness,stability,and practicality in real-world scenarios have not yet been systematically evaluated.To address this issue,this study selects three mainstream LLMs—ChatGPT,DeepSeek,and Doubao—and constructs an automated testing framework using Selenium and Python.Experiments are conducted on typical web applications including 139 Mail,189 Mail,Qyer,and Mafengwo.By automatically extracting UI elements,generating test data and scripts,and incorporating manual review with multi-dimensional metrics,the performance of each model is systematically analyzed in terms of test data validity,script accuracy,test case coverage,and defect detection capability.Experimental results indicate distinct capability differentiations among the models in test generation:Doubao performs best in terms of generation efficiency and pass rate in Chinese scenarios,ChatGPT demonstrates greater advantages in covering complex logic and edge cases,while DeepSeek leads in script code quality and structural standardization.Furthermore,this research proposes a multi-model collaboration and iterative optimization strategy,which effectively enhances the usability and scenario adaptability of generated scripts.This work not only validates the potential of LLMs in improving testing efficiency and coverage but also reveals limitations such as output inconsistency and inadequate understanding of complex interactions,providing experimental evidence and optimization pathways for the practical application of LLMs in software testing.