关于 agent-browser-ios
面向使用 agent-browser 操作 iOS Simulator 应用的 Agent 技能,适用于移动端浏览器工作流。内容涵盖环境准备、设备操作方式及 iOS 特有的注意事项。
主要功能
- 01启动并列出 iOS 模拟器
- 02用 tap 和 swipe 操作原生控件
- 03检查无障碍树和 WebView
- 04截取模拟器画面
适用场景
- 01在 iOS Simulator 中执行浏览器任务
- 02通过触控操作浏览原生界面
- 03启用 Web Inspector 后检查 WebView 内容
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ owenleezy/ agent-browser-skill --skill agent-browser-ios安装后在 Claude Code 中输入/agent-browser-ios确认已加载。
详细介绍
Agent Browser — iOS 模拟器
内部模板。 入口:
agent-browser技能。
推荐配置: agent-browser -p ios(即 --provider ios)
禁止事项
NEVER run commands before Simulator is booted — daemon can't connect; boot first with xcrun simctl
NEVER use `scroll` on iOS — use `swipe up` / `swipe down` instead
NEVER use `click` on native touch targets — prefer `tap @ref` for iOS elements
NEVER copy element refs across navigations — re-run `snapshot -i` after every screen change
NEVER assume WebView content is inspectable — must enable Web Inspector in Safari → Develop → [device]
前提条件
iOS 模拟器需要:
- macOS(Apple Silicon 或 Intel)
- Xcode 和 iOS 模拟器 — 从 Mac App Store 安装
- Appium —
npm install -g appium && appium driver install xcuitest - 启动 agent-browser 前,模拟器必须已在 Xcode 中运行
# Verify prerequisites
xcodebuild -version # Xcode installed?
appium --version # Appium installed?
appium driver list --installed # XCUITest driver present?
环境检查
printenv | grep AGENT_BROWSER # already set? Omit the corresponding inline flag
工作流
# 1. Start Simulator in Xcode first (or via xcrun)
xcrun simctl boot "iPhone 15 Pro"
open -a Simulator
# 2. List available simulators
agent-browser -p ios device list
# 3. Open app in simulator
agent-browser -p ios --device "iPhone 15 Pro" open https://app.example.com
# 4. Explore interactive elements
agent-browser -p ios snapshot -i
# 5. iOS-native gestures
agent-browser -p ios tap @e1
agent-browser -p ios swipe up # scroll up
agent-browser -p ios swipe down # scroll down
agent-browser -p ios swipe left # swipe carousel / delete row
agent-browser -p ios swipe right # go back (swipe edge)
# 6. Standard commands work too
agent-browser -p ios screenshot --full ios-result.png
agent-browser -p ios find role button click --name "Submit"
agent-browser -p ios get text @e3
agent-browser -p ios wait --load networkidle
关键模式
| 模式 | 命令 |
|---|---|
| 列出模拟器 | agent-browser -p ios device list |
| 指定目标设备 | -p ios --device "iPhone 15 Pro" |
| iOS 滚动 | swipe up / swipe down(不要使用 scroll) |
| iOS 点按 | tap @e1(触控目标优先使用此命令,而非 click) |
| 返回上一页 | swipe right(从边缘滑动) |
| 关闭底部面板 | swipe down |
| 截取证据截图 | screenshot --full ios-result.png |
| 检查 DOM(WebView) | snapshot -i(用于 WKWebView 中的网页内容) |
在 iOS 上仍可使用的 Chrome 命令
以下标准命令可与 -p ios 配合使用:
open <url>— 导航snapshot/snapshot -i— 无障碍树find role button click --name "..."— 语义定位器get text @e1/get value @e1screenshot [path]/screenshot --fullwait @e1/wait --load networkidleis visible @e1/is enabled @e1errors/console(用于 WebView 内容)
易踩问题
| 错误 | 修复方法 |
|---|---|
| 运行前未启动模拟器 | 先在 Xcode 中启动模拟器,或运行 xcrun simctl boot "iPhone 15 Pro" |
| 未安装 Appium | npm install -g appium && appium driver install xcuitest |
使用 scroll 而非 swipe | iOS 使用 swipe up/swipe down,而非 scroll |
在仅支持触控的元素上使用 click | 对原生触控目标优先使用 tap @e1 |
device list 未显示设备 | 模拟器尚未启动 — 打开 Xcode → Simulators 并启动一台设备 |
| 缺少 XCUITest 驱动 | appium driver install xcuitest |
| 无法检查 WebView 内容 | 在 Safari → Develop → [device name] 中启用 "Web Inspector" |
评论
支持 Markdown