2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Appiumはじめの一歩(Android版)

Last updated at Posted at 2022-12-19

はじめに

AppiumのGetting Startedを進めていたのですが思ったよりも動かすのに苦労したので手順をまとめておきました。
GettingStartよりも簡単に動く(はず!)

環境

私が用意した環境は以下の通り

  • node v16.16.0
  • npm 8.11.0
  • Java 11
  • Android Studio 2021.2.1

AndroidStudioのセットアップ

こちらに従ってインストール・セットアップを済ませます。以下が動くことを確認してください。

  • adbコマンド
    • appiumを動かすときにadbコマンドを利用するため必要になります
  • エミュレータの起動
    • ひとまずなんでもOKです。

Appiumのインストール&起動

npm install -g appium

正しくインストールできたか否かはappium-doctorをインストールしてappium-doctorコマンドを実行します

npm install -g appium-doctor
appium-doctor --android

appiumを起動します

appium

うまく起動すると以下のようなログが出力されます

C:\Users\uzres\products\appium-sample\appium-java-sample>appium
[Appium] Welcome to Appium v1.22.3
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

エミュレータを起動します

公式で提供しているサンプルアプリケーションはAndroid Version 8(古い・・・)で動くものなので起動する手順に注意が必要です。

DeviceManager - Create deviceを選択します

image.png

Pixel3aを選択してみました

image.png

Android 8はOreoなのでこれを選択します。(ダウンロードしていない場合はダウンロードします)

image.png

名前を適当に変更してFinishを選択します。

image.png

作ったエミュレータで再生ボタンを選択します。

image.png

端末が起動してくるはずです

image.png

テストの実行

今回はアプリをインストールし、TOPページのスクリーンショットを撮ってみます。

ソースはこちらからcloneしてください。

公式が提供しているサンプルアプリをダウンロードしappium-java-sample/src/test/resources/appsに保存します

テストを実行します。エミュレータを見ていると実際にappiumが動いてる様子が見れるはずです。

jp.gr.java_conf.uzresk.appium.sample.FirstTest

ルートディレクトリにscreenshot.jpgができていれば成功です。

image.png

補足

エミュレータにアプリを手動でインストール

adbコマンドでインストールが可能です。エミュレータに正しくインストールできるか確認してもよいでしょう。

adb install ApiDemos-debug.apk

アクティビティ起動失敗時のトラブルシューティング

エミュレータでDiskが一杯

appiumを動かしていると以下のようなエラーが発生

android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

Emulatorを停止し、「WipeData」をクリックするとデータを消せる。
(Emulatorはウィンドウの×ボタンを押せば止まります)

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?