🤖 Intelligent Android Automation Pipeline

Leveraging Computer Vision and Large Language Models for GUI Testing


📋 1. Problem Statement

With the explosive growth of mobile Internet and smart devices, user interfaces (GUIs) are becoming increasingly complex and evolving at a rapid pace, driving up the demand for high-quality application assurance. To reduce the cost of manual testing, automated GUI testing has become a mainstream approach, especially for regression and compatibility testing whenever requirements change or versions are updated.

While extensive research has applied LLMs and MLLMs to GUI automation, most work has focused primarily on UI element localization. However, real-world business scenarios involve numerous dynamic interference factors and strong domain-specific contexts, which often result in lower success rates for these methods.

🔍 Consistency Verification Challenge

How can we establish robust consistency between text and single-image/multi-image sequences/videos in UI scenarios? And if inconsistencies are found, how should we get the steps back to the correct page?


🎯 2. Project Overview

We developed an intelligent Android automation pipeline that leverages computer vision and large language models to understand and interact with mobile application interfaces. The system "sees" screens like a human would, making intelligent decisions about interactions (tap, type, swipe) based on visual understanding rather than predefined element mappings.

🚀 Key Capabilities:

  • 👁️ Visual screen understanding and element recognition
  • 🗣️ Natural language task interpretation and execution
  • 🔄 Multi-step workflow automation (e.g., "install TikTok from Play Store")
  • 🔧 Dynamic adaptation to interface changes
  • 📍 Coordinate extrapolation for unmarked UI elements

🏗️ System Architecture

🎭 Supervisor-Worker Pattern

The pipeline implements a distributed architecture with clearly separated responsibilities:

graph TD
    A[📱 Mobile App Interface] --> B[🎯 Supervisor Agent]
    B --> C[⚡ Worker Agent]
    C --> D[🎼 Orchestrator]
    D --> B
    C --> E[📸 Screenshot Analysis]
    E --> F[🔧 Tool Selection]
    F --> G[📱 ADB Execution]
    G --> A

    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style C fill:#e8f5e8
    style D fill:#fff3e0

🎯 Supervisor Agent

This Agent acts as:

  • Strategic Planner: Breaking complex tasks into atomic steps (e.g., "Open Play Store → Search → Install") for the Worker Agent to execute
  • Progress Monitor: Validation of Worker Agent executions through screenshot analysis and provides correction guidance

⚡ Worker Agent

This agent handles the tactical execution of the atomic steps defined by the Supervisor Agent using two-stage processing:

Stage 1: Vision Analysis Stage - Uses GPT-4 vision capabilities to understand current screen state

Stage 2: Execution Stage - Decides on the best tool to use. Tool includes Android Debug Bridge (ADB) function such as going to the next page, taking a screenshot to custom UI testing tools such as the Check_element_present custom tool that the worker agent can use to check if a UI element is present.

🎼 Orchestrator

This agent coordinates the flow management between agents through:

  • ⏱️ Timeout handling and progress tracking
  • 🔄 Communication coordination and state management

👁️ Vision Analysis Pipeline

The workflow of the vision analysis pipeline is as follows:

flowchart LR
    A[📸 Screenshot] --> B[🔍 Element Detection<br/>OmniParser]
    B --> C[📍 Coordinate Mapping<br/>Numerical IDs]
    C --> D[🧠 Context Analysis<br/>VLM Processing]
    D --> E[⚡ Structured Decision Making]

    subgraph E [⚡ Structured Decision Making]
        E1[👀 Observe Screen State]
        E2[🤔 Reason Tool Choices]
        E3[🎯 Select Relevant Tool]
        E4[🔮 Predict Outcome]
        E1 --> E2 --> E3 --> E4
    end

    style A fill:#e3f2fd
    style B fill:#f1f8e9
    style C fill:#fce4ec
    style D fill:#fff8e1
    style E fill:#f3e5f5

