appium について
appiumは、AndroidとiOSのネイティブアプリやハイブリッドアプリを自動テストする開発者向けのスキルです。capabilities、要素検索、端末操作、CI実行の手順を扱います。
主な機能
- 01AndroidとiOSのテスト手順
- 02Desired capabilitiesの例
- 03要素検索の方法
- 04ジェスチャーと端末操作の案内
- 05CI実行の実践事項
活用シーン
- 01ネイティブモバイルアプリの自動テスト
- 02ハイブリッドAndroid・iOSアプリのテスト
- 03要素検索方法や待機処理の選択
- 04CIでのモバイルテスト実行
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ partme-ai/ full-stack-skills --skill appiumインストール後、Claude Code で/appiumを入力して読み込まれたか確認します。
同梱ファイルLICENSE.txt
詳細
このスキルを使用するタイミング
次のことをユーザーが希望する場合は、いつでもこのスキルを使用してください。
- Android および iOS のネイティブまたはハイブリッドモバイルアプリケーションの自動テストを作成する
- アクセシビリティ ID、ID、XPath、またはクラス名を使用して要素を特定する
- ジェスチャー(タップ、スワイプ、スクロール)を実行し、デバイスとのやり取りを処理する
- デバイスやプラットフォームごとに desired capabilities を設定する
- Appium のテストを CI/CD パイプライン(Jenkins、GitHub Actions)に統合する
このスキルの使用方法
ワークフロー
- 環境をセットアップする:Appium Server、ドライバー(Android 用の UiAutomator2、iOS 用の XCUITest)、言語バインディングをインストールします
- capabilities を定義する:デバイス名、プラットフォーム、アプリのパス、オートメーションエンジンを指定します
- テストスクリプトを作成する:要素を特定し、操作を実行して、結果をアサートします
- CI で実行する:並列実行とレポート機能を使用して、実機またはエミュレーターで実行します
1. Desired Capabilities
desired_caps = {
"platformName": "Android",
"deviceName": "Pixel_6",
"app": "/path/to/app.apk",
"automationName": "UiAutomator2",
"noReset": True,
}
2. テスト例(Python)
from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
wait = WebDriverWait(driver, 10)
# Login flow
username = wait.until(EC.presence_of_element_located((AppiumBy.ACCESSIBILITY_ID, "username")))
username.send_keys("testuser")
driver.find_element(AppiumBy.ACCESSIBILITY_ID, "password").send_keys("secret")
driver.find_element(AppiumBy.ACCESSIBILITY_ID, "login-button").click()
# Assert
welcome = wait.until(EC.presence_of_element_located((AppiumBy.ACCESSIBILITY_ID, "welcome")))
assert welcome.is_displayed()
driver.quit()
3. テスト例(Java)
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "Android");
caps.setCapability("deviceName", "Pixel_6");
caps.setCapability("app", "/path/to/app.apk");
caps.setCapability("automationName", "UiAutomator2");
AndroidDriver driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), caps);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
driver.findElement(AppiumBy.accessibilityId("username")).sendKeys("testuser");
driver.findElement(AppiumBy.accessibilityId("login-button")).click();
assertTrue(wait.until(ExpectedConditions.visibilityOfElementLocated(AppiumBy.accessibilityId("welcome"))).isDisplayed());
driver.quit();
ベストプラクティス
- 要素の特定にはアクセシビリティ ID またはリソース ID を優先し、壊れやすい XPath 式は避けます
- 明示的な待機と再試行ロジックを使用し、失敗時にはスクリーンショットとログを取得します
- デバイスマトリックスを使用して、複数のデバイスと OS バージョンでテストします
- 機密情報(アプリのパス、認証情報)は環境変数に保存します
- スワイプ、スクロール、長押しには Appium 組み込みのジェスチャー API を使用します
リソース
- 公式ドキュメント:https://appium.io/docs/en/latest/
- GitHub:https://github.com/appium/appium
キーワード
appium, モバイルオートメーション, Android, iOS, UiAutomator2, XCUITest, アクセシビリティ ID, desired capabilities, クロスプラットフォーム, UI テスト, モバイルテスト
コメント
Markdown 対応