Skip to main content

基于AI的Web和Android自动化框架,支持自然语言驱动的UI操作

Project description

Midscene Python

Midscene Python 是一个基于 AI 的自动化框架,支持 Web 和 Android 平台的 UI 自动化操作。

概述

Midscene Python 提供全面的 UI 自动化能力,具有以下核心特性:

  • 自然语言驱动:使用自然语言描述自动化任务
  • 多平台支持:支持 Web(Selenium/Playwright)和 Android(ADB)
  • AI 模型集成:支持 GPT-4V、Qwen2.5-VL、Gemini 等多种视觉语言模型
  • 可视化调试:提供详细的执行报告和调试信息
  • 缓存机制:智能缓存提升执行效率

项目架构

midscene-python/
├── midscene/                    # 核心框架
│   ├── core/                    # 核心框架
│   │   ├── agent/              # Agent系统
│   │   ├── insight/            # AI推理引擎
│   │   ├── ai_model/           # AI模型集成
│   │   ├── yaml/               # YAML脚本执行器
│   │   └── types.py            # 核心类型定义
│   ├── web/                     # Web集成
│   │   ├── selenium/           # Selenium集成
│   │   ├── playwright/         # Playwright集成
│   │   └── bridge/             # Bridge模式
│   ├── android/                 # Android集成
│   │   ├── device.py           # 设备管理
│   │   └── agent.py            # Android Agent
│   ├── cli/                     # 命令行工具
│   ├── mcp/                     # MCP协议支持
│   ├── shared/                 # 共享工具
│   └── visualizer/             # 可视化报告
├── examples/                   # 示例代码
├── tests/                      # 测试用例
└── docs/                       # 文档

技术栈

  • Python 3.9+:核心运行环境
  • Pydantic:数据验证和序列化
  • Selenium/Playwright:Web 自动化
  • OpenCV/Pillow:图像处理
  • HTTPX/AIOHTTP:HTTP 客户端
  • Typer:CLI 框架
  • Loguru:日志记录

快速开始

安装

pip install midscene-python

基础用法

from midscene import Agent
from midscene.web import SeleniumWebPage

# 创建 Web Agent
with SeleniumWebPage.create() as page:
    agent = Agent(page)
    
    # 使用自然语言进行自动化操作
    await agent.ai_action("点击登录按钮")
    await agent.ai_action("输入用户名 'test@example.com'")
    await agent.ai_action("输入密码 'password123'")
    await agent.ai_action("点击提交按钮")
    
    # 数据提取
    user_info = await agent.ai_extract("提取用户个人信息")
    
    # 断言验证
    await agent.ai_assert("页面显示欢迎信息")

主要特性

🤖 AI 驱动的自动化

使用自然语言描述操作,AI 自动理解并执行:

await agent.ai_action("在搜索框中输入'Python教程'并搜索")

🔍 智能元素定位

支持多种定位策略,自动选择最优方案:

element = await agent.ai_locate("登录按钮")

📊 数据提取

从页面提取结构化数据:

products = await agent.ai_extract({
    "products": [
        {"name": "产品名称", "price": "价格", "rating": "评分"}
    ]
})

✅ 智能断言

AI 理解页面状态,进行智能断言:

await agent.ai_assert("用户已成功登录")

许可证

MIT License

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

midscene_python-0.1.1.tar.gz (79.0 kB view details)

Uploaded Source

Built Distribution

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

midscene_python-0.1.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file midscene_python-0.1.1.tar.gz.

File metadata

  • Download URL: midscene_python-0.1.1.tar.gz
  • Upload date:
  • Size: 79.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for midscene_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ae04db5ed56e1b67c116247bfec542e73ec8358cb988887b47fcbf2e3ea4dc5b
MD5 857969f3c4de5438114d30ee0815b666
BLAKE2b-256 f27a6d2fcf8baf5d75e6d035ba1cd58fbbae2891b5a18bc8a93c6447ed8743e1

See more details on using hashes here.

File details

Details for the file midscene_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for midscene_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac0c3990694284954ada2ea9f7139083091c68f4c5bc359021f6bb34353daf5f
MD5 07925b4f59f89372b14d6d34a7772c89
BLAKE2b-256 b0a7e034843feb1bcabe61f5e03cb81eb4d1f3bae723716f0a6aa4f4652b787a

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