Skip to main content

Android UI inspection and automation tool

Project description

Android View Scope

Modern Android UI element inspector, similar to weditor functionality, built with Vue.js 3 + FastAPI

Features

  • Modern Tech Stack - Vue.js 3 + Element Plus + FastAPI
  • Device Management - Auto-detect and manage Android devices
  • Real-time Screenshots - High-quality PNG screenshot capture
  • Interactive Element Selection - SVG interaction layer, click to select UI elements
  • UI Hierarchy Structure - Complete interface hierarchy tree display
  • Code Generation - Auto-generate uiautomator2 locator code
  • Multiple Locator Strategies - Resource-ID, text, XPath and other methods

Project Structure

viewscope/
├── frontend/          # Vue.js 3 前端项目
│   ├── src/
│   │   ├── views/     # 页面组件
│   │   ├── stores/    # 状态管理 (Pinia)
│   │   └── components/
│   ├── package.json
│   └── vite.config.js
├── backend/           # FastAPI 后端项目  
│   ├── main.py        # 应用入口
│   ├── core/          # 核心模块
│   │   ├── device_manager.py  # 设备管理
│   │   ├── ui_analyzer.py     # UI分析
│   │   └── code_generator.py  # 代码生成
│   ├── api/           # API路由
│   │   ├── devices.py
│   │   ├── screenshot.py
│   │   └── ...
│   └── requirements.txt
├── start.bat          # 一键启动脚本
└── README.md

Quick Start

One-Click Launch (Recommended)

Simply install via pip and run:

pip install ViewScope
viewscope

The command will automatically:

  1. Start backend API service (port 8060+)
  2. Launch web interface in browser

Manual Development Setup

Backend

cd backend
pip install -r requirements.txt
python main.py

Frontend

cd frontend
npm install
npm run dev

Prerequisites

System Requirements

  • Windows 10/11 / macOS / Linux
  • Python 3.8+
  • Android SDK (ADB available)

Device Requirements

  • Android 4.4+
  • USB debugging enabled
  • Device connected via ADB

Environment Verification

# Check Python
python --version

# Check ADB
adb version

# Check device connection
adb devices

Usage

  1. Launch Application

    • Run viewscope command
    • Browser opens automatically
  2. Connect Device

    • Select device from top toolbar
    • Click "Refresh Current View" button
  3. Element Selection

    • Click any UI element in screenshot
    • Element details show in right panel
  4. Code Generation

    • Switch to "Code Generation" tab
    • View auto-generated uiautomator2 code
    • Click "Copy Code" button
  5. UI Hierarchy View

    • Switch to "UI Hierarchy" tab
    • Browse complete interface tree structure
    • Use search to locate specific elements

API Documentation

After starting backend service, visit http://localhost:8060/docs for complete API documentation.

Main Endpoints

  • GET /api/devices - Get device list
  • POST /api/screenshot - Take screenshot and get UI structure
  • GET /api/ui-hierarchy - Get UI hierarchy structure
  • POST /api/code/generate - Generate locator code

Troubleshooting

Common Issues

  1. Device Not Detected

    # Check ADB connection
    adb devices
    # Restart ADB service
    adb kill-server
    adb start-server
    
  2. Screenshot Failed

    • Ensure device has authorized USB debugging
    • Check if device is locked
    • Try reconnecting device
  3. Frontend Cannot Access Backend

    • Check if backend started on port 8060
    • Confirm firewall settings
    • Check browser console errors
  4. Dependency Installation Failed

    # Python dependencies
    pip install -r requirements.txt -i https://pypi.douban.com/simple
    

Development

Tech Stack

  • Frontend: Vue.js 3, Element Plus, SVG, Pinia
  • Backend: FastAPI, uiautomator2, Pillow
  • Build Tools: Vite, Python uvicorn

Development Environment

# Backend hot reload
uvicorn main:app --reload --host 0.0.0.0 --port 8060

# Frontend hot reload
npm run dev

Build & Deploy

Frontend Build

cd frontend
npm run build

Package Distribution

pip install build twine
python -m build
twine upload dist/*

Contributing

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

License

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

Acknowledgments


For issues or suggestions, welcome to submit Issues or Pull Requests!

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

viewscope-1.1.3.tar.gz (461.8 kB view details)

Uploaded Source

Built Distribution

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

viewscope-1.1.3-py3-none-any.whl (469.6 kB view details)

Uploaded Python 3

File details

Details for the file viewscope-1.1.3.tar.gz.

File metadata

  • Download URL: viewscope-1.1.3.tar.gz
  • Upload date:
  • Size: 461.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for viewscope-1.1.3.tar.gz
Algorithm Hash digest
SHA256 03ffe844f82dfefb36a82dfe4c0ec87ad34283d606a0e46e6ad3585d69e2cf58
MD5 5c6452fa1eeb01c08264e02d64bba604
BLAKE2b-256 e4d5a95921d05077c4cc425982c0bdedb7b35023f611c14f824e60951f62f747

See more details on using hashes here.

File details

Details for the file viewscope-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: viewscope-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 469.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for viewscope-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2215063b6c5f3de004c7801fa53a7ee376bf557db0e004d05c6dc8173eb4b3
MD5 b2533376a2f5f4b56eb272a9eef5e11b
BLAKE2b-256 95ca3b5d0183aad26f85762489a5c77a87f0f7f72da956cd5e01480227e89e7b

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