uiautomator 连接报错 WARNING - (‘Connection aborted.‘, RemoteDisconnected(‘Remote end closed connection

uiautomator2 一直用的好好的,突然使用weditor 无法获取UI元素

经过一番用deepSeek 搜索,把weditor卸载重新安装,还是不行,在快要绝望查看uiautomator2 不是最新版,把uiautomator2 升级到最新版本,又恢复正常使用了,太坑了

顺便再贴一下weditor 工作原理:

weditor 是一个基于 Web 的 UI 查看器和调试工具,专门为 uiautomator2 设计。它可以帮助开发者实时查看 Android 设备的 UI 层次结构,并支持元素定位、属性查看、操作录制等功能。以下是 weditor 的工作原理和关键组件:


1. 核心工作原理

weditor 的工作原理可以概括为以下几个步骤:

(1) 与设备通信
  • weditor 通过 uiautomator2 与 Android 设备通信。

  • uiautomator2 在设备上运行一个后台服务(atx-agent),该服务负责与 PC 端的 weditor 进行数据交换。

(2) 获取 UI 层次结构
  • weditor 通过 uiautomator2 调用 Android 的 UIAutomator 框架,获取当前屏幕的 UI 层次结构(XML 格式)。

  • 这个 UI 层次结构包含了屏幕上所有控件的属性信息,例如:

    • 控件类型(class

    • 文本内容(text

    • 资源 ID(resource-id

    • 坐标位置(bounds

    • 其他属性(如 clickableenabled 等)。

(3) 渲染 UI 层次结构
  • weditor 将获取到的 UI 层次结构(XML 格式)解析并渲染成一个可视化的树状结构。

  • 用户可以通过浏览器访问 weditor 的 Web 界面,实时查看设备的 UI 层次结构。

(4) 交互操作
  • 用户可以在 weditor 的 Web 界面上点击某个控件,查看其属性。

  • weditor 支持通过界面操作设备,例如点击、输入文本、滑动等。这些操作会通过 uiautomator2 传递到设备上执行。


2. 关键组件

weditor 的实现依赖于以下关键组件:

(1) uiautomator2
  • uiautomator2 是 weditor 的核心依赖,负责与 Android 设备通信。

  • 它通过 atx-agent 在设备上运行一个后台服务,用于获取 UI 层次结构和执行操作。

(2) atx-agent
  • atx-agent 是 uiautomator2 的设备端服务,运行在 Android 设备上。

  • 它负责接收 PC 端的指令(如获取 UI 层次结构、执行操作等),并将结果返回给 PC 端。

(3) Web 服务器
  • weditor 启动一个本地的 Web 服务器,用户可以通过浏览器访问其界面。

  • Web 服务器负责将 UI 层次结构渲染成可视化的树状结构,并处理用户的操作指令。

(4) 前端界面
  • weditor 的前端界面基于 HTML、JavaScript 和 CSS 实现。

  • 它提供了一个交互式的 UI 查看器,用户可以通过界面查看控件属性、执行操作等。


3. 工作流程

以下是 weditor 的典型工作流程:

  1. 用户在 PC 上启动 weditor

  2. weditor 启动一个本地 Web 服务器,并打开浏览器访问其界面。

  3. weditor 通过 uiautomator2 连接到 Android 设备。

  4. weditor 从设备获取当前屏幕的 UI 层次结构,并渲染到 Web 界面。

  5. 用户可以在 Web 界面上查看控件属性、执行操作(如点击、输入文本等)。

  6. 用户的操作通过 uiautomator2 传递到设备上执行。


4. 优点

  • 实时性:可以实时查看设备的 UI 层次结构。

  • 可视化:以树状结构展示 UI 层次,方便查看和调试。

  • 交互性:支持通过界面操作设备,简化了调试流程。

  • 跨平台:基于 Web 实现,可以在任何操作系统上使用。


5. 使用场景

  • UI 自动化测试:用于定位元素、调试脚本。

  • 开发调试:查看 UI 层次结构,验证控件属性。

  • 操作录制:录制用户操作并生成自动化脚本。

>pip install scikit-learn -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com Looking in indexes: http://pypi.douban.com/simple/ WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-learn/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-learn/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-learn/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-learn/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-learn/ ERROR: Could not find a version that satisfies the requirement scikit-learn (from versions: none) ERROR: No matching distribution found for scikit-learn
11-02
pip install python-igraph louvain -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com Looking in indexes: http://pypi.douban.com/simple/ WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/python-igraph/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/python-igraph/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/python-igraph/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/python-igraph/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/python-igraph/ ERROR: Could not find a version that satisfies the requirement python-igraph (from versions: none) ERROR: No matching distribution found for python-igraph
最新发布
12-09
ccy@ccy-desktop:~$ pip install scikit-image -i http://pypi.douban.com/simple --trusted-host pypi.douban.com Defaulting to user installation because normal site-packages is not writeable Looking in indexes: http://pypi.douban.com/simple WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-image/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-image/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-image/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-image/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))': /simple/scikit-image/ ERROR: Could not find a version that satisfies the requirement scikit-image (from versions: none) ERROR: No matching distribution found for scikit-image ccy@ccy-desktop:~$ ccy@ccy-desktop:~$
10-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fish_study_csdn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值