AirtestProject / Poco

A cross-engine test automation framework based on UI inspection
http://airtest.netease.com/
Apache License 2.0
1.77k stars 318 forks source link

pocoui相关 小程序UI脚本运行时有时候会定位不到元素报超时,有时间又没问题,已添加了等待时间方式了,排除页面加载时间问题。可看具体描述,多谢。 #471

Open Li96224 opened 3 years ago

Li96224 commented 3 years ago

运行环境: macos10.14.6,python 3.9 , airtest 1.2.0 ,pocoui 1.0.82,手机华为mote10,手机系统android10,Android Debug Bridge version 1.0.41 Version 29.0.6-6198805,微信小程序:"超级猩猩" " 问题描述: 在运行脚本时微信切入小程序页面后,定位不到小程序页面元素,报了超时错误。但是该场景问题偶尔会成功,有时间就可以定位到,不会报错。经过确认不是页面加载太快或太慢的原因,因为已经加了等待。同时手机对pocoservice已经开启启动权限。

代码截图: image image

报错信息: 报错: [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 wait-for-device [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell getprop ro.build.version.sdk [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys activity top [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys package com.netease.open.pocoservice [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys package com.netease.open.pocoservice.test [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 forward --no-rebind tcp:17413 tcp:10080 [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 forward --no-rebind tcp:12023 tcp:10081 [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell ps -A |echo $(grep -E com.github.uiautomator) [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell am force-stop com.netease.open.pocoservice [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell am start -n com.netease.open.pocoservice/.TestActivity [11:04:20][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell am instrument -w -e debug false -e class com.netease.open.pocoservice.InstrumentedTestAsLauncher com.netease.open.pocoservice.test/android.support.test.runner.AndroidJUnitRunner [11:04:22][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell monkey -p com.tencent.mm -c android.intent.category.LAUNCHER 1 [11:04:29][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell ls -l /data/local/tmp/rotationwatcher.jar [11:04:29][DEBUG] install_rotationwatcher skipped [11:04:29][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell app_process -Djava.class.path=/data/local/tmp/rotationwatcher.jar /data/local/tmp com.example.rotationwatcher.Main [11:04:29][DEBUG] [rotation_server]b'0' [11:04:31][INFO] update orientation None->0 [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys display [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys SurfaceFlinger [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell getevent -p [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell ls -l /data/local/tmp/maxpresent.jar [11:04:31][DEBUG] install_maxtouch skipped [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys display [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell dumpsys SurfaceFlinger [11:04:31][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell getevent -p [11:04:32][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 forward --no-rebind tcp:12512 localabstract:maxpresent_12512 [11:04:32][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell app_process -Djava.class.path=/data/local/tmp/maxpresent.jar /data/local/tmp com.netease.maxpresent.MaxPresent socket maxpresent_12512 [11:04:32][DEBUG] [airtouch_server]b'Metrics Message : 2560.0=====1440.0' [11:04:32][DEBUG] [airtouch_server]b'Start local socket (maxpresent_12512) server...' [11:06:50][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 shell am force-stop com.tencent.mm

Error Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 59, in testPartExecutor yield File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 593, in run self._callTestMethod(testMethod) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 550, in _callTestMethod method() File "/Users/supermonkey/AirtestProject/demo.py", line 125, in test_case self.assertEqual(HomePage().select_good_lessons_get_text(poco=self.poco),"精选好课") File "/Users/supermonkey/AirtestProject/demo.py", line 88, in select_good_lessons_get_text init_element(self.select_good_lessons,poco).wait_for_appearance() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/poco/proxy.py", line 681, in wait_for_appearance raise PocoTargetTimeout('appearance', self) poco.exceptions.PocoTargetTimeout: Waiting timeout for appearance of "UIObjectProxy of "text=精选好课""

Assertion failed 只执行一次

Ran 1 test in 150.926s

FAILED (errors=1) [11:06:51][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 forward --remove tcp:17413 [11:06:51][DEBUG] /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/airtest/core/android/static/adb/mac/adb -P 5037 -s UYT5T18524015578 forward --remove tcp:12512 [11:06:51][DEBUG] [rotation_server]b'' [11:06:51][DEBUG] [airtouch_server]b''

Process finished with exit code 1

Assertion failed

Assertion failed

nianwu commented 3 years ago

当 airtestIDE 打开的时候, 会更新 poco 辅助窗 中的 节点树, 这种情况下 可以找到文字 如果关闭了 airteset IDE 就会出现找不到文字的情况, 目前需要找到一种方法去模拟 airtestIDE 的这个操作, 但是没有找到