Detailed explanation of Appium framework: cross-platform mobile automation practice
You can automatically refresh short videos and regression test new App versions without touching the phone screen - Appium has become one of the mainstream tools for mobile automation with its unified cross-platform UI automation capabilities. With only one set of Python API, you can drive real devices or simulators of Android and iOS at the same time, without having to go through the native tool chains of UiAutomator and XCUITest respectively.
This article takes you through three steps from environment-setup → core tool class packaging → Douyin practice to get you started quickly. All codes are adapted to Python highlighting, and you can modify and run them by copying.
1. Set up a cross-platform basic environment in 5 minutes
Appium uses the classic client-server architecture:
- Server side: Based on the core transit layer of Node.js, it communicates with the device through the WebDriver protocol.
- Client library: Supports multiple languages such as Python/Java/JS. Developers only need to write business logic and call the unified API.
1.1 Common dependencies across all platforms
Whether you are working on Android or iOS, you need to install the following common core tools first:
1.2 One-click installation and platform supplement
Open a terminal or CMD and install common services and drivers in order:
- Android users: Install Android Studio (automatically manage SDK, ADB), and enable "USB debugging", "USB installation" and "Allow simulated locations (optional)" in developer mode on your phone.
- iOS users (macOS only): Install Xcode (automatically manage simulator/real device signature), execute
xcode-select --installInstall command line tools. :::
1.3 Verify whether the environment is running smoothly
Start the Appium server (default listeninghttp://127.0.0.1:4723):
When you see "Appium REST http interface listener started" appearing in the output, it means that the server started successfully!
2. Lightweight general tool class encapsulation
In order to avoid repeatedly configuring connections, explicit waiting, etc. every time we write a script, we first encapsulate an out-of-the-boxAppiumHelperkind.
2.1 Complete Python code
3. Douyin actual combat: simulate real user browsing
Based on the just packagedAppiumHelper, let’s implement a Douyin browsing script that can randomly like, randomly follow, and simulate real dwell time.
3.1 Obtain APP key information
First open the Douyin APP and obtain the package name and startup page through the ADB command:
Usually the output looks like:
- Package name:
com.ss.android.ugc.aweme - Startup page:
com.ss.android.ugc.aweme.splash.SplashActivity
3.2 Complete actual code
4. Summary and expansion
The core advantage of Appium lies in its cross-platform unified API and complete ecosystem. After getting started, you can continue to delve deeper into the following aspects:
- More precise positioning: Use Appium Inspector to directly grab UI elements and replace the alternate locator in the example.
- More complex gestures: Utilize
ActionChainImplement advanced operations such as long press, drag, and two-finger zoom. - Parallel Multiple Devices: Use Docker containers or Appium Grid to control multiple devices at the same time.
- Integration with testing framework: Integrate Pytest and Allure to generate professional UI automation test reports.
:::warning Compliance Tips When using automated scripts, please strictly abide by the user agreement and laws and regulations of the target platform. It is prohibited to use it for malicious brushing, batch crawling of private data and other violations.

