AppAgent icon indicating copy to clipboard operation
AppAgent copied to clipboard

KeyError: 'bounds' ,bounds = elem.attrib["bounds"][1:-1].split("][")

Open timeisgoing opened this issue 1 year ago • 2 comments


[<Element 'hierarchy' at 0x10d29eac0>, <Element 'node' at 0x10d29ed40>]


Traceback (most recent call last): File "/Users/tt/Downloads/AppAgent/scripts/step_recorder.py", line 95, in traverse_tree(xml_path, focusable_list, "focusable", True) ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/tt/Downloads/AppAgent/scripts/and_controller.py", line 68, in traverse_tree parent_prefix = get_id_from_element(path[-2]) File "/Users/tt/Downloads/AppAgent/scripts/and_controller.py", line 42, in get_id_from_element bounds = elem.attrib["bounds"][1:-1].split("][") ~~~~~~~~~~~^^^^^^^^^^ KeyError: 'bounds'

另外我的用的本机的android studio,和这个有关系吗?

timeisgoing avatar Jan 07 '25 10:01 timeisgoing

+1同问

maoinbupt avatar Jan 12 '25 03:01 maoinbupt

我复现并定位到了这个异常:traverse_tree 会为可交互节点生成父级前缀,但 Android UI XML 的 hierarchy 根节点通常没有 bounds,当前代码仍然直接读取该属性。我准备让 bounds 解析对缺失或异常属性做容错:无坐标的父节点不参与前缀,无有效坐标的交互节点安全跳过,并补充最小 XML 回归测试。

yaodong-shen avatar Jul 21 '26 12:07 yaodong-shen