ios-app-tester について
iOS App Tester は、AXe コマンドラインツールで iOS Simulator アプリをテスト・自動化するスキルです。画面操作、アクセシビリティ検査、動画記録、スクリプト化したテスト、CI/CD の手順を扱います。
主な機能
- 01シミュレーターのタップと文字入力
- 02アクセシビリティ要素の検査
- 03シミュレーター動画の記録・配信
- 04テスト手順のスクリプト化
- 05CI/CD テスト設定の案内
活用シーン
- 01シミュレーターでのログイン操作の自動化
- 02アクセシビリティラベルの監査
- 03テスト調査用動画の記録
- 04CI/CD への UI 検査の追加
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ ckorhonen/ claude-skills --skill ios-app-testerインストール後、Claude Code で/ios-app-testerを入力して読み込まれたか確認します。
詳細
iOS アプリテスター(AXe CLI)
概要
Apple のアクセシビリティ API を活用してシミュレーターをプログラムから制御するコマンドラインツール、AXe を使用して、iOS シミュレーターのアプリをテストおよび自動化します。AXe はサーバーのセットアップが不要な単一のバイナリとして動作します。
使用する場面
- テストのために iOS シミュレーターの UI 操作を自動化する
- アクセシビリティラベルと VoiceOver の説明を監査する
- テスト実行の動画を記録する
- 再現可能なテストシナリオをスクリプト化する
- CI/CD パイプラインに iOS テストを統合する
前提条件
- Xcode がインストールされた macOS
- iOS シミュレーター(Xcode に付属)
- Homebrew(インストール用)
インストール
brew tap cameroncooke/axe
brew install axe
インストールを確認します:
axe --help
クイックスタート
- シミュレーターの UDID を確認します:
axe list-simulators
- 座標をタップします:
axe tap -x 200 -y 400 --udid <SIMULATOR_UDID>
- アクセシビリティ要素を調べます:
axe describe-ui --udid <SIMULATOR_UDID>
コマンドリファレンス
シミュレーターの検出
# List all available simulators with UDIDs
axe list-simulators
タッチ操作
# Tap at coordinates
axe tap -x 100 -y 200 --udid <UDID>
# Swipe gesture
axe swipe --start-x 100 --start-y 500 --end-x 100 --end-y 200 --udid <UDID>
# Low-level touch events
axe touch-down -x 100 -y 200 --udid <UDID>
axe touch-up -x 100 -y 200 --udid <UDID>
ジェスチャーのプリセット
# Scrolling
axe gesture scroll-up --udid <UDID>
axe gesture scroll-down --udid <UDID>
axe gesture scroll-left --udid <UDID>
axe gesture scroll-right --udid <UDID>
# Edge swipes (for navigation)
axe gesture swipe-from-left-edge --udid <UDID>
axe gesture swipe-from-right-edge --udid <UDID>
axe gesture swipe-from-top-edge --udid <UDID>
axe gesture swipe-from-bottom-edge --udid <UDID>
テキスト入力
# Type text directly
axe type 'Hello World!' --udid <UDID>
# Type from stdin (useful for passwords/sensitive data)
echo "secret" | axe type --stdin --udid <UDID>
# Type from file
axe type --file input.txt --udid <UDID>
ハードウェアボタン
# Home button
axe button home --udid <UDID>
# Lock/power button
axe button lock --udid <UDID>
# Long press (e.g., for Siri)
axe button lock --duration 2.0 --udid <UDID>
# Side button
axe button side --udid <UDID>
# Apple Pay
axe button apple-pay --udid <UDID>
アクセシビリティの調査
# Describe all UI elements (full screen)
axe describe-ui --udid <UDID>
# Describe element at specific point
axe describe-ui --point 100,200 --udid <UDID>
動画の録画
# Record to MP4 file
axe record-video --udid <UDID> --fps 15 --output test-recording.mp4
# Stream video (for ffmpeg piping)
axe stream-video --udid <UDID> --fps 30 --format ffmpeg | ffmpeg -i - output.mp4
# Stream as MJPEG
axe stream-video --udid <UDID> --fps 10 --format mjpeg > stream.mjpeg
タイミング制御
すべてのコマンドで、順序を制御するための遅延を指定できます:
# Wait before action
axe tap -x 100 -y 200 --pre-delay 1.0 --udid <UDID>
# Wait after action
axe tap -x 100 -y 200 --post-delay 0.5 --udid <UDID>
# Combined delays
axe type 'text' --pre-delay 0.5 --post-delay 1.0 --udid <UDID>
アクセシビリティテストのワークフロー
1. 画面全体を監査する
# Get all accessibility elements
axe describe-ui --udid <UDID> > accessibility-audit.txt
出力を確認し、次の項目をチェックします:
accessibilityLabelの値が設定されていない- 「button」や「image」のような汎用的なラベル
- 複雑な操作に対する
accessibilityHintが設定されていない accessibilityTraitsが正しくない
2. ポイントベースの調査
# Check specific element
axe describe-ui --point 200,400 --udid <UDID>
3. VoiceOver シミュレーションスクリプト
#!/bin/bash
UDID="YOUR_SIMULATOR_UDID"
# Navigate through app elements
axe gesture swipe-from-left-edge --udid $UDID --post-delay 1.0
axe describe-ui --udid $UDID
axe tap -x 200 -y 400 --udid $UDID --post-delay 0.5
axe describe-ui --udid $UDID
自動化の例
#!/bin/bash
UDID="YOUR_SIMULATOR_UDID"
# Login flow automation
echo "Starting login test..."
# Tap email field
axe tap -x 200 -y 300 --udid $UDID --post-delay 0.3
# Type email
axe type '[email protected]' --udid $UDID --post-delay 0.3
# Tap password field
axe tap -x 200 -y 380 --udid $UDID --post-delay 0.3
# Type password (from stdin for security)
echo "password123" | axe type --stdin --udid $UDID --post-delay 0.3
# Tap login button
axe tap -x 200 -y 480 --udid $UDID --post-delay 2.0
# Verify result - check for expected element
axe describe-ui --udid $UDID | grep -q "Welcome" && echo "Login successful"
CI/CD との統合
# GitHub Actions example
- name: Run iOS UI Tests
run: |
# Boot simulator
xcrun simctl boot "iPhone 15"
UDID=$(xcrun simctl list devices | grep "iPhone 15" | grep -oE '[A-F0-9-]{36}')
# Install app
xcrun simctl install $UDID ./build/MyApp.app
xcrun simctl launch $UDID com.example.myapp
# Run AXe tests
axe describe-ui --udid $UDID > accessibility-report.txt
# Record test
axe record-video --udid $UDID --fps 10 --output test.mp4 &
VIDEO_PID=$!
# Run automation script
./test-scripts/login-flow.sh $UDID
kill $VIDEO_PID
トラブルシューティング
「シミュレーターが見つかりません」
# Ensure simulator is booted
xcrun simctl boot "iPhone 15"
# Get correct UDID
axe list-simulators
「権限がありません」
# Grant accessibility permissions in System Preferences
# Security & Privacy > Privacy > Accessibility
コマンドが応答しない
# Ensure app is in foreground
xcrun simctl launch <UDID> <BUNDLE_ID>
# Add delays between commands
axe tap -x 100 -y 200 --post-delay 1.0 --udid <UDID>
ベストプラクティス
- 信頼性を高めるため、コマンド間には必ず
--post-delayを使用します - スクリプトでは UDID を環境変数に保存します
- 操作の前後に
describe-uiを使用して状態を確認します - デバッグのため、テスト実行中に動画を録画します
- 機密性の高いテキストはコマンドライン引数ではなく、標準入力経由で渡します
- CI/CD パイプラインの一部としてアクセシビリティ監査を実行します
コメント
Markdown 対応