Web end-to-end (e2e) testing evaluates the workflow of a web application. It simulates real-world user scenarios to ensure the application flows behave as expected. However, web e2e tests are notorious for being flaky, i.e., the tests can produce inconsistent results despite no changes to the code. One common type of flakiness is caused by nondeterministic execution orders between the test code and the client-side code under test. In particular, UI-based flakiness emerges as a notably prevalent and challenging issue to fix because the test code has limited knowledge about the client-side code execution. In this paper, we propose WEFix, a technique that can automatically generate fix code for UI-based flakiness in web e2e testing. The core of our approach is to leverage browser UI changes to predict the client-side code execution and generate proper wait oracles. We evaluate the effectiveness and efficiency of WEFix against 122 web e2e flaky tests from seven popular real-world projects. Our results show that WEFix dramatically reduces the overhead (from 3.7$\times$ to 1.25$\times$) while achieving a high correctness (98%).
翻译:Web端到端(e2e)测试用于评估Web应用程序的工作流程。它模拟真实用户场景,确保应用程序流程按预期运行。然而,Web端到端测试因具有脆弱性(即测试在代码未变的情况下可能产生不一致结果)而著称。一种常见的脆弱性源于测试代码与被测客户端代码之间的非确定性执行顺序。其中,基于UI的脆弱性因其显著普遍性和修复困难性尤为突出,原因在于测试代码对客户端代码执行情况的了解有限。本文提出WEFix技术,该技术能够自动生成针对Web端到端测试中基于UI脆弱性的修复代码。本方法的核心在于利用浏览器UI变化预测客户端代码执行状态,并生成恰当的等待预言。我们使用来自七个真实世界流行项目的122个Web端到端脆弱测试对WEFix的有效性和效率进行评估。结果表明,WEFix在实现高正确率(98%)的同时,显著降低了开销(从3.7倍降至1.25倍)。