首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >启用USB tethering后,Python uiautomator崩溃

启用USB tethering后,Python uiautomator崩溃
EN

Stack Overflow用户
提问于 2019-06-14 20:04:31
回答 1查看 121关注 0票数 0

我正在尝试使用uiautomator在Android上启用USB tethering。但是,在打开USB tethering之后,它将抛出urllib3.exceptions.ProtocolError。你知道怎么修复它吗?谢谢!

我写这个错误只是为了捕捉这个错误,但它会在崩溃时自动禁用USB tethering。这意味着我仍然无法打开USB tethering。

代码语言:javascript
复制
import uiautomator
d = uiautomator.Device('serial number', 5555)
d(text='USB tethering').right(className='android.widget.Switch').click()
print('succeed')
代码语言:javascript
复制
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1321, in getresponse
    response.begin()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 265, 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 "C:\Users\user\Downloads\test.py", line 1009, in switch_tethered
    d(text='USB tethering').right(className='android.widget.Switch').click()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomator\__init__.py", line 76, in __call__
    return self.func(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomator\__init__.py", line 971, in _click
    return self.jsonrpc.click(self.selector)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomator\__init__.py", line 443, in wrapper
    return _JsonRPCMethod(url, method, timeout, False)(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomator\__init__.py", line 438, in wrapper
    return _method_obj(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\uiautomator\__init__.py", line 119, in __call__
    timeout=self.timeout)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\poolmanager.py", line 323, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1321, in getresponse
    response.begin()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-20 23:02:25

我有答案了。uiautomator不再更新。uiautomator2可以解决这个问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56597844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档