「"RPA"風に利用できるかも」と思い、次のurlを参考にさせて頂きながら、 appium を windows10にinstall 。
- https://qiita.com/emurin/items/fe640327f847c474f1e8
- https://qiita.com/cawpea/items/4913ba73c4c60ae54e02
- https://qiita.com/exp/items/bdf06a388f30a1726984
今回は「とりあえずのinstall」まで行っています。
java , python , nodejs
それぞれが、何の prerequired かであるかは、忘れましたが、 appium 等のinstall 前に以下のversionがinstallされていました。
C:\Users\end0t>java -version java version "10.0.1" 2018-04-17 C:\Users\end0t>python --version Python 2.7.16 C:\Users\end0t>node -v v10.15.3 C:\Users\end0t>npm -v 6.4.1
install android studio (3.3.2 for Windows 64-bit (948 MB))
android仮想端末とplatform-toolsが必要ですので、 android studio をinstallしています。
インストーラは android-studio-ide-182.5314842-windows.exe です。 (ver.3.3.2 という文字列がファイル名にないことが少々、気になります)
android studioのinstallにより、SDKも合わせてinstallされますが windowsの環境変数に以下を追加しています。
android studioから仮想端末を作成し、adbで動作確認
次のように追加した仮想端末が認識されていれば、OK
C:\Users\end0t>adb devices List of devices attached emulator-5554 device
install appium (GUI版)
http://appium.io/ から appium-desktop-setup-1.11.0.exe をダウンロードし、installするだけです。
install appium (CUI版)
C:\Users\end0t>npm install -g appium C:\Users\end0t>npm install -g appium-doctor C:\Users\end0t>appium-doctor
install後の appium の状態?は、appium-doctor が診断してくれます。 私の場合、 windows-build-tools や opencv4nodejs をinstallしています。 ( cmake もinstallしたような)
PS C:\WINDOWS\system32> npm install --global windows-build-tools PS C:\WINDOWS\system32> npm install --save opencv4nodejs
install Appium-Python-Client
C:\Users\end0t>pip install Appium-Python-Client
軽く動作確認
- 1) https://github.com/appium/python-client/blob/master/test/apps/ApiDemos-debug.apk から、ApiDemos-debug.apk をダウンロードし、任意のdirに保存
- 2) android studioで仮想端末を起動
- 3) appium (GUI)で、Start Server v1.11.1 をクリック
- 4) 以下のpython scriptを実行して、何となく動作すればOK
#!python # -*- coding: utf-8 -*- import getopt import sys import os from appium import webdriver from appium.webdriver.common.touch_action import TouchAction import unittest # https://github.com/appium/python-client class TestAppium(unittest.TestCase): def setUp(self): desired_caps = {} desired_caps["platformName"] = "Android" desired_caps["automationName"] = "Appium" # desired_caps["automationName"] = "uiautomator2" desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'ApiDemos-debug.apk')) desired_caps["platformVersion"] = "8.1" desired_caps['deviceName'] = 'Nexus 5 API 27' desired_caps["appPackage"] = "io.appium.android.apis" desired_caps["appActivity"] = "io.appium.android.apis.ApiDemos" self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) def tearDown(self): self.driver.quit() def test_contexts_list(self): el = self.driver.find_element_by_class_name('android.widget.ListView') actions = TouchAction(self.driver) actions.flick_element(el, 0, -300, 0) actions.perform() sleep(5) # def test_find_element(self): # elm = self.driver.find_element_by_class_name('android.widget.TextView'); # print(elm) # elm.click() # TouchAction(self.driver).tap(x=204, y=530).perform() # TouchAction(self.driver).tap(x=204, y=700).perform() # 要素が見つかるまで ?sec待つ # self.driver.implicitly_wait(5) # elm = self.driver.find_element_by_accessibility_id("App"); # elm = self.driver.find_element_by_id("android:id/text7"); if __name__ == "__main__": unittest.main()