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.
Requirement
1.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 = 25
3.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 & Usage
1.Install androidautotest
pip install androidautotest
Follow information indicate you have installed androidautotest successfully.
> python -m androidautotest
usage:
androidautotest --installdep
androidautotest --startasm
androidautotest --newcase <NEWCASE> --savedir <SAVEDIR>
androidautotest --casedir <CASEDIR> --device <DEVICE> --times <TIMES>
A framework to run test case for android automated test
optional arguments:
-V, --version Print version and exit
-h, --help Print this help message and exit
install dependency:
--installdep install dependency of androidautotest
start asm:
--startasm start Android Screen Monitor
create case:
--newcase <NEWCASE> New case name to create
--savedir <SAVEDIR> Path to save new case
run case:
--casedir <CASEDIR> Case path to run
--device <DEVICE> Device to switch
--times <TIMES> Times of case running
2.install requirements
python -m androidautotest --installdep
3.start Android Screen Monitor(First, connect your Android Phone with PC, and open adb debug mode), then run follow command:
python -m androidautotest --startasm
4.create a new case to start your test task with Android Phone(For example: to create a new case named 'case001').
python -m androidautotest --newcase case001 --savedir E:\AndroidTest\workspace
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. 1.If you connect one Android Phone with your PC, and run for once time, simple wirte as following
python -m androidautotest --casedir E:\AndroidTest\workspace\case001.air --device HMKNW17421063974 --times 5
2.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 -m androidautotest --casedir E:\AndroidTest\workspace\case001.air --device HMKNW17421063974 --times 5
And there are three log files you can use to analyze your test plan after run your case.
In case001.air\log\case001.log.XXX
| File Name | Description |
|---|---|
| log_case001_XXX.txt | all log output |
| serial_log_case001_XXX.txt | adb log output |
| report_case001_XXX.html | report of case run |
Metadata
Release files for androidautotest 0.0.2.33
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| androidautotest-0.0.2.33.tar.gz | 14.0 kB | Without provenance | Details for androidautotest-0.0.2.33.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| androidautotest-0.0.2.33-py3-none-any.whl | Python 3 | none | any | Details for androidautotest-0.0.2.33-py3-none-any.whl |
Total release size: 31.1 kB
Release files / androidautotest-0.0.2.33.tar.gz
| Download URL | androidautotest-0.0.2.33.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5aab687666cd9746023700bb78a7b59dd48316418d8c033c67ed817e4fed8e7
|
|
BLAKE2b-256 checksum How to use checksums |
10052a8539c3695640e1d0b4e3480190b35a24292a96cef773afde4e71036f0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.4
|
Release files / androidautotest-0.0.2.33-py3-none-any.whl
| Download URL | androidautotest-0.0.2.33-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
330ff10dde031b7d9e2f0a65dc540245676079afb763338f9bb1606751211c22
|
|
BLAKE2b-256 checksum How to use checksums |
1e06a5a71776276b16d14d7331f76b084d37a609404e45d076835f858ad6f0fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.4
|
Security for androidautotest 0.0.2.33
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.