一句话:提出标签文本筛选技术LTS,大幅加速GUI测试中基于OCR的控件定位。
基于OCR的GUI控件定位在测试自动化中常因OCR算法缓慢而难以使用,尤其在无GPU环境下。本文首先归纳出GUI测试中常见的待定位控件文本类型——标签文本,即按钮、菜单项和窗口标题等控件中的短文本;随后分析GUI屏幕文本特征,提出与GPU无关的标签文本筛选技术LTS。该技术打开OCR引擎黑箱,组合使用简单方法尽量避免对屏幕进行过度文本分析。实验表明,在目标数据集上LTS大幅降低平均定位时间:在4K分辨率GUI屏幕和普通笔记本无GPU条件下,约60%以上案例的定位时间低于0.5秒;而基于Tesseract、PaddleOCR和EasyOCR的现有CPU方法通常需超过2秒,即使使用GPU也难保持在1秒内。
Optical character recognition (OCR) algorithms often run slow. They may take several seconds to recognize the texts on a GUI screen, which makes OCR-based widget localization in test automation unfriendly for use, especially on GPU-free computers. This paper first concludes a common type of widget text to be located in GUI testing: label text, which are short texts in widgets like buttons, menu items, and window titles. We then investigate the characteristics of texts on a GUI screen and introduce a fast GPU-independent Label Text Screening (LTS) technique to accelerate the OCR process for label text localization. The technique opens the black box of OCR engines and uses a combination of simple methods to avoid excessive text analysis on a screen as much as possible. Experiments show that, on the subject datasets, LTS reduces the average OCR-based label text localization time to a large extent. On 4k resolution GUI screens, it keeps the localization time below 0.5 seconds for over about 60% of cases without GPU support on a normal laptop computer. In contrast, the existing CPU-based approaches built on popular OCR engines Tesseract, PaddleOCR, and EasyOCR usually need over 2 seconds to achieve the same goal on the same platform. Even with GPU acceleration, they can hardly keep the analysis time in 1 second. We believe the proposed approach would be helpful for implementing OCR-based test automation tools.