axe-ios-simulator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAXe iOS Simulator Automation
AXe iOS Simulator 自动化
AXe is a single-binary CLI for iOS Simulator automation via Apple's Accessibility APIs and HID.
AXe是一个单二进制文件的CLI工具,通过Apple的无障碍API和HID实现iOS Simulator自动化。
Installation
安装
bash
brew install cameroncooke/axe/axebash
brew install cameroncooke/axe/axeQuick Start
快速开始
bash
undefinedbash
undefinedGet simulator UDID
获取模拟器UDID
axe list-simulators
UDID="<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
undefinedaxe 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
undefinedTouch & Gestures
触摸与手势
bash
undefinedbash
undefinedTap at coordinates
按坐标点击
axe tap -x 100 -y 200 --udid $UDID
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
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
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
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
undefinedaxe 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
undefinedGesture Presets
手势预设
| Preset | Use Case |
|---|---|
| Content navigation |
| Content navigation |
| Horizontal scrolling |
| Horizontal scrolling |
| Back navigation |
| Forward navigation |
| Dismiss/close |
| Open/reveal |
bash
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| 预设值 | 适用场景 |
|---|---|
| 内容导航 |
| 内容导航 |
| 横向滚动 |
| 横向滚动 |
| 返回导航 |
| 前进导航 |
| 关闭/取消 |
| 打开/显示 |
bash
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 $UDIDText Input
文本输入
bash
undefinedbash
undefinedDirect text (use single quotes for special characters)
直接输入文本(特殊字符使用单引号)
axe type 'Hello World!' --udid $UDID
axe type 'Hello World!' --udid $UDID
From stdin (best for automation)
从标准输入读取(最适合自动化场景)
echo "Complex text" | axe type --stdin --udid $UDID
echo "Complex text" | axe type --stdin --udid $UDID
From file
从文件读取输入
axe type --file input.txt --udid $UDID
axe type --file input.txt --udid $UDID
Individual key press by HID keycode
通过HID键码单独按键
axe key 40 --udid $UDID # Enter key
axe key 42 --duration 1.0 --udid $UDID # Hold Backspace
axe key 40 --udid $UDID # 回车键
axe key 42 --duration 1.0 --udid $UDID # 长按退格键
Key sequence
按键序列
axe key-sequence --keycodes 11,8,15,15,18 --udid $UDID # "hello"
undefinedaxe key-sequence --keycodes 11,8,15,15,18 --udid $UDID # 输入"hello"
undefinedHardware Buttons
硬件按钮操作
bash
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 $UDIDbash
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 $UDIDScreenshot & Video
截图与录屏
bash
undefinedbash
undefinedScreenshot (auto-generates filename)
截图(自动生成文件名)
axe screenshot --udid $UDID
axe screenshot --udid $UDID
Screenshot to specific path
截图到指定路径
axe screenshot --output ~/Desktop/screenshot.png --udid $UDID
axe screenshot --output ~/Desktop/screenshot.png --udid $UDID
Video recording to MP4
录制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
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
流式传输MJPEG
axe stream-video --udid $UDID --fps 10 --format mjpeg > stream.mjpeg
axe stream-video --udid $UDID --fps 10 --format mjpeg > stream.mjpeg
Pipe to ffmpeg
管道传输到ffmpeg
axe stream-video --udid $UDID --fps 30 --format ffmpeg |
ffmpeg -f image2pipe -framerate 30 -i - -c:v libx264 -preset ultrafast output.mp4
ffmpeg -f image2pipe -framerate 30 -i - -c:v libx264 -preset ultrafast output.mp4
Press `Ctrl+C` to stop recording. AXe finalizes MP4 and prints path to stdout.axe stream-video --udid $UDID --fps 30 --format ffmpeg |
ffmpeg -f image2pipe -framerate 30 -i - -c:v libx264 -preset ultrafast output.mp4
ffmpeg -f image2pipe -framerate 30 -i - -c:v libx264 -preset ultrafast output.mp4
按下`Ctrl+C`停止录制。AXe会完成MP4文件的生成,并在标准输出中打印文件路径。Accessibility Inspection
无障碍检查
bash
undefinedbash
undefinedFull screen accessibility tree
全屏无障碍树
axe describe-ui --udid $UDID
axe describe-ui --udid $UDID
Accessibility info at specific point
指定位置的无障碍信息
axe describe-ui --point 100,200 --udid $UDID
undefinedaxe describe-ui --point 100,200 --udid $UDID
undefinedAutomation Patterns
自动化模式
Wait-then-tap pattern
等待后点击模式
bash
axe tap --label "Continue" --pre-delay 2.0 --udid $UDIDbash
axe tap --label "Continue" --pre-delay 2.0 --udid $UDIDScroll to find element
滚动查找元素
bash
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 $UDIDbash
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 $UDIDForm filling
表单填充
bash
axe tap --label "Email" --udid $UDID
axe type 'user@example.com' --udid $UDID
axe tap --label "Password" --udid $UDID
axe type 'secret123' --udid $UDID
axe tap --label "Sign In" --udid $UDIDbash
axe tap --label "Email" --udid $UDID
axe type 'user@example.com' --udid $UDID
axe tap --label "Password" --udid $UDID
axe type 'secret123' --udid $UDID
axe tap --label "Sign In" --udid $UDIDScreenshot after action
操作后截图
bash
axe tap --label "Submit" --post-delay 1.0 --udid $UDID
axe screenshot --output result.png --udid $UDIDbash
axe tap --label "Submit" --post-delay 1.0 --udid $UDID
axe screenshot --output result.png --udid $UDID