Mobile Development 8 min read

Baidu Smart Mini Program Automation Testing Framework Architecture Analysis

The article explains how Baidu’s Smart Mini Program, which runs hybrid H5‑Native code in separate Logic and View threads within the Baidu app, cannot be tested with standard tools, so the Smart Mini Program Testing Platform created the smartapp‑automator framework that combines a Selenium‑like engine for in‑process UI control with a unified device‑control API abstracting Android, iOS, Chrome and cloud‑phone automation tools.

Baidu Geek Talk
Baidu Geek Talk
Baidu Geek Talk
Baidu Smart Mini Program Automation Testing Framework Architecture Analysis

Baidu Smart Mini Program is a hybrid technology combining H5 and Native, running on host apps like Baidu App and iQIYI. Due to its unique architecture, existing automation testing tools like Appium (for native apps) or Selenium (for H5) cannot be directly applied to test Baidu Smart Mini Programs.

To address this challenge, Baidu's Smart Mini Program Testing Platform team developed the smartapp-automator automation testing framework. This article provides an in-depth analysis of its architecture.

Smart Mini Program Architecture: When opening a mini program in Baidu App, the app creates a separate process containing one Logic thread and multiple View threads. All business logic runs in the Logic thread, while View threads handle page rendering. The Logic and View threads communicate bidirectionally through an eventBus provided by the swan SDK integrated in the host app.

smartapp-automator Architecture: The framework consists of two main parts: automation control of the mini program runtime and automation control of various device types.

Mini Program Automation Control: The framework implements a Smart Mini Program Testing Engine inspired by Selenium 1.0 and Chrome Debug Protocol. The engine contains four components: batEngineLogic (in the Logic thread), batEngineView (in the View thread), bat-agent (websocket server), and bat-driver (API layer). When debug mode is enabled, batEngineLogic and batEngineView are dynamically loaded into the mini program's threads. The three-layer bidirectional communication architecture enables features like UI test case recording and playback on real devices.

Device Automation Control: The framework provides a unified device control API that abstracts different automation tools for various device types: Android (ADB, Atx-Agent), iOS (WDA), Chrome/Chromium (Puppeteer), and cloud phones (bacagent). This allows users to control devices without worrying about underlying tool implementations.

mobile testingAppiumAutomation TestingSeleniumBaiduframework-architecturesmart mini program
Baidu Geek Talk
Written by

Baidu Geek Talk

Follow us to discover more Baidu tech insights.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.