前言:
App Inspector:浏览器端的移动设备 UI 查看器,使用树状态结构查看 UI 布局,自动生成 XPaths。官网:https://macacajs.github.io/app-inspector/cn/
本次教程仅支持iOS,Mac
一、环境安装:
1、安装Node.js
brew install node
2、安装macaca
npm i -g macaca-cli
3、安装 ideviceinstaller
brew install ideviceinstaller
4、安装 usbmuxd
brew install usbmuxd
5、安装iOS驱动
npm i macaca-ios -g
6、安装App Inspector
npm install app-inspector -g
二、安装XCTestWD
1、进入App Inspector安装目录下XCTestWD文件夹,具体路径参照自己的路径,可以通过find命令查找。
2、用xcode打开XCTestWD.xcodeproj文件cd /usr/local/lib/node_modules/app-inspector/node_modules/xctestwd/XCTestWD






4、项目文件直接编译,test结尾的文件build for Testing。编译成功即可。
三、将 TEAM_ID 通过环境变量传入覆盖安装App Inspector、iOS驱动
1、获取你的TEAM_ID ,见下图。
2、覆盖安装iOS驱动
DEVELOPMENT_TEAM_ID=TEAM_ID npm i macaca-ios -g
3 、覆盖安装App Inspector
DEVELOPMENT_TEAM_ID=TEAM_ID npm install app-inspector -g
四、使用App Inspector
1、获取测试机uuid,并执行以下命令:
2、chrome浏览器自动打开地址:http://192.168.21.101:5678/ (推荐用 Chrome 浏览器)app-inspector -u DEVICE-ID

3、点击页面元素,即可获取元素xpath,name
4、若切换页面,需现在手机上切换,然后刷新浏览器,则获取手机的最新页面。
以上~
网友评论