AirtestProject / AirtestProject/AirtestIDE
poco代码运行一段时间后出现超时RpcTimeoutError报错问题
- Dominant language
- No language data
- Stars
- 236
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
附上整段代码,log在代码结尾处后面:
# -*- encoding=utf8 -*-
__author__ = "Administrator"
from airtest.core.api import *
auto_setup(__file__)
from poco.drivers.unity3d import UnityPoco
poco = UnityPoco()
poco("ctrl_btn_change_dress").click([1,1])
def main():
with poco.freeze() as frozen_poco:
kind_list = frozen_poco("cmp_list_clothes_kind").children()
for i in range(0, 5):
kind_btn = kind_list[i]
kind_btn.click((0.5, 0.5))
test_a_class()
poco.click((0.5, 0.5)) # 点击屏幕中间
poco("btn_suit").click([1,1])
test_a_class()
#判断一下能否点击,判断依据是按钮的框是不是在列表框内,左右不用判断,上下能包围住就可以
def can_clothes_click(clothes_btn):
with poco.freeze() as frozen_poco:
bounds = frozen_poco("cmp_list_clothes").get_bounds()
btn_bounds = clothes_btn.get_bounds()
return btn_bounds[0] >= bounds[0] and btn_bounds[2] <= bounds[2]
#获取中心点
def get_center(UIObj):
size = UIObj.get_size()
pos = UIObj.get_position()
return [ pos[0] + size[0] * 0.5, pos[1] + size[1] * 0.5 ]
#测试一类,可能带TAB
def test_a_class():
with poco.freeze() as frozen_poco:
tab_list = frozen_poco("cmp_list_tab")
if tab_list.exists():
for tab_btn in tab_list.children():
tab_btn.click((0.5, 0.5))
basic_test()
else:
basic_test()
#测试当前类别的所有
def basic_test():
poco = UnityPoco()
with poco.freeze() as frozen_poco:
list_obj = frozen_poco("cmp_list_clothes")
if not list_obj.exists() or len(list_obj.children()) == 0:
return
#已经测试过的名字放这里
history = []
clothes_list = list_obj.children()
start = get_center(clothes_list[3])
end = get_center(clothes_list[0])
if len(clothes_list) < 4:
for clothes_btn in clothes_list:
clothes_btn.click((0.5, 0.5))
else:
need_continue = True
while need_continue:
need_continue = False
with poco.freeze() as frozen_poco:
clothes_list = frozen_poco("cmp_list_clothes").children()
for clothes_btn in clothes_list:
clothes_name = clothes_btn.child("txt_name").attr("text")
if can_clothes_click(clothes_btn):
print(clothes_name + " can click")
if clothes_name not in history:
need_continue = True # 如果有测试,就可能还有下一次
clothes_btn.click((0.5, 0.5))
history.append(clothes_name)
print(clothes_name + " click")
# 滑动
if need_continue:
poco.swipe(start, end, duration=0.5)
main()
poco("cmp_btn_close").click
poco("btn_right").click
附上log:
ERROR: runTest (app.widgets.code_runner.ide_launcher.AirtestIDECase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "airtest\cli\runner.py", line 65, in runTest
File "site-packages\six.py", line 693, in reraise
File "airtest\cli\runner.py", line 61, in runTest
File "E:\zero_client_autotest\zero_client_autotest\test_clothes.air\test_clothes.py", line 90, in
main()
File "E:\zero_client_autotest\zero_client_autotest\test_clothes.air\test_clothes.py", line 18, in main
test_a_class()
File "E:\zero_client_autotest\zero_client_autotest\test_clothes.air\test_clothes.py", line 44, in test_a_class
basic_test()
File "E:\zero_client_autotest\zero_client_autotest\test_clothes.air\test_clothes.py", line 76, in basic_test
if can_clothes_click(clothes_btn):
File "E:\zero_client_autotest\zero_client_autotest\test_clothes.air\test_clothes.py", line 25, in can_clothes_click
with poco.freeze() as frozen_poco:
File "F:\airtest\AirtestIDE\poco\pocofw.py", line 199, in freeze
return FrozenPoco()
File "F:\airtest\AirtestIDE\poco\pocofw.py", line 182, in __init__
hierarchy_dict = this.agent.hierarchy.dump()
File "F:\airtest\AirtestIDE\poco\freezeui\hierarchy.py", line 69, in dump
return self.dumper.dumpHierarchy()
File "F:\airtest\AirtestIDE\poco\utils\simplerpc\utils.py", line 13, in new_func
ret, err = cb.wait(timeout=30)
File "F:\airtest\AirtestIDE\poco\utils\simplerpc\simplerpc.py", line 78, in wait
raise RpcTimeoutError(self)
poco.utils.simplerpc.simplerpc.RpcTimeoutError: (rid=3022b21e-3061-4949-a927-f19ae66b8b49) (connection="tcp://127.0.0.1:17213")
----------------------------------------------------------------------
Ran 1 test in 507.671s
FAILED (errors=1)
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:17213
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:17571
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:17397
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:16535
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:19736
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:14965
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:14731
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:17433
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:14723
[08:02:57][DEBUG] F:\airtest\AirtestIDE\airtest\core\android\static\adb\windows\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:14413
[08:02:57][DEBUG] orientationWatcher has ended
[Finished]
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.