saint228 / dreammultidevices Goto Github PK
View Code? Open in Web Editor NEW基于Python/Airtest/Unittest的自动化多设备测试
基于Python/Airtest/Unittest的自动化多设备测试
[config]
packname =com.ifeng.fhdt
#packname =com.toutiao.kaililong.xjsj
activityname =
deviceslist =
apkpath =F:\helloc\pipenv_proj\warpy_airtestpoco\PIPENV_EENV_IN_PROJECT\warpy_airtestpoco-OqiTcr_4\Lib\site-packages\DreamMultiDevices\ifengfm_v7.3.3_20190401.apk
其他参数保持不变
F:\helloc\pipenv_proj\warpy_airtestpoco>PIPENV_EENV_IN_PROJECT\warpy_airtestpoco-OqiTcr_4\Scripts\pipenv.exe run python PIPENV_EENV_IN_PROJECT\warpy_airtestpoco-OqiTcr_4\Lib\site-packages\DreamMultiDevices\start.py
2020-07-11 22:21:31 测试结束
adb -s ec3c14da shell dumpsys window policy|findstr mScreenOnFully
'adb' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
'adb' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
'adb' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
ec3c14da has been ScreenOFF
通过搜索错误信息,找到代码位置 ScreenOFF.py
import sys,os,time
def setScreenOFF(device):
platform = sys.platform
command1 = command2 = ""
# setScreenON(device)
if platform == "win32":
command1 = "adb -s {} shell dumpsys window policy|findstr mScreenOnFully".format(device)
else:
command1 = "adb -s {} shell dumpsys window policy|grep mScreenOnFully".format(device)
print(command1)
...
因为 DreamMultiDevice 库依赖于 airtest,建议直接取 airtest 自带的 adb
修改文件 ScreenOFF.py
from airtest.core.android.adb import ADB
adb = ADB().adb_path
if platform == "win32":
command1 = adb + " -s {} shell dumpsys window policy|findstr mScreenOnFully".format(device)
else:
command1 = adb + " -s {} shell dumpsys window policy|grep mScreenOnFully".format(device)
...
command2 = adb + " -s {} shell input keyevent 26".format(device)
...
我们安卓APP是用原生+WEEX写的,无法抓取fps数据
Collecting DreamMultiDevices
Using cached https://files.pythonhosted.org/packages/d6/65/9e68e933825dba8f0fdaf9284e0ef3f3506c8dff4cff3e0cfdd30dd12084/DreamMultiDevices-1.11.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "c:\users\admini~1\appdata\local\temp\pip-install-ornoym\DreamMultiDevices\setup.py", line 8, in
with open("README.md", "r",encoding='utf-8') as fh:
TypeError: 'encoding' is an invalid keyword argument for this function
麻烦看下这个encoding 字段 出了啥问题了吗?
from airtest.core.api import *
connect_device('Android://127.0.0.1:5037/127.0.0.1:62001')
if exists(Template(r"..\img\tpl1566374671903.png", record_pos=(0.077, -0.149), resolution=(2340, 1080))):
print('sdf')
报错如下:
Traceback (most recent call last):
File "F:/lyydezdh/GFtest/sss.py", line 8, in
if exists(Template(r"..\img\tpl1566374671903.png", record_pos=(0.077, -0.149), resolution=(2340, 1080))):
File "D:\Python\Python37\lib\site-packages\airtest\utils\logwraper.py", line 72, in wrapper
res = f(*args, **kwargs)
File "D:\Python\Python37\lib\site-packages\airtest\core\api.py", line 411, in exists
pos = loop_find(v, timeout=ST.FIND_TIMEOUT_TMP)
File "D:\Python\Python37\lib\site-packages\airtest\utils\logwraper.py", line 72, in wrapper
res = f(*args, **kwargs)
File "D:\Python\Python37\lib\site-packages\airtest\core\cv.py", line 59, in loop_find
screen = G.DEVICE.snapshot(filename=None)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\android.py", line 218, in snapshot
screen = self.minicap.get_frame_from_stream()
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 24, in wrapper
return func(inst, *args, **kwargs)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 325, in get_frame_from_stream
self.frame_gen = self.get_stream()
File "D:\Python\Python37\lib\site-packages\airtest\utils\snippet.py", line 106, in ready_func
return func(inst, *args, **kwargs)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 219, in get_stream
stopped = next(gen)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 233, in _get_stream
proc, nbsp, localport = self._setup_stream_server(lazy=lazy)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 289, in _setup_stream_server
params, display_info = self._get_params()
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 185, in get_params
display_info = self.ori_function()
File "D:\Python\Python37\lib\site-packages\airtest\core\android\android.py", line 546, in get_display_info
display_info = self.minicap.get_display_info()
File "D:\Python\Python37\lib\site-packages\airtest\utils\snippet.py", line 106, in ready_func
return func(inst, *args, **kwargs)
File "D:\Python\Python37\lib\site-packages\airtest\core\android\minicap.py", line 149, in get_display_info
display_info = json.loads(display_info)
File "D:\Python\Python37\lib\json_init.py", line 348, in loads
return _default_decoder.decode(s)
File "D:\Python\Python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[04:25:09][DEBUG]<airtest.core.android.adb> D:\Python\Python37\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s 127.0.0.1:62001 forward --remove tcp:12601
[04:25:09][DEBUG]<airtest.core.android.rotation> orientationWatcher has ended
Hi,
Sorry for using English because I don't know much as Chinese, I'm really interesting about your framework, it would be a big help for me when performing the automation testing.
But I'm got a trouble with the config.ini file, so could you please help me to clarify some point as below:
1 - Does it should work when we using ADB via USB?
2 - If the application already installed in device, do we need the APK path?
I really appreciate your help and really exciting your framework.
Thanks a lot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.