51Testing软件测试论坛

标题: airtest 在 oppo 真机上遇到麻烦,求助? [打印本页]

作者: 测试积点老人    时间: 2019-8-5 10:07
标题: airtest 在 oppo 真机上遇到麻烦,求助?
刚开始学习airtest,遇到点小问题
问题是,第二步点击安装之后,第三步就找不到控件id了
看了下日志,发现PocoService 被杀了,然后在手机上给进程加了一个锁,跑的时候还是被杀掉了,不知道是不是这个原因?
哪位小伙伴遇到过类似问题?
环境:
oppoA57 android6.0.1

代码:
  1. import threading
  2. from airtest.core.api import *
  3. from airtest.core.android.android import *
  4. from poco.drivers.android.uiautomation import AndroidUiautomationPoco

  5. android = Android()
  6. poco = AndroidUiautomationPoco(force_restart=False)
  7. APP_NAME = 'com.xxxx.yyyy'
  8. INSTALL_PATH = "F:\\ggg\\xxxx_443.apk"  # 路径带中文不能识别

  9. class PermissionThread(threading.Thread):   # 处理OPPO权限
  10.     def __init__(self):
  11.         threading.Thread.__init__(self)

  12.     def run(self):
  13.         install_permission()

  14. def install_permission():
  15.     while True:     # 第一步 输入oppo账号的密码
  16.         try:
  17.             poco("com.coloros.safecenter:id/et_login_passwd_edit").click()
  18.             text("123456")
  19.             poco("android:id/button1").click()
  20.             break
  21.         except:
  22.             pass
  23.         finally:
  24.             sleep(5)
  25.     while True:     #  第二步 在权限页面确认页面点击安装按钮,找不到id,所以用图片识别
  26.         try:
  27.             touch(Template(r"tpl1544600876786.png", record_pos=(0.215, 0.811), resolution=(720, 1280)))
  28.             break
  29.         except:
  30.             pass
  31.         finally:
  32.             sleep(5)
  33.     while True:     #  第三步 安装完成后,点击完成按钮
  34.         try:
  35.             poco("com.android.packageinstaller:id/bottom_button_one").click()
  36.             break
  37.         except:
  38.             pass
  39.         finally:
  40.             sleep(5)

  41. def install_bao():
  42.     android.uninstall_app(APP_NAME)
  43.     thread = PermissionThread()
  44.     thread.start()
  45.     android.install_app(INSTALL_PATH)

  46. if __name__ == '__main__':
  47.     connect_device("Android:///")
  48.     wake()  # 唤醒
  49.     home()  # 回到首页
  50.     install_bao()   # 安装apk
复制代码
日志:
  1. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'PID: 14560'
  2. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: Using projection 720x1280@720x1280/0'
  3. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:240) Creating SurfaceComposerClient'
  4. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:243) Performing SurfaceComposerClient init check'
  5. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:250) Creating virtual display'
  6. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:256) Creating buffer queue'
  7. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:261) Creating CPU consumer'
  8. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:265) Creating frame waiter'
  9. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (external/MY_minicap/src/minicap_23.cpp:269) Publishing virtual display'
  10. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 2766852 bytes for JPG encoder'
  11. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (/home/lxn3032/minicap_for_ide/jni/minicap/minicap.cpp:473) Server start'
  12. [08:12:41][DEBUG]<airtest.utils.nbsp> [minicap_server]b'INFO: (/home/lxn3032/minicap_for_ide/jni/minicap/minicap.cpp:475) New client connection'
  13. [08:12:41][DEBUG]<airtest.core.android.minicap> (1, 24, 14560, 720, 1280, 720, 1280, 0, 2)
  14. [08:12:41][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -i ; echo ---$?---
  15. [08:12:41][DEBUG]<airtest.core.api> try match with _find_template
  16. [08:12:41][DEBUG]<airtest.aircv.template> threshold=0.7, result={'result': (515, 1224), 'rectangle': ((361, 1192), (361, 1256), (669, 1256), (669, 1192)), 'confidence': 0.9994706511497498}
  17. [08:12:41][DEBUG]<airtest.core.api> match result: {'result': (515, 1224), 'rectangle': ((361, 1192), (361, 1256), (669, 1256), (669, 1192)), 'confidence': 0.9994706511497498}
  18. [08:12:41][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell getprop ro.product.cpu.abi
  19. [08:12:41][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell getprop ro.build.version.sdk
  20. [08:12:41][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell ls /data/local/tmp/minitouch ; echo ---$?---
  21. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell ls -l /data/local/tmp/minitouch ; echo ---$?---
  22. [08:12:42][DEBUG]<airtest.core.android.minitouch> install_minitouch skipped
  23. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -i ; echo ---$?---
  24. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --no-rebind tcp:13147 localabstract:minitouch_13147
  25. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell /data/local/tmp/minitouch -n 'minitouch_13147' 2>&1
  26. [08:12:42][DEBUG]<airtest.utils.nbsp> [minitouch_server]b'Note: device /dev/input/mice is not supported by libevdev'
  27. [08:12:42][DEBUG]<airtest.utils.nbsp> [minitouch_server]b'Type B touch device touchpanel (720x1280 with 10 contacts) detected on /dev/input/event1 (score 21969)'
  28. [08:12:42][DEBUG]<airtest.utils.nbsp> [minitouch_server]b'Connection established'
  29. [08:12:42][DEBUG]<airtest.core.android.minitouch> minitouch header:b'v 1\n^ 10 720 1280 0\n$ 14586\n'
  30. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:14771
  31. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:16847
  32. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:13870
  33. [08:12:42][DEBUG]<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:13147
  34. [08:12:42][DEBUG]<airtest.core.android.rotation> orientationWatcher has ended
复制代码



作者: qqq911    时间: 2019-8-6 10:13
把管家什么的都关了。




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2