トップページ > Appium API(逆引き) > 【Appium Python】アプリケーションインストールとその関連

【Appium Python】アプリケーションインストールとその関連

【PR】業界トップクラスの「高単価報酬」「低マージン」を実現!レバテックフリーランス

「is_app_installed」ではローカルに保存されている".apk"ファイルを引数に指定してアプリをインストールしていきます。インストール後、アプリは自動で起動するわけでなく別のメソッドを用いて起動する必要があります。


「remove_app」でアプリのアンインストール、「is_app_installed」でインストール確認をします。ともに引数にパッケージ名を指定します。インストール確認では、True/Falseで戻り値が返されます。

説明

◆メソッド
  ○アプリケーションインストール
       ・driver.is_app_installed("/path/to/app.apk")
      
  ○アプリケーションアンインストール
       ・driver.remove_app("com.example.app")
      
  ○インストール確認
       ・install_info = driver.is_app_installed("com.example.app")
◆備考
  ・ー
◆その他「Appium API」
  ・アプリケーションの起動とその関連
  ・キャプチャ関連

サンプル

from appium import webdriver
import time

# 接続したいアプリ情報を変数に格納
desired_caps = {}
desired_caps["platformName"] = "Android"
desired_caps["platformVersion"] = "12.0"
desired_caps["appium:deviceName"] = "PixelXLAPI31"
desired_caps["appium:automationName"] = "UiAutomator2"
# セッションの作成
test_session = webdriver.Remote(
    command_executor='http://localhost:4723/wd/hub',
    desired_capabilities= desired_caps)

# アプリのインストール
test_session.install_app("C:\\appium_test\\app-debug.apk")
# 指定したアプリがインストールされているか確認
check_ins = test_session.is_app_installed("com.example.appium_test_app")
print(check_ins) # True
# インストールしたアプリを起動
test_session.activate_app("com.example.appium_test_app")
# 5秒間待機
time.sleep(5)
# アプリのアンインストール
test_session.remove_app("com.example.appium_test_app")
# 指定したアプリがインストールされているか再度確認
check_ins = test_session.is_app_installed("com.example.appium_test_app")
print(check_ins) # False
※Appium v2.0.0-beta.55で動作確認をしています

実行結果

app1
yajirushi
app2

Warning: Invalid argument supplied for foreach() in /home/users/1/monda-muki/web/seleniumqref.com/api/appium_python/app/app_installation_related-AppiumPython.html on line 179

Appium PythonAPI TOP10
過去1週間(12/04~12/10)

    カテゴリー

    環境構築

    APIリファレンス

    その他

    ページ上部へ戻る
    トップページ > Appium API(逆引き) > 【Appium Python】アプリケーションインストールとその関連
    Copyright © 2016- Seleniumクイックリファレンス All Rights Reserved