안드로이드 테스트 자동화를 위한 applium 가져오기 (윈도우즈 + ptyhon)
python을 사용하는 데도 공식.의 js 코드가 움직이지 않는 이유가 있다.
개요는 Get started with mobile automation: Appium & Python의 개요이다.
차리다
Android Studio、python、Node.js 등이 설치되었습니다.
1. appium
GUI 및 CLI 가 있습니다.CLI를 사용했습니다.
도입 방법 상세여기 기사.
본체
npm install -g appium
설치에 결함이 없는지 진단하는 도구npm install -g appium-doctor
진단하다appium-doctor --android
Bin directory for %JAVA_HOME% is not set왜냐하면
%JAVA_HOME%\bin;
path 추가2. ptyhon 클라이언트 라이브러리
python을 사용하려고 하기 때문에 아래에 설치합니다
pip install Appium-Python-Client
3. Android Virtual Device 시작 만들기
Android Studio에서 AVD 관리자를 시작하여 가상 장치를 제작합니다.다음 설정을 사용했습니다.
터미널: Nexus One
APILevel: 26
ABI: x86
target:Android8.0 (Google APIs)
4. 애플리케이션 시작
2019/1/14 추기 관리자 권한으로 시작해야 할 수도 있음
appium
테스트
1. 상대의 apk 준비
원문에서 테스트 대상은 Chess Free라는 응용 프로그램을 사용했다.에서 오다여기..apk를 다운로드하여 적당한 위치에 두다.
2. AndroidManifest.xml에서 필요한 정보 얻기
필요한 것은
1. 포장 이름
2. 활동 이름 시작
apk의 루트 디렉토리에 있는 Android Manifest.xml에서 얻습니다.또는 명령 프롬프트에서
aapt dump badging apkへのパス
그런데 소식이 있는 것 같아요.Chess Free 정보
package="uk.co.aifactory.chessfree"and
android:name=".ChessFreeActivity"
필요한 정보.
3. 시험 쓰기
android_chess.py
"""
Qxf2: Example script to run one test against the Chess Free app using Appium
The test will:
- launch the app
- click the 'PLAY!' button
"""
import os
import unittest
from appium import webdriver
from time import sleep
class ChessAndroidTests(unittest.TestCase):
"Class to run tests against the Chess Free app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.0'
desired_caps['deviceName'] = 'Nexus'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'apps/Chess Free.apk'))
desired_caps['appPackage'] = 'uk.co.aifactory.chessfree'
desired_caps['appActivity'] = '.ChessFreeActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_single_player_mode(self):
"Test the Chess app launches correctly and click on Play button"
sleep(15)
element = self.driver.find_element_by_id("uk.co.aifactory.chessfree:id/ButtonPlay")
element.click()
sleep(5)
#---START OF SCRIPT
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ChessAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)
주의 setUp()
내의 설정은 자신의 환경의 설정과 일치한다.원래 보도와 달리 Chess Free의 응용 프로그램에는 다음과 같은 그림의 확인 화면이 나타난다
어쨌든
sleep(15)
할 때 "Accept"를 수동으로 눌러요.자신의 앱을 테스트하려면 버튼의 식별명 등을 알아야 한다
다른 프로그램의 버튼 id를 아는 방법이 있나요?
2019/4/7 보충
Android Studio와 함께 제공되는 UI Automator Viewer는 가능합니다@jwoff25.또 애플의 GUI 버전도 가능하다.
4. 실행
AVD와 applium이 시작되고 있기 때문에 실행만 남았습니다
python android_chess.py
ChessFree의 "PLAY!"버튼이 눌린 후에 프로그램이 끝납니다지령 제시 화면은 이런 느낌이다.
test_single_player_mode (_main_.ChessAndroidTests)
Test the Chess app launches correctly and click on Play button ... ok
----------------------------------------------------------------------
Ran 1 test in 29.538s
OK
Reference
이 문제에 관하여(안드로이드 테스트 자동화를 위한 applium 가져오기 (윈도우즈 + ptyhon)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/exp/items/bdf06a388f30a1726984텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)