Package: androidautotest
AndroidTestThe package is for android auto test, based on Python enviroment.Basic thought is using ADB (Android Debug Bridge) to send command to Android test Phone connected with the PC and match picture by match template algorithm in opencv-python.Requirement1.ADB (Android Debug Bridge)2.ASM (Android Screen Monitor)Use to capture partial picture, and you need to install JDK in your computer before running it.Then adjust zoom to 50%, you can also set zoom to other size, but need to add some code in your case source file after your create your case file:# adjust asm zoom to other size, 25%ASM.ZOOM_SIZE=253.Tesseract (Tesseract-OCR)If you want to use the mechod 'image_to_string' in the 'androidautotest.api' which can recognize text in pictures, you need to install Tesseract and install testdata necessary like chinese 'chi_sim'.Installation & Usage1.Install androidautotestpipinstallandroidautotestFollow information indicate you have installed androidautotest successfully.>python-mandroidautotest
usage:androidautotest--installdepandroidautotest--startasmandroidautotest--newcase<NEWCASE>--savedir<SAVEDIR>androidautotest--casedir<CASEDIR>--device<DEVICE>--times<TIMES>

Aframeworktoruntestcaseforandroidautomatedtestoptionalarguments:-V,--versionPrintversionandexit-h,--helpPrintthishelpmessageandexitinstalldependency:--installdepinstalldependencyofandroidautotest

startasm:--startasmstartAndroidScreenMonitor

createcase:--newcase<NEWCASE>Newcasenametocreate--savedir<SAVEDIR>Pathtosavenewcaseruncase:--casedir<CASEDIR>Casepathtorun--device<DEVICE>Devicetoswitch--times<TIMES>Timesofcaserunning2.install requirementspython-mandroidautotest--installdep3.start Android Screen Monitor(First, connect your Android Phone with PC, and open adb debug mode), then run follow command:python-mandroidautotest--startasm4.create a new case to start your test task with Android Phone(For example: to create a new case named 'case001').python-mandroidautotest--newcasecase001--savedirE:\AndroidTest\workspaceDocumentationYou can find the complete AndroidTest API documentation onreadthedocs.Examples# -*- coding: UTF-8 -*-fromandroidautotest.apiimport*# to homekeyevent(HOME)keyevent(HOME,device='HMKNW17421063974')# to FileBrowserwhilenotexists(Template(r'pic\20191215121636.png')):flick((400,400),DIR_LEFT,step=2)touch(Template(r'pic\20191215121636.png'))touch(Template(r'pic\20191215134814.png'))# not in top screen of FileBrowserifexists(Template(r'pic\20191215143440.png')):touch(Template(r'pic\20191215142057.png'))text('15045120')else:touch([530,142])text('15045120')# 15045120 is in screenassert_exists(Template(r'pic\20191215142425.png'))end()Once you finish your code writing, you can run your case.
1.If you connect one Android Phone with your PC, and run for once time, simple wirte as followingpython-mandroidautotest--casedirE:\AndroidTest\workspace\case001.air--deviceHMKNW17421063974--times52.If you connect more than one Android Phone with your PC, run case with Android Phone which's serial number is 'HMKNW17421063974' for 5 times, you can write as following.python-mandroidautotest--casedirE:\AndroidTest\workspace\case001.air--deviceHMKNW17421063974--times5And there are three log files you can use to analyze your test plan after run your case.In case001.air\log\case001.log.XXXFile NameDescriptionlog_case001_XXX.txtall log outputserial_log_case001_XXX.txtadb log outputreport_case001_XXX.htmlreport of case run