The HTML5 <canvas> is used to display high quality graphics in web applications such as web games (i.e., <canvas> games). However, automatically testing <canvas> games is not possible with existing web testing techniques and tools, and manual testing is laborious. Many widely used web testing tools rely on the Document Object Model (DOM) to drive web test automation, but the contents of the <canvas> are not represented in the DOM. The main alternative approach, snapshot testing, involves comparing oracle snapshot images with test-time snapshot images using an image similarity metric to catch visual bugs, i.e., bugs in the graphics of the web application. However, creating and maintaining oracle snapshot images for <canvas> games is onerous, defeating the purpose of test automation. In this paper, we present a novel approach to automatically detect visual bugs in <canvas> games. By leveraging an internal representation of objects on the <canvas>, we decompose snapshot images into a set of object images, each of which is compared with a respective oracle asset (e.g., a sprite) using four similarity metrics: percentage overlap, mean squared error, structural similarity, and embedding similarity. We evaluate our approach by injecting 24 visual bugs into a custom <canvas> game, and find that our approach achieves an accuracy of 100%, compared to an accuracy of 44.6% with traditional snapshot testing.
翻译:HTML5<canvas> 用于在网络游戏(例如,<canvas> 游戏)等网络应用程序中显示高质量的图形。然而,以现有的网络测试技术和工具自动测试<canvas> 游戏是不可能的,人工测试也是很麻烦的。许多广泛使用的网络测试工具都依靠文档对象模型(DOM)来驱动网络测试自动化,但<canvas> 中的内容没有在 DOM 中体现。主要替代方法(快照测试)涉及将图像与测试-时间快照图像比较为测试-时间快照图像,同时使用类似图像的图像的图像相似度衡量标准来捕获视觉错误,即网络应用程序图形中的错误。然而,为 < canvas> 游戏创建和维护或显示快照的图像非常麻烦,无法达到测试自动化的目的。在本文中,我们提出了一个新颖的方法,通过在 < canvas > 上对对象进行内部表达式图像的表达方式,我们将快速图像图像的每个图像都与各自的或缩略图中的精确度相比较,通过相似的缩略图的缩略图比 。