Stage 1: Element Detection - OmniParser processes screenshots to identify clickable elements

Stage 2: Coordinate Mapping - The detected clickable elements are assigned numerical IDs with precise coordinates

Stage 3: Context Analysis - The Vision Language model (VLM) receives elements, coordinates, and the current task context

Stage 4: Structured Decision Making - The VLM then performs the following structured analysis:

  • 👀 Observe current screen state
  • 🤔 Reasons on the choice of tools available
  • 🎯 Selects the most relevant tool to use
  • 🔮 Prediction of the expected outcome

🛠️ Agentic Tools

Below are some example tools we implemented for UI testing in our project. In theory, we could implement more sophisticated tools and provide them to the LLM Agent to call during the autonomous UI exploration, allowing for automatic UI testing.

1. 🔍 Check_element_present

  • Description: The function takes a screenshot and passes the query string which contains instructions on the specific element to check for into a VLM

2. 🎨 Check_element_color

  • Description: The function takes a screenshot and passes the query string which contains instructions on the specific element to check for into a VLM

3. 📐 Check_element_alignment

  • Description: Checks the alignment of elements by overlaying a grid on the screenshot. This method enhances the visibility of misaligned icons and works particularly well as a form of VLM (Visual Layout Mapping) for better analysis

💡 Core Innovation: Coordinate Extrapolation System

Traditional automation fails when UI detection tools (e.g. Omniparser) misses elements. Our breakthrough solution to detect unmarked elements leverages on the VLM spatial reasoning ability and the absolute coordinates of detected elements (e.g., "Element 5 (Google logo) at position (352, 234)") to generate spatial instructions (e.g., "tap 200 pixels below element 5").

graph LR
    A[🔍 Detected Elements<br/>Element 5: (352, 234)] --> B[🧠 VLM Spatial Reasoning]
    B --> C[📝 Spatial Instructions<br/>"tap 200px below element 5"]
    C --> D[📍 extrapolate_coordinate()]
    D --> E[🎯 Precise Coordinates<br/>(352, 434)]

    style A fill:#e8f5e8
    style B fill:#e3f2fd
    style C fill:#fff3e0
    style D fill:#fce4ec
    style E fill:#f1f8e9

The extrapolate_coordinate() function then converts the spatial instructions to precise coordinates, supporting various formats such as:

  • 📏 Pixel offsets from detected elements
  • 📊 Percentage-based screen positions
  • Midpoint calculations between elements
  • 🎯 Absolute coordinate positioning

💻 Development Tools and Technologies

🔧 Core Development Tools

  • 🐍 Python: Primary programming language for pipeline development
  • 🤖 Android Debug Bridge (ADB): Native Android device communication and control

📚 Core Libraries

  • 🤗 transformers: Hugging Face transformer models integration
  • 🔗 langchain: LLM application framework for chaining operations
  • 📊 langgraph: Graph-based workflow orchestration
  • 🔤 sentence-transformers: Semantic text understanding and embedding
  • ⚡ vLLM: High-performance LLM inference optimization
  • 🗃️ Neo4j: Graph database for workflow state management

🌐 APIs and External Services

  • 🧠 OpenAI GPT-4o: Advanced vision-language model for screen understanding and decision making

📦 Project Assets and Resources

  • 📂 AppAgentX GitHub Repository: Reference implementation and methodology framework
  • 🔍 OmniparserV2: Locally hosted UI element detection and parsing model
  • 👁️ Qwen2.5-VL-7B: Locally hosted vision-language model via vLLM for improved latency and privacy

This technical documentation outlines the comprehensive approach to intelligent Android automation using advanced AI and computer vision technologies.

Built With

  • android-debug-bridge
  • appagentx-github-repo
  • langchain
  • langgraph
  • neo4j
  • ominiparser
  • openai-gpt-4o
  • python
  • qwen-vl
  • sentence-transformers
  • transformers
  • vllm
Share this project:

Updates