大神方案:
在C:\sdk\android-sdk-windows\tools路徑下的uiautomatorviewer.bat,右鍵編輯打開,在最末端輸入:
call adb shell uiautomator dumpcall
call adb pull /storage/sdcard/window_dump.xml .
call window_dump.xml
通用方案:
桌面新建 test.bat文件,添加五行代碼,內容如下:
@echo on adb shell uiautomator dump /sdcard/app.uix adb pull /sdcard/app.uix D:/app.uix # 此處輸入任意自己本地路徑
adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png D:/app.png # 此處輸入任意自己本地路徑
保存為bat文件后,打開手機,進入自己想要定位的頁面,運行新建的 test.bat
再運行uiautomatorviewer.bat,點擊左上角的open按鈕,分別選擇 test.bat里輸入的本地存儲路徑。
此時能成功獲取手機頁面的截圖。
通用方案為萬能方法,基本都能成功,缺點是每進入一個新的頁面都需要執行一下test.bat,並在uiautomatorviewer 中導入。
聊勝於無,雖然麻煩,但能解決問題,畢竟頁面就那幾個
感謝大神分享~
來源:https://www.jianshu.com/p/200de8ded032