模拟器验证技能Skill simulator-verify

模拟器验证技能用于自动化测试iOS应用,通过构建应用、在模拟器中运行、使用深度链接导航、UI交互和截图来验证应用的功能和视觉界面。关键词:iOS模拟器、自动化测试、应用验证、截图、深度链接、UI交互、视觉检查、测试构建。

测试 0 次安装 0 次浏览 更新于 3/15/2026

名称: 模拟器验证 描述: 通过构建、运行和在iOS模拟器中截图来验证实现。支持通过idb的深度链接和触摸交互。

模拟器验证技能

目的

构建应用,在模拟器中运行,导航到特定屏幕,交互UI,并截图进行视觉验证。

自动激活时机

  • 关键词:验证、截图、模拟器、测试构建、检查UI、视觉检查

先决条件

  • 安装idb:brew tap facebook/fb && brew install idb-companion && pip3 install fb-idb

快速命令

启动和构建

# 启动模拟器
xcrun simctl boot "iPhone 16" && open -a Simulator

# 构建(增量构建快速)
xcodebuild build -workspace Anytype.xcworkspace -scheme Anytype \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -derivedDataPath ./DerivedData

# 安装和启动
xcrun simctl install booted ./DerivedData/Build/Products/Debug-iphonesimulator/Anytype.app
xcrun simctl launch booted io.anytype.app

导航(深度链接)

xcrun simctl openurl booted "anytype://create-object-widget"
xcrun simctl openurl booted "anytype://object?objectId=xxx&spaceId=yyy"
xcrun simctl openurl booted "anytype://sharing-extension"
xcrun simctl openurl booted "anytype://membership?tier=1"

触摸交互(idb)

idb ui tap 200 400           # 在坐标处点击
idb ui swipe 200 600 200 200 # 向上滑动
idb ui text "Hello World"    # 输入文本
idb ui button HOME           # 按下主页按钮
idb ui describe-all          # 获取可访问性树(JSON)
idb ui describe-point 200 400 # 获取坐标处的元素

截图

xcrun simctl io booted screenshot /tmp/verify.png
# 然后使用Claude的Read工具读取 /tmp/verify.png

Anytype常量

常量
包ID io.anytype.app
应用路径 ./DerivedData/Build/Products/Debug-iphonesimulator/Anytype.app
工作空间 Anytype.xcworkspace
方案 Anytype

深度链接参考

URL方案

方案 构建
anytype:// 所有构建
dev-anytype:// 仅调试
prod-anytype:// 仅生产

可用路由

路由 URL 目的
创建对象 anytype://create-object-widget 从小部件创建新对象
分享扩展 anytype://sharing-extension 显示分享表
图库导入 anytype://main/import?type=1&source=2 从图库导入
空间邀请 anytype://invite?cid=<cid>&key=<key> 加入空间
打开对象 anytype://object?objectId=<id>&spaceId=<spaceId> 导航到对象
个人资料 anytype://hi?id=<id>&key=<key> 打开身份页面
会员资格 anytype://membership?tier=1 会员等级

命令参考

simctl命令(模拟器管理)

命令 描述
xcrun simctl list devices available 列出所有可用的模拟器及其UDID
xcrun simctl boot <UDID> 启动模拟器
xcrun simctl shutdown <UDID> 关闭模拟器
xcrun simctl install booted <app_path> 安装.app文件
xcrun simctl launch booted <bundle_id> 启动应用
xcrun simctl terminate booted <bundle_id> 关闭应用
xcrun simctl io booted screenshot <path> 捕获屏幕截图
xcrun simctl openurl booted <url> 打开深度链接

idb命令(UI交互)

命令 描述
idb ui tap X Y 在坐标处点击
idb ui swipe X1 Y1 X2 Y2 滑动手势
idb ui text "hello" 输入文本
idb ui button HOME 按下硬件按钮
idb ui describe-all 获取可访问性树(JSON)
idb ui describe-point X Y 获取点处的元素

工作流程

┌─────────────────────┐
│ 1. 构建            │  xcodebuild build ...
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 2. 启动和安装   │  simctl boot + install
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 3. 启动应用       │  simctl launch
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 4. 导航         │  深度链接或idb点击/滑动
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 5. 交互         │  idb点击/输入/滑动
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 6. 截图       │  simctl screenshot
└──────────┬──────────┘
           ▼
┌─────────────────────┐
│ 7. 分析          │  Claude读取图像
└─────────────────────┘

查找UI元素

选项A:可访问性树

idb ui describe-all > /tmp/ui-tree.json
# 解析JSON以查找元素坐标

选项B:截图+视觉

xcrun simctl io booted screenshot /tmp/screen.png
# Claude分析图像以识别元素位置

示例会话

# 1. 启动模拟器
xcrun simctl boot "iPhone 16"
open -a Simulator

# 2. 构建(如果已构建则跳过)
xcodebuild build -workspace Anytype.xcworkspace -scheme Anytype \
  -destination 'platform=iOS Simulator,name=iPhone 16' \
  -derivedDataPath ./DerivedData

# 3. 安装和启动
xcrun simctl install booted ./DerivedData/Build/Products/Debug-iphonesimulator/Anytype.app
xcrun simctl launch booted io.anytype.app

# 4. 导航到特定屏幕(深度链接)
xcrun simctl openurl booted "anytype://create-object-widget"

# 5. 等待动画
sleep 2

# 6. 点击按钮(示例:200,400)
idb ui tap 200 400

# 7. 输入一些文本
idb ui text "Hello World"

# 8. 截图
xcrun simctl io booted screenshot /tmp/verify.png

# 9. Claude读取并分析

相关文件

  • Modules/DeepLinks/Sources/DeepLinks/DeepLink.swift - 路由定义
  • Modules/DeepLinks/Sources/DeepLinks/DeepLinkParser.swift - URL解析
  • Anytype/Sources/PresentationLayer/Flows/SpaceHub/SpaceHubCoordinatorViewModel.swift - 导航处理