Poco
Poco copied to clipboard
在命令行执行脚本,无法运行poco相关指令
描述问题bug 在命令行通过python运行脚本,无法执行poco(Android)相关命令,报错如下:
E:\Airtest_Pack>"E:\python-3.7\python.exe" -u "E:\AirtestIDE\sample\custom_launcher.py" "E:\Airtest_Pack\PackTest.air"
do not connect device
do not save log
custom setup
[17:42:53][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe devices
[17:42:54][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe devices
[17:42:54][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K wait-for-device
[17:42:55][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K shell getprop ro.build.version.sdk
[17:42:55][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K shell dumpsys activity top
[17:42:56][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K shell dumpsys package com.netease.open.pocoservice
[17:42:56][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K forward --no-rebind tcp:13563 tcp:10080
[17:42:57][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K forward --no-rebind tcp:15602 tcp:10081
[17:42:57][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K shell monkey -p com.google.android.apps.photos -c android.intent.category.LAUNCHER 1
[17:43:09][ERROR]<airtest.core.api> Traceback (most recent call last):
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 26, in wrapped
proxy.wait_for_appearance(timeout=proxy.poco._pre_action_wait_for_appearance)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\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 "Show Navigation Drawer""
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\cli\runner.py", line 70, in runTest
exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
File "E:\Airtest_Pack\PackTest.air\PackTest.py", line 14, in <module>
poco("Show Navigation Drawer").click()
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 29, in wrapped
raise e
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 23, in wrapped
return func(proxy, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 332, in click
pos_in_percentage = self.get_position(focus)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 72, in wrapped
return func(proxy, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 613, in get_position
pos = list(map(float, self.attr('pos')))
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 39, in wrapped
return func(self, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 734, in attr
nodes = self._do_query(multiple=False)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 874, in _do_query
raise PocoNoSuchNodeException(self)
poco.exceptions.PocoNoSuchNodeException: Cannot find any visible node by query UIObjectProxy of "Show Navigation Drawer"
custom tearDown
======================================================================
ERROR: runTest (__main__.CustomCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 26, in wrapped
proxy.wait_for_appearance(timeout=proxy.poco._pre_action_wait_for_appearance)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\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 "Show Navigation Drawer""
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\cli\runner.py", line 73, in runTest
six.reraise(*sys.exc_info())
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\six.py", line 719, in reraise
raise value
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\cli\runner.py", line 70, in runTest
exec(compile(code.encode("utf-8"), pyfilepath, 'exec'), self.scope)
File "E:\Airtest_Pack\PackTest.air\PackTest.py", line 14, in <module>
poco("Show Navigation Drawer").click()
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 29, in wrapped
raise e
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 23, in wrapped
return func(proxy, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 332, in click
pos_in_percentage = self.get_position(focus)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 72, in wrapped
return func(proxy, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 613, in get_position
pos = list(map(float, self.attr('pos')))
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 39, in wrapped
return func(self, *args, **kwargs)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 734, in attr
nodes = self._do_query(multiple=False)
File "C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\poco\proxy.py", line 874, in _do_query
raise PocoNoSuchNodeException(self)
poco.exceptions.PocoNoSuchNodeException: Cannot find any visible node by query UIObjectProxy of "Show Navigation Drawer"
----------------------------------------------------------------------
Ran 1 test in 15.723s
FAILED (errors=1)
[17:43:09][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K forward --remove tcp:13563
[17:43:09][DEBUG]<airtest.core.android.adb> C:\Users\huchengbo01\AppData\Roaming\Python\Python37\site-packages\airtest\core\android\static\adb\windows\adb.exe -s HA1KZ12K forward --remove tcp:15602
复现步骤
- 关闭AirtestIDE
- 在命令行启动脚本("E:\python-3.7\python.exe" -u "E:\AirtestIDE\sample\custom_launcher.py" "E:\Airtest_Pack\PackTest.air")
- 和poco相关的指令无法执行
预期效果 关闭AirtestIDE同样可以执行poco相关的指令,或者启动poco service的方法
python 版本: python3.7
poco 版本: 1.0.69
pocoui 1.0.85
设备:
- 型号: 平板
- 系统: Android 12
其他相关环境信息 1:打开AirtestIDE,打开poco选择android,等待设备的poco service启动即可正常运行脚本 2:重启设备第一次运行脚本可以poco可以正常启动 3:Android 11系统的手机可以多次运行脚本 4:使用adb命令:adb shell am force-stop com.netease.open.pocoservice清除掉pocoservice后台, 再次运行脚本时候会启动pocoservice,之后脚本可以正常运行。 脚本内容: `# -- encoding=utf8 -- author = "sofia"
from airtest.core.api import *
auto_setup(file)
from poco.drivers.android.uiautomation import AndroidUiautomationPoco poco = AndroidUiautomationPoco(use_airtest_input=True, screenshot_each_action=False)
start_app("com.google.android.apps.photos") poco("Show Navigation Drawer").click()`