Skip to main content

Core utilities for Laite RPA: ADB control, AI client, UI analysis, and test actions

Project description

fast2common

Core utilities for automated Android testing

A comprehensive toolkit for Android RPA (Robotic Process Automation) including ADB control, AI-powered UI analysis, and test case actions.

Features

🎯 Core Components

  • ADB Controller: Advanced Android Debug Bridge control
  • AI Client: Integration with ZhipuAI for intelligent analysis
  • Screenshot Analyzer: AI-powered UI element detection and analysis
  • UI Analyzer: Parse and analyze Android UI hierarchy
  • Animation Detector: Detect and wait for UI animations
  • Icon Locator: AI-based icon matching and localization
  • Coordinate Converter: Convert between coordinate systems
  • Element Locator: Find UI elements by various criteria

🚀 Test Actions (New!)

Extensible test case action framework:

  • Tap: Click on screen elements (supports AI-based element finding)
  • Swipe: Gesture-based swipe actions
  • Launch App: Start Android applications
  • Close App: Force-stop applications
  • Input: Input text into fields
  • Wait: Wait for specified duration
  • Press Back: Navigate back
  • Screenshot: Capture screen states

Installation

pip install fast2common

Development installation

git clone https://github.com/yourorg/fast2common.git
cd fast2common
pip install -e ".[dev]"

Quick Start

ADB Control

from fast2common.adb_controller import ADBController

# Initialize ADB controller
adb = ADBController(device_id="emulator-5554")

# Take screenshot
adb.screenshot("/path/to/screenshot.png")

# Get UI dump
ui_xml = adb.get_ui_dump()

# Click at coordinates
adb.click(100, 200)

Test Case Actions

from fast2common.actions import ActionExecutor, ActionContext
import asyncio

async def run_test():
    # Create execution context
    context = ActionContext(
        device_id="emulator-5554",
        package_name="com.example.app",
        main_activity=".MainActivity",
        task_id="test_001"
    )

    # Execute tap action
    result = await ActionExecutor.execute(
        action_type="tap",
        action_data={"x": 100, "y": 200},
        context=context
    )

    if result.success:
        print(f"✅ Success: {result.message}")
    else:
        print(f"❌ Error: {result.error}")

asyncio.run(run_test())

UI Analysis

from fast2common.screenshot_analyzer import ScreenshotAnalyzer

# Analyze screenshot for UI elements
analyzer = ScreenshotAnalyzer()
result = analyzer.analyze_screenshot(
    screenshot_path="screenshot.png",
    prompt="Find all clickable buttons"
)

# Get detected elements
for element in result.get("elements", []):
    print(f"Found: {element['label']} at {element['bounds']}")

Supported Action Types

Action Description Example
tap Click on screen {"x": 100, "y": 200}
swipe Swipe gesture {"start_x": 100, "start_y": 200, "end_x": 300, "end_y": 400}
launch_app Launch app {"package_name": "com.example.app", "main_activity": ".MainActivity"}
close_app Close app {"package_name": "com.example.app"}
input Input text {"text": "Hello World"}
wait Wait time {"duration": 2}
press_back Back button {}
screenshot Take screenshot {}

Extending Actions

Create custom actions easily:

from fast2common.actions.base import BaseAction, ActionContext, ActionResult
from fast2common.actions import ActionExecutor

class CustomAction(BaseAction):
    action_type = "custom_action"
    description = "My custom action"

    async def execute(self, action_data, context, send_log_callback=None):
        # Your implementation here
        return ActionResult(
            success=True,
            message="Action completed"
        )

# Register custom action
ActionExecutor.register_action("custom_action", CustomAction)

Requirements

  • Python 3.8+
  • Android SDK (for ADB)
  • ZhipuAI API key (for AI features)

Dependencies

zhipuai>=1.0.0
pillow>=9.0.0
aiohttp>=3.8.0

Documentation

Full documentation is available at https://fast2common.readthedocs.io

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

0.2.0 (2025-01-08)

  • ✨ Added extensible test case actions framework
  • ✨ Added ActionExecutor for unified action execution
  • ✨ Added 8 built-in action types (tap, swipe, launch_app, etc.)
  • 📝 Improved documentation
  • 🐛 Bug fixes

0.1.2 (2025-01-05)

  • Initial release
  • ADB controller
  • UI analysis tools
  • AI client integration

Support

Acknowledgments

  • ZhipuAI for AI analysis capabilities
  • Android Open Source Project
  • All contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fast2common-0.2.0.tar.gz (70.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fast2common-0.2.0-py3-none-any.whl (81.5 kB view details)

Uploaded Python 3

File details

Details for the file fast2common-0.2.0.tar.gz.

File metadata

  • Download URL: fast2common-0.2.0.tar.gz
  • Upload date:
  • Size: 70.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for fast2common-0.2.0.tar.gz
Algorithm Hash digest
SHA256 41deeacf3b29fa95612e6069de6bf6878eb272a9e9fd71f1f78ac506399f7312
MD5 eade2fb04c9c4fa45d80e426941c4940
BLAKE2b-256 847d5b5687c2b31b0aaa54315b09db2b2fe0ce8c98e6d439127faba1d3b61cea

See more details on using hashes here.

File details

Details for the file fast2common-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fast2common-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 81.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for fast2common-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbb1559aecec21c5e7916e1ca7d3e2d2bab40221d7a6d257e7ccf84502cf97da
MD5 17aa68ccce71789d167d1f80c252439d
BLAKE2b-256 a3c86ffef70f2232175b2b6720cd635fd84a2803af50688dbfef723343145da9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page