openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.61k stars 1.41k forks source link

set_text中的内容长度超过302个字符后,报网络超时 #1037

Open peidachang opened 1 month ago

peidachang commented 1 month ago

手机型号:HONOR 50 android:14 uiautomator2的版本号:3.2.4

具体代码:

import uiautomator2 as u2
d = u2.connect('192.168.2.101:39863')
d.debug = True
message = "uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。uiautomator2 是一个基于UIAutomator的自动化测试框架。"
d(resourceId="com.tencent.mm:id/bkk").click()
d.set_input_ime(True)

d(resourceId="com.tencent.mm:id/bkk").set_text(message, 30)

错误信息: Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 790, in urlopen response = self._make_request( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 536, in _make_request response = conn.getresponse() File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 461, in getresponse httplib_response = super().getresponse() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1375, in getresponse response.begin() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 844, in urlopen retries = retries.increment( File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 470, in increment raise reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.10/site-packages/urllib3/util/util.py", line 38, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 790, in urlopen response = self._make_request( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 536, in _make_request response = conn.getresponse() File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 461, in getresponse httplib_response = super().getresponse() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1375, in getresponse response.begin() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/Cellar/python@3.10/3.10.15/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uiautomator2/core.py", line 104, in _http_request r = requests.request(method, url, json=data, timeout=timeout) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uiautomator2/core.py", line 270, in jsonrpc_call return _jsonrpc_call(self._dev, method, params, timeout, self._debug) File "/usr/local/lib/python3.10/site-packages/uiautomator2/core.py", line 132, in _jsonrpc_call r = _http_request(dev, "POST", "/jsonrpc/0", payload, timeout=timeout, print_request=print_request) File "/usr/local/lib/python3.10/site-packages/uiautomator2/core.py", line 117, in _http_request raise HTTPError(f"HTTP request failed: {e}") from e uiautomator2.exceptions.HTTPError: HTTP request failed: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

codeskyblue commented 1 month ago