Python獲取uiautomator文件保存在電腦的腳本

import time
import os
uix_name=str(time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()))
#用時間戳生成名字
os.system('adb devices') #獲取連接設備

dump_uix='adb shell uiautomator dump /sdcard/uix/'+uix_name+'.uix'
#通過時間戳對uix和圖片進行命名並截取保存在手機下
dump_png='adb shell screencap -p /sdcard/uix/'+uix_name+'.png'
pull_uix='adb pull /sdcard/uix/'+uix_name+".uix E:\\APPUI"
pull_png='adb pull /sdcard/uix/'+uix_name+".png E:\\APPUI"

result=os.system(dump_uix)
if result:
    print('無uix')
else:
    print('有uix')
    os.system(pull_uix)
    os.system(dump_png)
    os.system(pull_png)
print(dump_uix,dump_png,pull_uix,pull_png)

 

保存下來的使用方法:

1、打開 uiautomatorviewer,工具在SDK的tools件夾中 這個是我的路徑(C:\Program Files (x86)\Android\android-sdk\tools)

 

2、 點擊打開文件,選擇保存在電腦的文件(注意文件和圖片要對應)

 然後就可以查看對應 元素進行操作了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章