Mobile Development 6 min read

UI Automation Element Locating for Android and iOS Using WEditor and Appium

This guide explains how to set up and use WEditor for Android and tidevice/Appium for iOS to locate UI elements efficiently, covering prerequisite tools, installation commands, step‑by‑step connection procedures, error handling, and best‑practice strategies for reliable mobile UI automation.

转转QA
转转QA
转转QA
UI Automation Element Locating for Android and iOS Using WEditor and Appium

To perform UI automation testing, accurate element locating is essential. This article outlines practical methods for Android and iOS, summarizing tools, setup steps, and key insights gained from real‑world automation projects.

Android Element Locating

Prerequisites: adb, Python 3, an Android device with developer options enabled.

Tool: WEditor (cross‑platform).

Installation:

pip install weditor

Connect the Android device (enable USB debugging) and verify with:

adb devices

Start WEditor:

python -m weditor

In the WEditor UI, select Android, enter the device ID obtained from adb devices , and click connect . Install the prompted app on the device.

Open the target app, click Dump Hierarchy to capture the UI tree; refresh to capture new pages as needed.

If the error atx-agent recover failed occurs, run:

pip install --upgrade --pre uiautomator2

iOS Element Locating

Prerequisites: Python 3, an iPhone with WebDriverAgent installed.

Tools: tidevice, Appium 1.21.0+

Installation:

pip install tidevice

Check installed apps and obtain the bundle ID:

tidevice applist

List connected iOS devices to get the UDID:

tidevice list

Start WebDriverAgent:

tidevice -u <UDID> wdaproxy -B <WDA package> -p 8200

Launch Appium server (version 1.20.2 or later) and create a new session using a JSON representation, for example:

{
    "deviceName": "xxxx",
    "bundleId": "xxxxx",
    "platformVersion": "14.4",
    "udid": "000080xxxxxxxxxxxE",
    "webDriverAgentUrl": "http://localhost:8200",
    "platformName": "IOS",
    "xcodeOrgId": "xxxxxx",
    "automationName": "XCUITest",
    "usePrebuiltWDA": true,
    "useXctestrunFile": false,
    "skipLogCapture": true
}

After the session starts, you can begin capturing elements.

Key Takeaways

Simplicity: Prefer straightforward locating strategies:

Android: id > text > img > ocr > xpath
iOS: name > text > img > ocr > xpath
Web/H5: name > id > text > selector

Network Latency: Use framework methods like finds with timeout and interval scanning, and element_is_existed to return True or False based on element presence.

Fuzzy Matching: When text varies across versions, apply fuzzy matching on partial text to improve robustness.

Summary

Element locating is the foundation of UI automation; without reliable locators, actions cannot be performed.

The choice of locating strategy impacts test efficiency, stability, and coverage.

Tools like WEditor and Appium Inspector assist in discovering locator attributes but are not the solution themselves.

Understanding widget characteristics, implementation details, and layout principles is essential for effective element locating.

iOSAndroidUI AutomationMobile TestingappiumElement Locating
转转QA
Written by

转转QA

In the era of knowledge sharing, discover 转转QA from a new perspective.

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.