How dtmilano/androidviewclient works
Project type and purpose
• It is a command-line / library tool written in Python that automates Android UI testing.
• It provides:
– ADB-based device communication (adbclient module)
– UI Hierarchy capture & parsing (uiautomatorhelper + dumpsys)
– Logical “ViewClient” abstractions for interacting with on-screen elements
– Script generation (“culebra” scripts) and Robot Framework wrappers
– Concurrency support for multiple devices
File structure
• src/com/dtmilano/android – core Python packages:
– adb: low-level ADBClient, dumpsys, key-mapping
– uiautomator: UIAutomatorHelper wrapper for UIAutomator server
– viewclient: ViewClient Java/Python code that parses and manipulates UI trees
– robotframework: integration layer for Robot Framework
– Helper modules: controlpanel, plot, distance, concertina, kato
• tools/ and examples/ – CLI entry scripts & end-user examples
• setup.py / build.xml – packaging and publishing; defines console entrypoints
• docs/ / sphinx/ / uml/ – documentation and UML artifacts
• tests/ / tst/ – unit / integration tests, resource mocks
README for additional insights
• Confirms pure-Python design (>= Python 3.6)
• Highlights ADB usage, UI Automator Hierarchy vs. image-based comparison
• Mentions forthcoming Kotlin backend (out of scope here)
Main components and their relationships
┌─────────────────────────────────────────────────────────────────────────┐
│ 1. User / CLI layer │
│ • culebra, tools/ scripts, examples scripts → Python entrypoints │
├─────────────────────────────────────────────────────────────────────────┤
│ 2. Core-Library layer │
│ • adbclient module (spawns ADB subprocesses) │
│ • uiautomatorhelper (talks to on-device UIAutomator server) │
│ • viewclient (parses UI XML, presents tree API) │
│ • script-generation engine (culebra) │
│ • optional robotframework adapter │
├─────────────────────────────────────────────────────────────────────────┤
│ 3. External-Integration layer │
│ • Local ADB server / daemon │
│ • USB / TCP/IP → Android devices / emulators │
│ • On-device UIAutomator (Java) │
├─────────────────────────────────────────────────────────────────────────┤
│ 4. Persistence & CI │
│ • GitHub Actions workflows (pythonpublish.yml) │
│ • Packaging: PyPI (setup.py) / Ant (build.xml) │
└─────────────────────────────────────────────────────────────────────────┘
Relationships & interactions:
– CLI layer invokes functions in the Core-Library.
– Core-Library → spawns ADB subprocesses → communicates with ADB server.
– ADB server ↔ Android device/emulator.
– On-device UIAutomator service returns UI hierarchy → Core-Library.
– Core-Library processes hierarchy, issues input commands back via ADB.
– Script-generation engine writes reusable Python test scripts.
– RobotFramework adapter calls Core-Library APIs for keyword-driven tests.
Architectural patterns & design principles
• Modular layering: clear separation of CLI, core logic, and external integration
• Adapters: ADBClient adapter, UIAutomator helper adapter, RobotFramework adapter
• Factory / generator: “culebra” script/ code generator
• Concurrency: thread-pool or async support for multi-device operation
• Test coverage: heavy use of unit/integration tests under tests/ and tst/