测试积点老人 发表于 2019-8-5 10:07:14

airtest 在 oppo 真机上遇到麻烦,求助?

刚开始学习airtest,遇到点小问题
问题是,第二步点击安装之后,第三步就找不到控件id了
看了下日志,发现PocoService 被杀了,然后在手机上给进程加了一个锁,跑的时候还是被杀掉了,不知道是不是这个原因?
哪位小伙伴遇到过类似问题?
环境:
oppoA57 android6.0.1

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

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

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

    def run(self):
      install_permission()

def install_permission():
    while True:   # 第一步 输入oppo账号的密码
      try:
            poco("com.coloros.safecenter:id/et_login_passwd_edit").click()
            text("123456")
            poco("android:id/button1").click()
            break
      except:
            pass
      finally:
            sleep(5)
    while True:   #第二步 在权限页面确认页面点击安装按钮,找不到id,所以用图片识别
      try:
            touch(Template(r"tpl1544600876786.png", record_pos=(0.215, 0.811), resolution=(720, 1280)))
            break
      except:
            pass
      finally:
            sleep(5)
    while True:   #第三步 安装完成后,点击完成按钮
      try:
            poco("com.android.packageinstaller:id/bottom_button_one").click()
            break
      except:
            pass
      finally:
            sleep(5)

def install_bao():
    android.uninstall_app(APP_NAME)
    thread = PermissionThread()
    thread.start()
    android.install_app(INSTALL_PATH)

if __name__ == '__main__':
    connect_device("Android:///")
    wake()# 唤醒
    home()# 回到首页
    install_bao()   # 安装apk日志:
<airtest.utils.nbsp> b'PID: 14560'
<airtest.utils.nbsp> b'INFO: Using projection 720x1280@720x1280/0'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:240) Creating SurfaceComposerClient'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:243) Performing SurfaceComposerClient init check'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:250) Creating virtual display'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:256) Creating buffer queue'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:261) Creating CPU consumer'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:265) Creating frame waiter'
<airtest.utils.nbsp> b'INFO: (external/MY_minicap/src/minicap_23.cpp:269) Publishing virtual display'
<airtest.utils.nbsp> b'INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 2766852 bytes for JPG encoder'
<airtest.utils.nbsp> b'INFO: (/home/lxn3032/minicap_for_ide/jni/minicap/minicap.cpp:473) Server start'
<airtest.utils.nbsp> b'INFO: (/home/lxn3032/minicap_for_ide/jni/minicap/minicap.cpp:475) New client connection'
<airtest.core.android.minicap> (1, 24, 14560, 720, 1280, 720, 1280, 0, 2)
<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 ---$?---
<airtest.core.api> try match with _find_template
<airtest.aircv.template> threshold=0.7, result={'result': (515, 1224), 'rectangle': ((361, 1192), (361, 1256), (669, 1256), (669, 1192)), 'confidence': 0.9994706511497498}
<airtest.core.api> match result: {'result': (515, 1224), 'rectangle': ((361, 1192), (361, 1256), (669, 1256), (669, 1192)), 'confidence': 0.9994706511497498}
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell getprop ro.product.cpu.abi
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 shell getprop ro.build.version.sdk
<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 ---$?---
<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 ---$?---
<airtest.core.android.minitouch> install_minitouch skipped
<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 ---$?---
<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
<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
<airtest.utils.nbsp> b'Note: device /dev/input/mice is not supported by libevdev'
<airtest.utils.nbsp> b'Type B touch device touchpanel (720x1280 with 10 contacts) detected on /dev/input/event1 (score 21969)'
<airtest.utils.nbsp> b'Connection established'
<airtest.core.android.minitouch> minitouch header:b'v 1\n^ 10 720 1280 0\n$ 14586\n'
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:14771
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:16847
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:13870
<airtest.core.android.adb> f:\huigui_app\airtest\airtest\core\android\static\adb\windows\adb.exe -s 4d986a30 forward --remove tcp:13147
<airtest.core.android.rotation> orientationWatcher has ended

qqq911 发表于 2019-8-6 10:13:44

把管家什么的都关了。
页: [1]
查看完整版本: airtest 在 oppo 真机上遇到麻烦,求助?