airtestproject / airtest Goto Github PK
View Code? Open in Web Editor NEWUI Automation Framework for Games and Apps
Home Page: http://airtest.netease.com/
License: Apache License 2.0
UI Automation Framework for Games and Apps
Home Page: http://airtest.netease.com/
License: Apache License 2.0
from airtest.core.api import *
# connect an android phone with adb
connect_device("Android:///")
touch("2.png")
File "test.py", line 5, in
touch("2.png")
File "/Users/qunhe/miniconda2/lib/python2.7/site-packages/airtest/utils/logwraper.py", line 73, in wrapper
res = f(*args, **kwargs)
File "/Users/qunhe/miniconda2/lib/python2.7/site-packages/airtest/core/helper.py", line 114, in wrapper
r = f(*args, **kwargs)
File "/Users/qunhe/miniconda2/lib/python2.7/site-packages/airtest/core/api.py", line 227, in touch
G.DEVICE.touch(pos, **kwargs)
File "/Users/qunhe/miniconda2/lib/python2.7/site-packages/airtest/core/android/android.py", line 277, in touch
pos = self._touch_point_by_orientation(pos)
File "/Users/qunhe/miniconda2/lib/python2.7/site-packages/airtest/core/android/android.py", line 536, in _touch_point_by_orientation
x, y = tuple_xy
ValueError: too many values to unpack
exiting.......
打开unity官方实例roll a ball,将unity3d sdk导入,挂载pocomanager于ground对象上,然后打apk包,安装至手机。打开airtest,选择unity,发现左侧poco辅助窗没有将原本所有的ui树遍历出来。比如,player对象,或是本能展开的节点也不能展开了。
电脑4个usb接口,一台电脑连接一台手机进行自动化没问题,但是若多连一台手机,两台手机同时跑自动化脚本,另外一台就没反应。
两个bat脚本分别如下:
python -m airtest run D:\Airtest\airtest\hzy.air --device Android:///4df150757e465fdb --log D:\Airtest\airtest\4df150757e465fdb
pause
python -m airtest run D:\Airtest\airtest\hzy.air --device Android:///9aa768ee --log D:\Airtest\airtest\9aa768ee
pause
0
VR设备,录制脚本后,运行脚本,画面必须在可视范围内
[08:25:16][DEBUG]<airtest.core.android.adb> /usr/lib/python2.7/site-packages/airtest/core/android/static/adb/linux/adb devices
Traceback (most recent call last):
File "start.py", line 88, in <module>
run_case(app_name)
File "start.py", line 38, in run_case
device_pre(app_name)
File "start.py", line 13, in device_pre
connect_device(url)
File "/usr/lib/python2.7/site-packages/airtest/core/api.py", line 46, in connect_device
dev = cls(uuid, **params)
File "/usr/lib/python2.7/site-packages/airtest/core/android/android.py", line 31, in __init__
self.serialno = serialno or ADB().devices(state="device")[0][0]
File "/usr/lib/python2.7/site-packages/airtest/core/android/adb.py", line 196, in devices
output = self.cmd("devices", device=False)
File "/usr/lib/python2.7/site-packages/airtest/core/android/adb.py", line 167, in cmd
proc = self.start_cmd(cmds, device)
File "/usr/lib/python2.7/site-packages/airtest/core/android/adb.py", line 146, in start_cmd
stderr=subprocess.PIPE
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Hello!
I have a problem with construction the UI-hierarchy tree to Unity Game.
In AirtestIDE don't construction UI-hierarchy. Logs from console
All logs - log.txt
Using Airtest version: 0.0.18 if I try to launch a test on FTL it crashes with that error:
java.lang.UnsatisfiedLinkError: Native method not found: org.libsdl.app.SDLActivity.nativeSetEnv:(Ljava/lang/String;Ljava/lang/String;)V
FATAL EXCEPTION: main
Process: com.netease.open.airbase, PID: 30796
java.lang.UnsatisfiedLinkError: Native method not found: org.libsdl.app.SDLActivity.nativeSetEnv:(Ljava/lang/String;Ljava/lang/String;)V
at org.libsdl.app.SDLActivity.nativeSetEnv(Native Method)
at org.kivy.android.PythonActivity$UnpackFilesTask.onPostExecute(PythonActivity.java:169)
at org.kivy.android.PythonActivity$UnpackFilesTask.onPostExecute(PythonActivity.java:116)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(Native Method)
Which seems to happen in the test apk (not the game).
It seems to fail on all devices:
使用命令行方式执行脚本,然后生成log。html之后,加载不了图片,并出现重要卡顿;目前只能支持几百张图片的log,但是我这边需要支持大几千张图片的加载,希望能够帮助解决一下,多谢!
当pc上运行了其他手机助手时,可能会因为端口占用的问题,导致没法运行自己的adb指令:
List of devices attached
adb server version (31) doesn't match this client (39); killing...
error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:
通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 (10048)
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon
里面的中文报错信息编码被adb处理成了utf-8编码,在airtest中运行adb指令时因为decode的编码是gbk,导致抛出异常:
Traceback (most recent call last):
File "app\plugins\device\device_panel\util.py", line 25, in adbDevices
File "airtest\core\android\adb.py", line 192, in devices
File "airtest\core\android\adb.py", line 168, in cmd
UnicodeDecodeError: 'gbk' codec can't decode bytes in position 106-107: illegal
multibyte sequence
相关代码:
查看了api,发现只有swipe 和 pinch
是否可以实现swipe_press
我用命令列下指令執行時報錯了,可以幫我定位一下問題點嗎?
airtest run "path to your .air dir" --device Android:
======================================================================
ERROR: runTest (airtest.cli.runner.AirtestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/airtest/cli/runner.py", line 88, in runTest
exec(compile(code.encode("utf-8"), pyfilepath.encode(sys.getfilesystemencoding()), 'exec')) in self.scope
File "/Users/cm-nb-01007/Desktop/test.air/test.py", line 12, in <module>
poco(text="test").click()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/poco/pocofw.py", line 97, in __call__
return UIObjectProxy(self, name, **kw)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/poco/proxy.py", line 63, in __init__
self.query = build_query(name, **attrs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/poco/utils/query_util.py", line 57, in build_query
attr_val = ensure_unicode(attr_val)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/poco/utils/query_util.py", line 46, in ensure_unicode
return value.decode("utf-8")
AttributeError: 'str' object has no attribute 'decode'
大家好,感谢大家对Airtest Project的兴趣。
我们开发团队在考虑后续的开发计划,目前的开发方向包括:
希望各位同学们参与讨论,以上几项直接在对应楼层点大拇指,其余的新开楼层。
Hi all, thanks for you interest in Airtest Project !
Our dev team is making future development plan, currently including:
Please feel free to comment here. Click the thumbs up if the feature is already listed.
类似这里提到的的方法:alibaba/macaca#366
可以连续地连上不在同一直线上的三个点
Traceback (most recent call last):
File "app\plugins\device\android\android_client.py", line 167, in loadConnectedPhones
File "app\plugins\device\android\android_phone.py", line 77, in init
File "app\plugins\device\android\android_phone.py", line 103, in _initDev
File "airtest\core\android\android.py", line 463, in display_info
File "airtest\core\android\android.py", line 475, in get_display_info
File "airtest\utils\snippet.py", line 101, in ready_func
File "airtest\core\android\minicap.py", line 134, in get_display_info
File "airtest\core\android\adb.py", line 345, in shell
AdbShellError: stdout[] stderr[Segmentation fault
]
I have a very simple script like that:
start_app("com.google.android.apps.santatracker")
sleep(5.0)
swipe(v1=[0.5, 0.3], v2=[0.5, 0.8])
Give the doc here I would expect tit to swipe half the height of the screen starting at 30% of the screen and finishing at 80% of the screen (all happening at half the width, ie the middle of the screen).
Instead I can see the notification bar briefly appearing and nothing else. When I activate the debug option to show the input pointer it show the pointer quickly appearing an disapearing on the top left corner.
text("test(3") 报错 File "site-packages\pywinauto\keyboard.py", line 557, in parse_keys
KeySequenceError: )
not found
text("test(3)") 没报错 但是输入的是test3 自动把括号去掉了
def wakeUpToIdle(self):
wake()
keyevent("POWER")
scrollUI = self.poco("com.android.systemui:id/notification_stack_scroller")
scrollUI.scroll('vertical')
#get_top_activity_name()
#device().get_top_activity_name()
#current_device().get_top_activity_name()
self.device.get_top_activity_name()
上面得current_device().后面的方法感应不出来
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pocounit/case.py", line 165, in run
emitter.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pocounit/result/record.py", line 31, in start
success = self.device.start_recording()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/airtest/core/android/android.py", line 503, in start_recording
return self.recorder.start_recording(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/airtest/utils/snippet.py", line 101, in ready_func
return func(inst, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/airtest/core/android/recorder.py", line 53, in start_recording
m = re.match("start result: Record start success! File path:(.*\.mp4)", line.strip())
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 172, in match
return _compile(pattern, flags).match(string)
TypeError: cannot use a string pattern on a bytes-like object
airtest.core.android.android
中的check_app
方法,如果包不存在直接报错了,而不是返回一个False,跟文档的描述有点出入。
http://airtest.readthedocs.io/zh_CN/latest/all_module/airtest.core.android.android.html
使用场景:
想使用check_app方法判断是否已安装测试包,若已安装则清空数据,若没有安装则执行安装
if (device().check_app("packageName")==True):clear_app("packageName")
else :
proc = device().adb.start_shell("pm install /data/local/tmp/apk.apk")
sleep(3)
poco(text="安装").click()
proc.wait()
后来发现可以在pm install
命令中加入-r
参数实现强制安装解决我的需求,
但是check_app
这个方法的描述似乎还是有点偏差?
求个连续移动的接口,
for循环好难用
Crash on poco(pos=[0.376650631, 0.467089951]).
If i change poco(pos=[0.376650631, 0.467089951]) on poca('something') script it will worked.
poco(pos=[0.376650631, 0.467089951]).click()
File "poco\pocofw.py", line 100, in __call__
File "poco\proxy.py", line 65, in __init__
File "poco\utils\query_util.py", line 57, in build_query
File "poco\utils\query_util.py", line 46, in ensure_string_value
AttributeError: 'list' object has no attribute 'decode'
test@ubuntu:~/work$ airtest run main_ui3.air --device Android://127.0.0.1:5037/VS7STS6TUKAU5TBE
[08:51:01][DEBUG]<airtest.core.android.adb> /home/qatest/.local/lib/python2.7/site-packages/airtest/core/android/static/adb/linux/adb -P 5037 -s VS7STS6TUKAU5TBE wait-for-device
======================================================================
ERROR: setUpClass (airtest.cli.runner.AirtestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/qatest/.local/lib/python2.7/site-packages/airtest/cli/runner.py", line 37, in setUpClass
connect_device(dev)
File "/home/qatest/.local/lib/python2.7/site-packages/airtest/core/api.py", line 46, in connect_device
dev = cls(uuid, **params)
File "/home/qatest/.local/lib/python2.7/site-packages/airtest/core/android/android.py", line 35, in __init__
self.adb.wait_for_device()
File "/home/qatest/.local/lib/python2.7/site-packages/airtest/core/android/adb.py", line 271, in wait_for_device
proc = self.start_cmd("wait-for-device")
File "/home/qatest/.local/lib/python2.7/site-packages/airtest/core/android/adb.py", line 146, in start_cmd
stderr=subprocess.PIPE
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
----------------------------------------------------------------------
Ran 0 tests in 0.316s
FAILED (errors=1)
exiting.......
命令行,批量执行脚本,按照脚本命名可顺序执行脚本:airtest run untitled.air(脚本路径) --device Android:///手机设备号 --log log/(log存放路径)
D:\WebSafe\AndroidTest\venv\Scripts\python.exe D:/WebSafe/my-testflow/testflow/scripts/Setting_changeUserGuest.py
this testcase filename is "D:\WebSafe\my-testflow\testflow\scripts\Setting_changeUserGuest.py".
using "D:\WebSafe\my-testflow\testflow\scripts" as project root. This testcase is "PocoTestSuite"
testcase locates in "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\suite.py"
using "D:\WebSafe\my-testflow" as project root. This testcase is "Setting_changeUserGuest"
testcase locates in "D:\WebSafe\my-testflow\testflow\scripts\Setting_changeUserGuest.py"
log filename will be "D:\WebSafe\my-testflow\pocounit-results\testflow\scripts\Setting_changeUserGuest\Setting_changeUserGuest (for P200 8-1)\poco-result.log"
log filename will be "D:\WebSafe\my-testflow\pocounit-results\testflow\scripts\Setting_changeUserGuest\Setting_changeUserGuest (for P200 8-1)\metainfo.txt"
[12:39:53][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe devices
[12:39:53][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB wait-for-device
[12:39:53][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.build.version.sdk
[12:39:53][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell cat /proc/cpuinfo
[12:39:54][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.product.manufacturer
[12:39:54][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell df /data
[12:39:54][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
[12:39:54][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys meminfo
[12:40:05][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys SurfaceFlinger
[12:40:05][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.product.model
[12:40:05][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys display
[12:40:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys activity top
[12:40:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell settings get secure default_input_method
[12:40:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell ime list -a
[12:40:07][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.open.pocoservice
installed version is None, installer version is 37. force_reinstall=False
[12:40:08][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB install D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\drivers\android\lib\pocoservice-debug.apk
[12:40:11][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.open.pocoservice.test
installed version is 0, installer version is 0. force_reinstall=True
[12:40:11][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB install -r D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\drivers\android\lib\pocoservice-debug-androidTest.apk
[12:40:13][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --no-rebind tcp:19202 tcp:10080
[12:40:13][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --no-rebind tcp:11727 tcp:10081
[12:40:13][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell ps
[12:40:14][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am force-stop com.netease.open.pocoservice
[12:40:14][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am start -n com.netease.open.pocoservice/.TestActivity
[12:40:14][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am instrument -w -e debug false -e class com.netease.open.pocoservice.InstrumentedTestAsLauncher com.netease.open.pocoservice.test/android.support.test.runner.AndroidJUnitRunner
still waiting for uiautomation ready.
[12:40:17][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.nie.yosemite
[12:40:17][INFO]<airtest.core.android.yosemite> local version code is 281, installed version code is 281
[12:40:17][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell pm path com.netease.nie.yosemite
[12:40:19][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell CLASSPATH=/data/app/com.netease.nie.yosemite-0QA_3mVErBk-yinr6yR8uA==/base.apk exec app_process /system/bin com.netease.nie.yosemite.Recorder --stop-record
[12:40:20][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell pm path com.netease.nie.yosemite
[12:40:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell CLASSPATH=/data/app/com.netease.nie.yosemite-0QA_3mVErBk-yinr6yR8uA==/base.apk exec app_process -Dduration=1800 /system/bin com.netease.nie.yosemite.Recorder --start-record
[12:40:23][DEBUG]<airtest.utils.nbsp> [325818824]'Only support local recording.'
[12:40:24][DEBUG]<airtest.utils.nbsp> [325818824]'port:8686'
[12:40:24][DEBUG]<airtest.utils.nbsp> [325818824]'[OkHttp] sendRequest>>'
[12:40:24][DEBUG]<airtest.utils.nbsp> [325818824]'[OkHttp] sendRequest<<'
[12:40:24][DEBUG]<airtest.utils.nbsp> [325818824]'get current display size...'
[12:40:24][DEBUG]<airtest.utils.nbsp> [325818824]'get display size...'
D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\case.py:187: UserWarning: Fail to start result emitter: "ScreenRecorder". You can report this error to the developers or just ignore it. Error message:
"Traceback (most recent call last):
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\case.py", line 183, in run
emitter.start()
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\result\record.py", line 39, in start
self.started[udid] = self.start_device_recorder(udid, dev)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\result\record.py", line 64, in start_device_recorder
success = device.start_recording()
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\android.py", line 506, in start_recording
return self.recorder.start_recording(*args, **kwargs)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\utils\snippet.py", line 101, in ready_func
return func(inst, *args, **kwargs)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\recorder.py", line 53, in start_recording
raise RuntimeError("start recording error")
RuntimeError: start recording error
"
.format(emitter.__class__.__name__, traceback.format_exc()))
[12:40:29][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell monkey -p com.android.settings -c android.intent.category.LAUNCHER 1
[12:40:31][DEBUG]<airtest.utils.logwraper> >start_app Time used: 1.603000s
[12:40:31][DEBUG]<airtest.utils.logwraper> function: {'time_used': 1.6030001640319824, 'args': ('com.android.settings',), 'name': 'start_app', 'ret': None, 'kwargs': {}}
[12:40:34][DEBUG]<airtest.utils.logwraper> >sleep Time used: 3.007000s
[12:40:34][DEBUG]<airtest.utils.logwraper> function: {'time_used': 3.006999969482422, 'args': (3,), 'name': 'sleep', 'ret': None, 'kwargs': {}}
[12:40:43][DEBUG]<airtest.utils.logwraper> >sleep Time used: 1.001000s
[12:40:43][DEBUG]<airtest.utils.logwraper> function: {'time_used': 1.001000165939331, 'args': (1,), 'name': 'sleep', 'ret': None, 'kwargs': {}}
EndOfStream: 325818824
[12:41:02][DEBUG]<airtest.utils.logwraper> >sleep Time used: 10.001000s
[12:41:02][DEBUG]<airtest.utils.logwraper> function: {'time_used': 10.000999927520752, 'args': (10,), 'name': 'sleep', 'ret': None, 'kwargs': {}}
[12:41:02][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell input keyevent HOME
[12:41:07][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.nie.yosemite
[12:41:07][INFO]<airtest.core.android.yosemite> local version code is 281, installed version code is 281
[12:41:07][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am start -a com.netease.nie.yosemite.ACTION_IDENTIFY
[12:41:08][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell input keyevent HOME
[12:41:13][DEBUG]<airtest.utils.logwraper> >wake Time used: 10.539000s
[12:41:13][DEBUG]<airtest.utils.logwraper> function: {'time_used': 10.539000034332275, 'args': (), 'name': 'wake', 'ret': None, 'kwargs': {}}
[12:41:13][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell input keyevent POWER
[12:41:17][DEBUG]<airtest.utils.logwraper> >keyevent Time used: 4.224000s
[12:41:17][DEBUG]<airtest.utils.logwraper> function: {'time_used': 4.223999977111816, 'args': ('POWER',), 'name': 'keyevent', 'ret': None, 'kwargs': {}}
ED:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\case.py:204: UserWarning: Fail to stop result emitter: "SiteSnapshot". You can report this error to the developers or just ignore it. Error message:
"Traceback (most recent call last):
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\case.py", line 200, in run
emitter.stop()
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\result\site_snapshot.py", line 22, in stop
self.snapshot('caseEnd')
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\result\site_snapshot.py", line 28, in snapshot
self.snapshot_screen(site_id)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\result\site_snapshot.py", line 47, in snapshot_screen
b64img, fmt = self.poco.snapshot()
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\pocofw.py", line 418, in snapshot
return self.agent.screen.getScreen(width)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\drivers\android\uiautomation.py", line 78, in getScreen
b64img = self.screen.getScreen(width)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\hrpc\object_proxy.py", line 88, in __call__
return self._client__.evaluate(self.__call_no_evaluate__(remote_obj_cache, *args))
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\hrpc\client.py", line 78, in evaluate
raise RpcRemoteException(resp)
RpcRemoteException: java.lang.IllegalStateException: UiAutomation not connected!
|-- Remote Traceback --|
java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1096)
at android.app.UiAutomation.takeScreenshot(UiAutomation.java:687)
at com.netease.open.pocoservice.Screen.getScreen(Screen.java:39)
at java.lang.reflect.Method.invoke(Native Method)
at com.netease.open.hrpc.backend.RpcServer.onRequest(RpcServer.java:170)
at com.netease.open.hrpc.backend.RpcServer.serve(RpcServer.java:57)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:840)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:189)
at java.lang.Thread.run(Thread.java:764)
|-- Remote Traceback end --|
"
.format(emitter.__class__.__name__, traceback.format_exc()))
======================================================================
ERROR: runTest (__main__.Setting_changeUserGuest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:/WebSafe/my-testflow/testflow/scripts/Setting_changeUserGuest.py", line 134, in runTest
self.wakeUpToIdle()
File "D:/WebSafe/my-testflow/testflow/scripts/Setting_changeUserGuest.py", line 104, in wakeUpToIdle
scrollUI.scroll('vertical')
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 405, in scroll
return self.focus(focus1).drag_to(self.focus(focus2), duration=duration)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 371, in drag_to
target_pos = target.get_position()
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 507, in get_position
x, y = self.attr('pos')
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 39, in wrapped
return func(self, *args, **kwargs)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 620, in attr
nodes = self._do_query(multiple=False)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\proxy.py", line 755, in _do_query
self._nodes = self.poco.agent.hierarchy.select(self.query, multiple)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\utils\hrpc\hierarchy.py", line 27, in select
return self.selector.select(query, multiple)
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\hrpc\object_proxy.py", line 88, in __call__
return self._client__.evaluate(self.__call_no_evaluate__(remote_obj_cache, *args))
File "D:\WebSafe\AndroidTest\venv\lib\site-packages\hrpc\client.py", line 78, in evaluate
raise RpcRemoteException(resp)
RpcRemoteException: java.lang.IllegalStateException: UiAutomation not connected!
|-- Remote Traceback --|
java.lang.IllegalStateException: UiAutomation not connected!
at android.app.UiAutomation.throwIfNotConnectedLocked(UiAutomation.java:1096)
at android.app.UiAutomation.getRootInActiveWindow(UiAutomation.java:475)
at com.netease.open.pocoservice.Dumper.getRoot(Dumper.java:30)
at com.netease.open.pocoservice.Dumper.getRoot(Dumper.java:17)
at com.netease.open.libpoco.sdk.Selector.getRoot(Selector.java:135)
at com.netease.open.libpoco.sdk.Selector.select(Selector.java:37)
at java.lang.reflect.Method.invoke(Native Method)
at com.netease.open.hrpc.backend.RpcServer.onRequest(RpcServer.java:170)
at com.netease.open.hrpc.backend.RpcServer.serve(RpcServer.java:57)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:840)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:189)
at java.lang.Thread.run(Thread.java:764)
|-- Remote Traceback end --|
----------------------------------------------------------------------
Ran 1 test in 84.523s
FAILED (errors=1)
[12:41:18][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --remove tcp:19202
exiting.......
[12:41:18][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --remove tcp:11727
Process finished with exit code -1
支持IOS APP吗?
D:\WebSafe\AndroidTest\venv\Scripts\python.exe D:/WebSafe/my-testflow/testflow/scripts/Setting_changeUserGuest.py
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe devices
this testcase filename is "D:\WebSafe\my-testflow\testflow\scripts\Setting_changeUserGuest.py".
using "D:\WebSafe\my-testflow\testflow\scripts" as project root. This testcase is "PocoTestSuite"
testcase locates in "D:\WebSafe\AndroidTest\venv\lib\site-packages\pocounit\suite.py"
using "D:\WebSafe\my-testflow" as project root. This testcase is "Setting_changeUserGuest"
testcase locates in "D:\WebSafe\my-testflow\testflow\scripts\Setting_changeUserGuest.py"
log filename will be "D:\WebSafe\my-testflow\pocounit-results\testflow\scripts\Setting_changeUserGuest\Setting_changeUserGuest (for P200 8-1)\poco-result.log"
log filename will be "D:\WebSafe\my-testflow\pocounit-results\testflow\scripts\Setting_changeUserGuest\Setting_changeUserGuest (for P200 8-1)\metainfo.txt"
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB wait-for-device
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.build.version.sdk
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell cat /proc/cpuinfo
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.product.manufacturer
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell df /data
[12:36:06][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
[12:36:07][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys meminfo
[12:36:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys SurfaceFlinger
[12:36:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell getprop ro.product.model
[12:36:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys display
[12:36:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys activity top
[12:36:22][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell settings get secure default_input_method
[12:36:23][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell ime list -a
[12:36:24][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.open.pocoservice
installed version is 37, installer version is 37. force_reinstall=False
[12:36:25][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell dumpsys package com.netease.open.pocoservice.test
[12:36:25][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --no-rebind tcp:12554 tcp:10080
installed version is 0, installer version is 0. force_reinstall=False
[12:36:25][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB forward --no-rebind tcp:16904 tcp:10081
[12:36:25][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell ps
[12:36:25][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am force-stop com.netease.open.pocoservice
[12:36:26][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am start -n com.netease.open.pocoservice/.TestActivity
[12:36:26][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB shell am instrument -w -e debug false -e class com.netease.open.pocoservice.InstrumentedTestAsLauncher com.netease.open.pocoservice.test/android.support.test.runner.AndroidJUnitRunner
D:\WebSafe\AndroidTest\venv\lib\site-packages\poco\drivers\android\uiautomation.py:272: UserWarning: instrument server process is not alive
warnings.warn("instrument server process is not alive")
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation target package: com.netease.open.pocoservice
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS_CODE: -1
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
still waiting for uiautomation ready.
[12:36:38][DEBUG]<airtest.core.android.adb> D:\WebSafe\AndroidTest\venv\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s SS79FM99NRFQEMLB uninstall com.netease.open.pocoservice
Airtest uses adb
to do android automation. The adb
binary file here does have +x permission:
➜ mac git:(refactor) ls -l adb
-rwxr-xr-x 1 liuxin staff 2326156 1 24 11:57 adb
But if installed with pip install -U airtest
, the permission is wrong.
>>> from airtest.core.android import Android
>>> a = Android()
[10:40:32][DEBUG]<airtest.core.android.adb> /Users/liuxin/Library/Python/2.7/lib/python/site-packages/airtest/core/android/static/adb/mac/adb devices
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/liuxin/Library/Python/2.7/lib/python/site-packages/airtest/core/android/android.py", line 31, in __init__
self.serialno = serialno or ADB().devices(state="device")[0][0]
File "/Users/liuxin/Library/Python/2.7/lib/python/site-packages/airtest/core/android/adb.py", line 196, in devices
output = self.cmd("devices", device=False)
File "/Users/liuxin/Library/Python/2.7/lib/python/site-packages/airtest/core/android/adb.py", line 167, in cmd
proc = self.start_cmd(cmds, device)
File "/Users/liuxin/Library/Python/2.7/lib/python/site-packages/airtest/core/android/adb.py", line 146, in start_cmd
stderr=subprocess.PIPE
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Is it a bug of pypi? Any elegant solution to solve this issue? @felixonmars
使用airtest report
生成报告,总是报错提示没有.air/log/log.txt
使用的.air是直接由IDE编辑生成的.air文件
运行airtest report
之前有成功运行过airtest run "xxx.air" --device Android:///
命令
可是还是没有log.txt生成,请问这个log.txt是什么操作生成的?
driver = WebChrome(chrome_options=options)
WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:9222
from chrome not reachable
谷歌浏览器版本65.
This link:
It would be better to have a list on link that redirect to the various part of the airtest doc or some intro text
1.对安卓系统是否有 root要求?
2.华为、oppo等手机会杀后台程序,哪怕加入白名单也会被杀,airtest是否会被杀?
3.定位异常区域,是否有自动添加方框圆圈标识的功能?
4.能否一台控制多台终端?
5.底层点击、拖动是用的什么框架操作的? minitouch?
When running on api lvl 26 using the test.apk (for Firebase) it looks as if no touch were simulated on the device. The scripts seems to be running and the logs shows that it find the image using OpenCv but it seems to have issues simulating the inputs (I'll gather logs and a repro script + apk and update the issue)
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.