Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Working on autotesting using
airtest
and
poco
recently.Due to that
Android-Toast
is not supported,I want to use
uiautomator2
in my testing project.Installation as well as the initiation come out to be successful.But I got:
uiautomator2.exceptions.GatewayError: uiautomator2.GatewayError(gateway error, time used 0.0s)`
when I call:
import uiautomator2 as u2
d = u2.connect_usb()
d.toast.show("uiautomator2", 3)
The full stack trace:
[W 200916 11:28:57 __init__:203] atx-agent has something wrong, auto recovering
[D 200916 11:28:57 __init__:286] device 364748377d05 is online
[I 200916 11:28:58 init:155] uiautomator2 version: 2.11.3
[I 200916 11:28:58 init:352] Install minicap, minitouch
[I 200916 11:29:01 init:367] Install com.github.uiautomator, com.github.uiautomator.test 2.3.1
[I 200916 11:29:09 init:332] - app-uiautomator.apk installed
[I 200916 11:29:14 init:332] - app-uiautomator-test.apk installed
[I 200916 11:29:14 init:340] Install atx-agent 0.9.5
[I 200916 11:29:15 init:377] Check atx-agent version
Successfully init AdbDevice(serial=364748377d05)
<uiautomator2.Device object at 0x0C59D7D0>
[D 200916 11:29:17 __init__:598] kill process(ps): uiautomator
[D 200916 11:29:20 __init__:617] uiautomator-v2 is starting ... left: 40.0s
[D 200916 11:29:21 __init__:617] uiautomator-v2 is starting ... left: 39.0s
[D 200916 11:29:22 __init__:617] uiautomator-v2 is starting ... left: 38.0s
[D 200916 11:29:23 __init__:617] uiautomator-v2 is starting ... left: 37.0s
[D 200916 11:29:24 __init__:617] uiautomator-v2 is starting ... left: 35.9s
[I 200916 11:29:25 __init__:570] restart-uiautomator since "uiautomator2.GatewayError(gateway error, time used 0.0s)"
[D 200916 11:29:25 __init__:598] kill process(ps): uiautomator
[D 200916 11:29:27 __init__:652] grant permissions
[D 200916 11:29:32 __init__:617] uiautomator-v2 is starting ... left: 40.0s
[D 200916 11:29:33 __init__:617] uiautomator-v2 is starting ... left: 39.0s
[D 200916 11:29:34 __init__:617] uiautomator-v2 is starting ... left: 38.0s
[D 200916 11:29:35 __init__:617] uiautomator-v2 is starting ... left: 37.0s
[D 200916 11:29:36 __init__:617] uiautomator-v2 is starting ... left: 35.9s
Ran 1 test in 42.147s
FAILED (errors=1)
[11:29:37][DEBUG]<airtest.core.android.adb> F:\python\lib\site-packages\airtest\core\android\static\adb\windows\adb.exe -s 364748377d05 forward --remove tcp:14076
Error
Traceback (most recent call last):
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 441, in _jsonrpc_retry_call
return self._jsonrpc_call(*args, **kwargs)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 478, in _jsonrpc_call
(time.time() - request_start))
uiautomator2.exceptions.GatewayError: uiautomator2.GatewayError(gateway error, time used 0.0s)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\python\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "F:\python\lib\unittest\case.py", line 611, in run
self.setUp()
File "F:\PythonPrj\pycharm_airtest_iesapp\testcase\testcases_qjdl.py", line 111, in setUp
d.toast.show("uiautomator2", 3)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 1201, in show
return obj.jsonrpc.makeToast(text, duration * 1000)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 435, in __call__
http_timeout)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 445, in _jsonrpc_retry_call
self.reset_uiautomator(str(e)) # uiautomator可能出问题了,强制重启一下
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 589, in reset_uiautomator
depth=depth + 1)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 589, in reset_uiautomator
depth=depth + 1)
File "F:\python\lib\site-packages\uiautomator2\__init__.py", line 566, in reset_uiautomator
"adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner",
OSError: [WinError adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner] uiautomator2.GatewayError(gateway error, time used 0.0s): 'https://github.com/openatx/uiautomator2/wiki/Common-issues'
Seems uiautomator2 cannot be started.New to python3 and uiautomator2. Can anyone help?
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.