关于 axe-ios-simulator
axe-ios-simulator 是通过 Apple Accessibility API 和 HID 操作 iOS Simulator 的命令行技能,适用于自动化测试与重复性模拟器任务,并支持元素定位、手势和画面采集。
主要功能
- 01按坐标、标签或标识符点击
- 02从输入或文件录入文本
- 03执行预设触控手势
- 04按下模拟器硬件按钮
- 05检查无障碍树并采集媒体
适用场景
- 01自动填写并提交表单
- 02通过点击和滑动浏览界面
- 03测试时检查界面元素
- 04保存截图或视频录制
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ alleneubank/ claude-code --skill axe-ios-simulator安装后在 Claude Code 中输入/axe-ios-simulator确认已加载。
详细介绍
AXe iOS Simulator 自动化
AXe 是一款单二进制文件 CLI,可通过 Apple 的 Accessibility API 和 HID 实现 iOS Simulator 自动化。
安装
brew install cameroncooke/axe/axe
快速开始
# Get simulator UDID
axe list-simulators
UDID="<simulator-udid>"
# Basic interactions
axe tap -x 100 -y 200 --udid $UDID
axe tap --label "Safari" --udid $UDID
axe type 'Hello World!' --udid $UDID
axe gesture scroll-down --udid $UDID
axe button home --udid $UDID
axe screenshot --udid $UDID
触摸与手势
# Tap at coordinates
axe tap -x 100 -y 200 --udid $UDID
# Tap by accessibility identifier or label
axe tap --id "myButton" --udid $UDID
axe tap --label "Submit" --udid $UDID
# With timing controls
axe tap -x 100 -y 200 --pre-delay 1.0 --post-delay 0.5 --udid $UDID
# Swipe
axe swipe --start-x 100 --start-y 300 --end-x 300 --end-y 100 --udid $UDID
axe swipe --start-x 50 --start-y 500 --end-x 350 --end-y 500 --duration 2.0 --delta 25 --udid $UDID
# Low-level touch control
axe touch -x 150 -y 250 --down --udid $UDID
axe touch -x 150 -y 250 --up --udid $UDID
axe touch -x 150 -y 250 --down --up --delay 1.0 --udid $UDID
手势预设
| 预设 | 使用场景 |
|---|---|
scroll-up | 浏览内容 |
scroll-down | 浏览内容 |
scroll-left | 水平滚动 |
scroll-right | 水平滚动 |
swipe-from-left-edge | 返回导航 |
swipe-from-right-edge | 前进导航 |
swipe-from-top-edge | 关闭/退出 |
swipe-from-bottom-edge | 打开/显示 |
axe gesture scroll-down --udid $UDID
axe gesture swipe-from-left-edge --udid $UDID
axe gesture scroll-up --screen-width 430 --screen-height 932 --udid $UDID
axe gesture scroll-down --pre-delay 1.0 --post-delay 0.5 --udid $UDID
文本输入
# Direct text (use single quotes for special characters)
axe type 'Hello World!' --udid $UDID
# From stdin (best for automation)
echo "Complex text" | axe type --stdin --udid $UDID
# From file
axe type --file input.txt --udid $UDID
# Individual key press by HID keycode
axe key 40 --udid $UDID # Enter key
axe key 42 --duration 1.0 --udid $UDID # Hold Backspace
# Key sequence
axe key-sequence --keycodes 11,8,15,15,18 --udid $UDID # "hello"
硬件按钮
axe button home --udid $UDID
axe button lock --duration 2.0 --udid $UDID
axe button side-button --udid $UDID
axe button siri --udid $UDID
axe button apple-pay --udid $UDID
截图与视频
# Screenshot (auto-generates filename)
axe screenshot --udid $UDID
# Screenshot to specific path
axe screenshot --output ~/Desktop/screenshot.png --udid $UDID
# Video recording to MP4
axe record-video --udid $UDID --fps 15 --output recording.mp4
axe record-video --udid $UDID --fps 10 --quality 60 --scale 0.5 --output low-bandwidth.mp4
# Stream MJPEG
axe stream-video --udid $UDID --fps 10 --format mjpeg > stream.mjpeg
# Pipe to ffmpeg
axe stream-video --udid $UDID --fps 30 --format ffmpeg | \
ffmpeg -f image2pipe -framerate 30 -i - -c:v libx264 -preset ultrafast output.mp4
按 Ctrl+C 停止录制。AXe 会完成 MP4 文件并将路径输出到标准输出。
无障碍检查
# Full screen accessibility tree
axe describe-ui --udid $UDID
# Accessibility info at specific point
axe describe-ui --point 100,200 --udid $UDID
自动化模式
等待后点击模式
axe tap --label "Continue" --pre-delay 2.0 --udid $UDID
滚动查找元素
for i in {1..5}; do
axe describe-ui --udid $UDID | grep -q "targetElement" && break
axe gesture scroll-down --udid $UDID
done
axe tap --label "targetElement" --udid $UDID
填写表单
axe tap --label "Email" --udid $UDID
axe type '[email protected]' --udid $UDID
axe tap --label "Password" --udid $UDID
axe type 'secret123' --udid $UDID
axe tap --label "Sign In" --udid $UDID
操作后截图
axe tap --label "Submit" --post-delay 1.0 --udid $UDID
axe screenshot --output result.png --udid $UDID
评论
支持 Markdown