返回顶部
m

mobile-appium-test移动端Appium测试

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
557
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

mobile-appium-test

移动端Appium测试

使用Appium通过USB连接真实设备进行Android UI自动化测试。

前置条件

必需工具(必须安装):

  • - ADB(Android调试桥)- Android SDK的一部分
  • Appium服务器(推荐v2.x版本)
  • Appium Doctor(npm install -g @appium/doctor)

验证安装:
bash
adb version
appium --version
appium doctor

快速参考

设备连接

目标命令
列出已连接设备adb devices
获取设备信息
adb shell getprop ro.build.version.release | | 重启ADB服务器 | adb kill-server && adb start-server | | USB调试授权 | 检查手机上的授权提示 |

Appium服务器

目标命令
启动Appiumappium --address 127.0.0.1 --port 4723
以宽松安全模式启动
appium --relaxed-security | | 检查Appium状态 | curl http://127.0.0.1:4723/status |

常见Appium操作

目标端点/操作
启动会话POST /session 附带能力参数
查找元素
POST /session/{id}/element | | 点击元素 | POST /session/{id}/element/{id}/click | | 输入文本 | POST /session/{id}/element/{id}/value | | 截取屏幕截图 | GET /session/{id}/screenshot | | 获取页面源码 | GET /session/{id}/source | | 退出会话 | DELETE /session/{id} |

典型工作流程

1. 验证设备连接

bash adb devices

确保设备显示device状态(而非unauthorized或offline)。

2. 启动Appium服务器

bash appium --address 127.0.0.1 --port 4723 --relaxed-security

3. 运行测试

使用USB设备的期望能力参数: json { platformName: Android, deviceName: device, udid: <设备UDID>, app: /path/to/app.apk, automationName: UiAutomator2, noReset: true }

4. 常见测试场景

  • - 安装应用:adb install app.apk
  • 启动应用:Appium的appActivity能力参数
  • 按ID查找元素:findelement(id, com.example:id/button)
  • 按文本查找元素:findelement(xpath, //*[@text=Submit])
  • 滑动操作:Appium触摸操作
  • 获取日志:adb logcat

错误处理

错误原因解决方案
device not foundUSB连接问题检查adb devices,重启ADB服务器
unauthorized
USB调试未授权 | 解锁手机,授权计算机 | | no such element | 元素未找到 | 使用带等待的find_elements,检查页面源码 | | session not created | 能力参数不匹配 | 验证UDID、平台版本、应用路径 |

注意事项

  • - 对于真实设备测试,始终使用adb devices中的UDID
  • 使用UiAutomator2作为Android的自动化引擎
  • noReset: true可在会话之间保留应用状态
  • WiFi调试:adb tcpip 5555 然后 adb connect :5555

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 mobile-appium-test-1776295882 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 mobile-appium-test-1776295882 技能

通过命令行安装

skillhub install mobile-appium-test-1776295882

下载

⬇ 下载 mobile-appium-test v1.0.0(免费)

文件大小: 2.09 KB | 发布时间: 2026-4-16 18:39

v1.0.0 最新 2026-4-16 18:39
Initial release of mobile-appium-test.

- Provides a reference for automating UI tests on USB-connected Android devices using Appium.
- Includes device connection verification, app installation, UI element operations, test execution, screenshot capture, and log collection.
- Lists required tools (ADB and Appium Server) and basic installation checks.
- Details typical workflow, common Appium commands, and troubleshooting steps.
- Supports tests with custom capabilities and provides guidance for error handling.

Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com

p2p_official_large
返回顶部