Design and Implementation of a Cross‑Platform Mobile UI Automation Framework at QuNar
This article describes the background, challenges, and solution design for building a cross‑platform mobile UI automation framework at QuNar, covering test classification, element locating strategies, the POCO library, Page Object Model, JSON mock handling, and continuous integration with Jenkins to improve testing efficiency and reduce manual effort.
QuNar's mobile application development team faced a severe regression testing workload due to rapid iteration cycles, with hundreds of smoke test cases and thousands of monthly regression cases, leading to high manual effort, risk of missed bugs, and duplicated work.
To address these pain points, the project aimed to create a WYSIWYG script recording solution that allows non‑programmers to generate automation scripts through normal user interactions, thereby reducing maintenance costs and improving test coverage across multiple device types.
The solution selection began with a classification of testing purposes (functional, performance, stress, compatibility, security, etc.) and testing stages (unit, integration, system, regression, acceptance). It highlighted the evolution of automation testing from early white‑box unit tests to modern black‑box UI testing tools.
Given the mobile‑first trend and the need for cross‑platform support, the team evaluated existing frameworks such as UiAutomator, Robotium, and iOS Instrument, concluding that Appium offered the best balance of language flexibility, C/S architecture, and multi‑platform compatibility.
The framework architecture combines TARS, Jenkins, and STF to form a control layer, device layer, and application layer. Test cases are recorded via UI element recognition, image OCR, and mock data injection, then executed on a device farm, with results diffed against expected responses and screenshots.
Three primary element locating methods were compared: XPath (flexible but layout‑sensitive), identifier‑based locating (stable but requires added IDs), and image‑based recognition (human‑like but resolution‑dependent). The POCO library was introduced to encapsulate these methods, providing a unified Python API for element attributes, relative positioning, regex matching, and interaction control.
POCO, an open‑source cross‑platform UI automation framework built on Python, wraps underlying tools (e.g., WDA, UIAutomation) and supports element lookup, interaction, and extensibility such as OCR integration.
To keep test scripts maintainable, the Page Object Model (POM) design pattern was adopted, separating page element definitions from business logic, exposing only public methods, avoiding assertions inside page objects, and allowing method chaining across pages.
A JSON mock solution was implemented to handle unstable online data by intercepting API responses, applying configurable transformations (e.g., removing pop‑ups, modifying passenger data), and returning the mocked payload to the app, ensuring reliable test execution.
Continuous integration was realized with Jenkins, automating the build‑test‑report cycle: building the latest beta, deploying to devices, configuring environments, executing test suites (smoke, regression, performance, compatibility), and publishing results. Daily runs provide online health checks.
In practice, the system processed over 200 test executions per month, saved approximately 370 person‑days of manual effort, detected critical bugs, and demonstrated significant efficiency gains across QuNar's mobile testing workflow.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.