<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          小知識分享:adb uiautomator 命令 dump ui 樹信息

          共 878字,需瀏覽 2分鐘

           ·

          2020-12-07 08:52

          之前給大家分享過一篇文章,講述如何通過 getevent/sendevent/input 命令向 android 手機(jī)設(shè)備接收和發(fā)送操作事件,來解決自動化腳本場景的需求。

          其實(shí)還有一個(gè)小知識點(diǎn)需要補(bǔ)充一下,就是可以借助 uiautomator 命令 dump 當(dāng)前頁面的 ui hierarchy 信息。

          一個(gè)完整的 uiautomator 命令類似:

          adb shell uiautomator dump [--compressed] [file]

          --compressed 參數(shù):輸出更加精簡的 layout 布局信息,包括 android:id/content 在內(nèi)的通用外層 ui 結(jié)構(gòu)都被拿掉了;

          file 參數(shù):xml 格式輸出結(jié)果文件,默認(rèn)為 /sdcard/window_dump.xml;

          還是老規(guī)矩,舉個(gè)簡單的例子。

          ~?yifeng$?adb?shell?uiautomator dump
          UI hierchary dumped to: /sdcard/window_dump.xml

          再通過 adb pull 命令將手機(jī) sdcard 里的文件傳輸?shù)诫娔X中。

          adb?pull?/sdcard/window_dump.xml?Desktop/

          用 Sublime 軟件打開,Indent XML 插件格式化后,就是這個(gè)樣子:


          <hierarchy?rotation="0">
          ????<node?bounds="[0,0][1080,2340]"?checkable="false"?checked="false"?class="android.widget.FrameLayout"?clickable="false"?content-desc=""?enabled="true"?focusable="false"?focused="false"?index="0"?long-clickable="false"?package="com.feng.test"?password="false"?resource-id=""?scrollable="false"?selected="false"?text="">
          ????????<node?bounds="[48,128][341,208]"?checkable="false"?checked="false"?class="android.widget.TextView"?clickable="false"?content-desc=""?enabled="true"?focusable="false"?focused="false"?index="0"?long-clickable="false"?package="com.feng.test"?password="false"?resource-id=""?scrollable="false"?selected="false"?text="DemoApp"/>
          ????????<node?bounds="[339,1224][741,1368]"?checkable="false"?checked="false"?class="android.widget.Button"?clickable="true"?content-desc=""?enabled="true"?focusable="true"?focused="false"?index="1"?long-clickable="false"?package="com.feng.test"?password="false"?resource-id="com.feng.test:id/b_button"?scrollable="false"?selected="false"?text="HELLO?WORLD!"/>
          ????node>
          hierarchy>

          當(dāng)前頁面完整的 UI 樹結(jié)構(gòu)信息都 dump 出來了,包括 view 的類名、資源 ID 和屏幕位置坐標(biāo)等。

          長按識別二維碼,即可關(guān)注我




          原創(chuàng)推薦
          android getevent sendevent input 接收發(fā)送事件
          禁用 testOnly 屬性,解決 debug 包安裝失敗
          解決 Adb Unavailable,嘗試了一千種方案后
          瀏覽 410
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  国产精品视频播放三级 | 成人无码影音 | 亚洲黄色视频在线观看网站 | 国产一级片免费观看 | 亚洲免费观看视频 |