Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump出来的xml中能够找到节点,但是u2的child找不到节点 #1055

Open
philosophy912 opened this issue Nov 26, 2024 · 1 comment

Comments

@philosophy912
Copy link

uiautomator2版本号是:3.2.6

1

我导出来的xml结构如附件
1.txt
【请注意该文件是xml,由于github限制,请转换成xml文件】

我的代码是


driver = u2.connect("fb8bff0f")
# xml = driver.dump_hierarchy()
# print(xml)

# 通过 resource id 定位父节点
parent_node = driver(className="android.widget.ScrollView")

# 获取该节点下的所有一级子节点
children_nodes = parent_node.child()
print(len(parent_node))

从xml中能够看到,该节点是

<node index="0" text="" resource-id="com.omosoft.launcher:id/scroll_view_widget" class="android.widget.ScrollView"
      package="com.omosoft.launcher" content-desc="" checkable="false" checked="false" clickable="false" enabled="true"
      focusable="true" focused="true" scrollable="true" long-clickable="false" password="false" selected="false"
      visible-to-user="true" bounds="[0,160][748,1440]" drawing-order="1" hint="" display-id="0">
    <node index="0" text="" resource-id="" class="android.widget.LinearLayout" package="com.omosoft.launcher"
          content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
          focused="false" scrollable="false" long-clickable="false" password="false" selected="false"
          visible-to-user="true" bounds="[36,160][746,1440]" drawing-order="1" hint="" display-id="0">
        <node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
              content-desc="" checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
              focused="false" scrollable="false" long-clickable="false" password="false" selected="false"
              visible-to-user="true" bounds="[36,182][746,912]" drawing-order="2" hint="" display-id="0">
            <node index="0" text="" resource-id="com.omosoft.launcher:id/widget_adas_layout"
                  class="android.widget.FrameLayout" package="com.omosoft.launcher" content-desc="" checkable="false"
                  checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false"
                  long-clickable="true" password="false" selected="false" visible-to-user="true"
                  bounds="[36,182][746,540]" drawing-order="1" hint="" display-id="0">
                <node index="0" text="" resource-id="" class="android.widget.FrameLayout" package="com.omosoft.launcher"
                      content-desc="" checkable="false" checked="false" clickable="false" enabled="true"
                      focusable="false" focused="false" scrollable="false" long-clickable="false" password="false"
                      selected="false" visible-to-user="true" bounds="[36,182][746,540]" drawing-order="1" hint=""
                      display-id="0">
                    <node index="0" text="" resource-id="com.omosoft.launcher:id/bg_adas" class="android.view.View"
                          package="com.omosoft.launcher" content-desc="" checkable="false" checked="false"
                          clickable="false" enabled="true" focusable="false" focused="false" scrollable="false"
                          long-clickable="false" password="false" selected="false" visible-to-user="true"
                          bounds="[36,182][746,540]" drawing-order="1" hint="" display-id="0"/>
                    <node index="1" text="" resource-id="" class="android.widget.FrameLayout"
                          package="com.omosoft.launcher" content-desc="" checkable="false" checked="false"
                          clickable="false" enabled="true" focusable="false" focused="false" scrollable="false"
                          long-clickable="false" password="false" selected="false" visible-to-user="true"
                          bounds="[50,196][732,526]" drawing-order="2" hint="" display-id="0">
                        <node index="0" text="" resource-id="com.omosoft.launcher:id/kan_zi_view"
                              class="android.view.View" package="com.omosoft.launcher" content-desc="" checkable="false"
                              checked="false" clickable="false" enabled="true" focusable="true" focused="false"
                              scrollable="false" long-clickable="false" password="false" selected="false"
                              visible-to-user="true" bounds="[50,196][732,526]" drawing-order="1" hint=""
                              display-id="0"/>
                    </node>
                    <node NAF="true" index="2" text="" resource-id="com.omosoft.launcher:id/widget_adas_handle"
                          class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                          checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                          focused="false" scrollable="false" long-clickable="false" password="false" selected="false"
                          visible-to-user="true" bounds="[283,468][499,526]" drawing-order="5" hint="" display-id="0"/>
                </node>
            </node>
            <node index="1" text="" resource-id="com.omosoft.launcher:id/widget_nav_layout_content"
                  class="android.widget.FrameLayout" package="com.omosoft.launcher" content-desc="" checkable="false"
                  checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false"
                  long-clickable="true" password="false" selected="false" visible-to-user="true"
                  bounds="[36,554][746,912]" drawing-order="2" hint="" display-id="0">
                <node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
                      content-desc="" checkable="false" checked="false" clickable="false" enabled="true"
                      focusable="false" focused="false" scrollable="false" long-clickable="false" password="false"
                      selected="false" visible-to-user="true" bounds="[36,554][746,912]" drawing-order="1" hint=""
                      display-id="0">
                    <node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
                          content-desc="" checkable="false" checked="false" clickable="false" enabled="true"
                          focusable="false" focused="false" scrollable="false" long-clickable="false" password="false"
                          selected="false" visible-to-user="true" bounds="[36,554][746,912]" drawing-order="2" hint=""
                          display-id="0">
                        <node index="1" text="搜索目的地" resource-id="com.omosoft.launcher:id/search_tv"
                              class="android.widget.TextView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[36,554][746,734]" drawing-order="1"
                              hint="" display-id="0"/>
                        <node NAF="true" index="2" text="" resource-id="com.omosoft.launcher:id/img_home"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[36,725][262,912]" drawing-order="3"
                              hint="" display-id="0"/>
                        <node NAF="true" index="3" text="" resource-id="com.omosoft.launcher:id/img_folder"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[262,725][488,912]" drawing-order="4"
                              hint="" display-id="0"/>
                        <node NAF="true" index="4" text="" resource-id="com.omosoft.launcher:id/img_address"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[520,725][746,912]" drawing-order="5"
                              hint="" display-id="0"/>
                    </node>
                </node>
            </node>
        </node>
        <node index="1" text="" resource-id="com.omosoft.launcher:id/rv_left_card"
              class="androidx.recyclerview.widget.RecyclerView" package="com.omosoft.launcher" content-desc=""
              checkable="false" checked="false" clickable="false" enabled="true" focusable="true" focused="false"
              scrollable="false" long-clickable="false" password="false" selected="false" visible-to-user="true"
              bounds="[36,912][746,1440]" drawing-order="3" hint="" display-id="0">
            <node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
                  content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                  focused="false" scrollable="false" long-clickable="false" password="false" selected="false"
                  visible-to-user="true" bounds="[36,926][746,1284]" drawing-order="1" hint="" display-id="0">
                <node index="0" text="" resource-id="com.omosoft.launcher:id/layout_content"
                      class="android.widget.FrameLayout" package="com.omosoft.launcher" content-desc=""
                      checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                      focused="false" scrollable="false" long-clickable="true" password="false" selected="false"
                      visible-to-user="true" bounds="[36,926][746,1284]" drawing-order="1" hint="" display-id="0">
                    <node index="0" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
                          content-desc="" checkable="false" checked="false" clickable="false" enabled="true"
                          focusable="false" focused="false" scrollable="false" long-clickable="false" password="false"
                          selected="false" visible-to-user="true" bounds="[36,926][746,1284]" drawing-order="1" hint=""
                          display-id="0">
                        <node index="2" text="" resource-id="com.omosoft.launcher:id/card_bottom_bg"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[36,926][746,1284]" drawing-order="1"
                              hint="" display-id="0"/>
                        <node index="3" text="" resource-id="com.omosoft.launcher:id/card_bg"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[50,940][732,1270]" drawing-order="2"
                              hint="" display-id="0"/>
                        <node NAF="true" index="4" text="" resource-id="com.omosoft.launcher:id/area_play"
                              class="android.view.View" package="com.omosoft.launcher" content-desc="" checkable="false"
                              checked="false" clickable="true" enabled="true" focusable="true" focused="false"
                              scrollable="false" long-clickable="false" password="false" selected="false"
                              visible-to-user="true" bounds="[50,940][600,1135]" drawing-order="6" hint=""
                              display-id="0"/>
                        <node index="5" text="" resource-id="com.omosoft.launcher:id/media_image"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[82,973][214,1105]" drawing-order="7"
                              hint="" display-id="0"/>
                        <node index="6" text="暂无播放" resource-id="com.omosoft.launcher:id/tv_song_name"
                              class="android.widget.TextView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[246,973][596,1037]" drawing-order="9"
                              hint="" display-id="0"/>
                        <node NAF="true" index="7" text="" resource-id="com.omosoft.launcher:id/area_source_switching"
                              class="android.view.View" package="com.omosoft.launcher" content-desc="" checkable="false"
                              checked="false" clickable="true" enabled="true" focusable="true" focused="false"
                              scrollable="false" long-clickable="false" password="false" selected="false"
                              visible-to-user="true" bounds="[628,940][732,1040]" drawing-order="3" hint=""
                              display-id="0"/>
                        <node index="8" text="" resource-id="com.omosoft.launcher:id/iv_audio_source"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[628,967][684,1023]" drawing-order="4"
                              hint="" display-id="0"/>
                        <node index="9" text="" resource-id="com.omosoft.launcher:id/iv_triangle"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[688,1005][706,1023]" drawing-order="5"
                              hint="" display-id="0"/>
                        <node index="10" text="---" resource-id="com.omosoft.launcher:id/tv_author"
                              class="android.widget.TextView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[246,1041][596,1089]" drawing-order="10"
                              hint="" display-id="0"/>
                        <node index="11" text="" resource-id="com.omosoft.launcher:id/seekBar"
                              class="android.widget.SeekBar" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[82,1135][700,1141]" drawing-order="11"
                              hint="" display-id="0"/>
                        <node index="12" text="" resource-id="com.omosoft.launcher:id/flow_bottom"
                              class="android.view.View" package="com.omosoft.launcher" content-desc="" checkable="false"
                              checked="false" clickable="false" enabled="true" focusable="false" focused="false"
                              scrollable="false" long-clickable="false" password="false" selected="false"
                              visible-to-user="true" bounds="[82,1156][700,1256]" drawing-order="12" hint=""
                              display-id="0"/>
                        <node index="13" text="" resource-id="com.omosoft.launcher:id/iv_collect"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[82,1156][182,1256]" drawing-order="13"
                              hint="" display-id="0"/>
                        <node index="14" text="" resource-id="com.omosoft.launcher:id/iv_pre"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[212,1156][312,1256]" drawing-order="14"
                              hint="" display-id="0"/>
                        <node NAF="true" index="15" text="" resource-id="com.omosoft.launcher:id/iv_toggle"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[341,1156][441,1256]" drawing-order="15"
                              hint="" display-id="0"/>
                        <node index="16" text="" resource-id="com.omosoft.launcher:id/iv_next"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[471,1156][571,1256]" drawing-order="16"
                              hint="" display-id="0"/>
                        <node NAF="true" index="17" text="" resource-id="com.omosoft.launcher:id/iv_lyric"
                              class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[600,1156][700,1256]" drawing-order="17"
                              hint="" display-id="0"/>
                    </node>
                </node>
            </node>
            <node index="1" text="" resource-id="" class="android.view.ViewGroup" package="com.omosoft.launcher"
                  content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                  focused="false" scrollable="false" long-clickable="false" password="false" selected="false"
                  visible-to-user="true" bounds="[36,1298][746,1440]" drawing-order="2" hint="" display-id="0">
                <node index="0" text="" resource-id="com.omosoft.launcher:id/layout_content"
                      class="android.widget.FrameLayout" package="com.omosoft.launcher" content-desc=""
                      checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                      focused="false" scrollable="false" long-clickable="true" password="false" selected="false"
                      visible-to-user="true" bounds="[36,1298][746,1440]" drawing-order="1" hint="" display-id="0">
                    <node index="0" text="" resource-id="" class="android.widget.FrameLayout"
                          package="com.omosoft.launcher" content-desc="" checkable="false" checked="false"
                          clickable="false" enabled="true" focusable="false" focused="false" scrollable="false"
                          long-clickable="false" password="false" selected="false" visible-to-user="true"
                          bounds="[36,1298][746,1440]" drawing-order="1" hint="" display-id="0">
                        <node index="0" text="" resource-id="com.omosoft.launcher:id/root_view"
                              class="android.view.ViewGroup" package="com.omosoft.launcher" content-desc=""
                              checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                              focused="false" scrollable="false" long-clickable="false" password="false"
                              selected="false" visible-to-user="true" bounds="[36,1298][746,1440]" drawing-order="1"
                              hint="" display-id="0">
                            <node index="0" text="" resource-id="com.omosoft.launcher:id/bg_layer_1"
                                  class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                                  checkable="false" checked="false" clickable="false" enabled="true" focusable="false"
                                  focused="false" scrollable="false" long-clickable="false" password="false"
                                  selected="false" visible-to-user="true" bounds="[36,1298][746,1440]" drawing-order="1"
                                  hint="" display-id="0"/>
                            <node index="1" text="" resource-id="com.omosoft.launcher:id/no_location_view"
                                  class="android.view.ViewGroup" package="com.omosoft.launcher" content-desc=""
                                  checkable="false" checked="false" clickable="true" enabled="true" focusable="true"
                                  focused="false" scrollable="false" long-clickable="false" password="false"
                                  selected="false" visible-to-user="true" bounds="[36,1298][746,1440]" drawing-order="4"
                                  hint="" display-id="0">
                                <node index="0" text="" resource-id="com.omosoft.launcher:id/no_location_bg"
                                      class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                                      checkable="false" checked="false" clickable="false" enabled="true"
                                      focusable="false" focused="false" scrollable="false" long-clickable="false"
                                      password="false" selected="false" visible-to-user="true"
                                      bounds="[36,1298][746,1440]" drawing-order="1" hint="" display-id="0"/>
                                <node index="1" text="" resource-id="com.omosoft.launcher:id/no_location_icon"
                                      class="android.widget.ImageView" package="com.omosoft.launcher" content-desc=""
                                      checkable="false" checked="false" clickable="false" enabled="true"
                                      focusable="false" focused="false" scrollable="false" long-clickable="false"
                                      password="false" selected="false" visible-to-user="true"
                                      bounds="[36,1329][406,1440]" drawing-order="2" hint="" display-id="0"/>
                                <node index="2" text="无位置信息"
                                      resource-id="com.omosoft.launcher:id/no_location_title"
                                      class="android.widget.TextView" package="com.omosoft.launcher" content-desc=""
                                      checkable="false" checked="false" clickable="false" enabled="true"
                                      focusable="false" focused="false" scrollable="false" long-clickable="false"
                                      password="false" selected="false" visible-to-user="true"
                                      bounds="[431,1350][611,1399]" drawing-order="3" hint="" display-id="0"/>
                                <node index="3" text="请打开导航获取位置权限"
                                      resource-id="com.omosoft.launcher:id/no_location_content"
                                      class="android.widget.TextView" package="com.omosoft.launcher" content-desc=""
                                      checkable="false" checked="false" clickable="false" enabled="true"
                                      focusable="false" focused="false" scrollable="false" long-clickable="false"
                                      password="false" selected="false" visible-to-user="true"
                                      bounds="[345,1409][697,1440]" drawing-order="4" hint="" display-id="0"/>
                            </node>
                        </node>
                    </node>
                </node>
            </node>
        </node>
    </node>
</node>

所以这个节点是存在子节点的,但是u2无法获取到子节点,请有空的时候帮忙看看这个问题。

@philosophy912
Copy link
Author

我使用命令adb shell uiautomator dump导出的xml,则无法找到该元素。
window_dump.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant