上一步已經把環境搭建好了,先不要急着寫腳本,測試APP以前首先要知道app上每個控件的‘地址’,如何準確的定位到這個控件呢?android
一、adb 鏈接shell
把手機鏈接上電腦,開啓文件傳輸模式,開啓開發者模式,發開USB調試。app
在cmd命令輸入adb devices,查看是否能找到手機設備,能找到說明手機鏈接到電腦沒問題了。工具
在手機上打開要測試的APP, 輸入 cmd中輸入adb shell dumpsys window w | findstr \/ | findstr name=測試
查看app的'appActivity'spa
二、APP控件定位3d
在上一步android SDK中打開控件監控工具:調試
D:\android\sdk\tools\hierarchyviewer.bat blog
若是出現如下報錯須要先關閉appium:開發
Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist! Error while obtaining UI hierarchy XML file: com.android.ddmlib.SyncException: Remote object doesn't exist!
resource-id處就是數字8的id地址了