AndroidAutoTest

梦想的初衷 提交于 2019-12-22 13:30:13

pypi: https://pypi.org/project/androidautotest/

AndroidTest

The 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.

Installation

1.Install ADB (Android Debug Bridge), and add it to path.
2.Use ASM (Android Screen Monitor) to capture partial picture, and you need to install JDK in your computer first to run it.

  • Simple to use:
java -jar asm.jar
  • Then adjust zoom to 50%, you also can set to other size, but need to add some code in your case source file after your create your case file:
# if adjust asm zoom to 25% 
ASM.ZOOM_SIZE = 25

3.Install androidautotest

pip install androidautotest 

4.Install dependency before run your case file, Use tools\install.py

python install.py

5.Use tools\newCase.py to create a new case to start your test task with Android Phone.

python newCase.py <caseName> <savePath>

Documentation

You can find the complete AndroidTest API documentation on readthedocs.

Examples

# -*- coding: UTF-8 -*-
from androidautotest.api import *

# to home
keyevent(HOME)
keyevent(HOME,device='HMKNW17421063974')

# to FileBrowser
while not exists(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 FileBrowser
if exists(Template(r'pic\20191215143440.png')):
	touch(Template(r'pic\20191215142057.png'))
	text('15045120')
else:
	touch([530,142])
	text('15045120')

# 15045120 is in screen
assert_exists(Template(r'pic\20191215142425.png'))

end()

Once you finish your code writing, you can run your case(for example: you create a case named ‘case001’):

cd case001.air
python case001.py

And there are three log files you can use to analyze your test plan after run your case.

  • case001.air\case001.log.20191222010717_540637\log_case001_20191222010717_540637.txt
  • case001.air\case001.log.20191222010717_540637\serial_log_case001_20191222010717_540637.txt
  • case001.air\case001.log.20191222010717_540637\report_case001_20191222010717_540637.html

  • log_case001_XXX: all log output
  • serial_log_case001_XXX: adb log output
  • serial_log_case001_XXX: report of case run
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!