1、安装brew 软件包管理工具:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2、安装nodejs  :brew install node  安装完node 后需要设置通过npm安装的软件包放置位置设置为可以读写权限,chmod -R 777 /usr/local/lib/node_modules/  (注:在操作时时测试机器,赋给777权限没有问题,如果是其他机器,需要考虑是否给了不该给的权限)    其中 /usr/local/ 可以通过npm config get prefix 获得,这样会省去一些权限的问题。

3、安装macaca 参考官网:https://macacajs.github.io/environment-setup

4、安装macaca inspect :npm i app-inspector -g

  安装完后进入目录:/usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent,

  在这个目录下面新建一个文件夹并执行下命令

  mkdir -p Resources/WebDriverAgent.bundle

  sh ./Scripts/bootstrap.sh -d

用xcode 打开WebDriverAgent.xcodeproj文件,对项目文件进行重新编译,

  编译:WebDriverAgentLib编译选项

  修改Bundle id,Team选为登录xcode的appid,

编译:WebDriverAgentRunner

每个编译一定要出现succeeded才行

编译完成,就可以启动macaca inspector 命令:app-inspector --port 56789 -u f9b87274e2a24b310399ddxxxxxx

启动后再浏览器中输入localhost:56789 访问,(实际端口以执行命令显示为准),手机会安装一个程序,需要手动点击这个名为:WebDriverAgentRunner的app, 会提示要在设置中信任改开发者开发的软件,进入手机>设置>通用>设备管理 >开发者应用 >信任WebDriverAgentRunner

再次安装执行命令:

app-inspector --port 56789 -u f9b87274e2a24b310399dd56dd80f8561d99fdac --verbose

提示出错误:xctest client exit with code: 65

>> xctest-client.js:181:14 [master] pid:33863 xctest client exit with code: 65, signal: null

>> xctest-client.js:145:16 [master] pid:33863 deviceconsole exit with code: null, signal: SIGKILL

>> xctest-client.js:255:14 [master] pid:33863 Fail to start xctest: undefined

>> app-inspector:66:44 [master] pid:33863 undefined

解决办法:在xcode 中编译下:WebDriverAgentUSBClient

再删除手机上的WDA,重复启动下

app-inspector --port 56789 -u f9b87274e2a24b310399dd56dd80f8561d99fdac --verbose

在再手机中信任开发者。就可以了,这个问题是签名问题

又由于macaca inspector 无法查看所有的元素,只有通过代码获取运行时xml页面元素布局   获取xml内容方法为:System.out.println(driver.getPageSource());

获取如下,有了这个xml文件内容,就能根据实际内容得到xpath  name 登录内容,完美解决元素查找问题

<?xml version="1.0" encoding="UTF-8"?><AppiumAUT><XCUIElementTypeApplication type="XCUIElementTypeApplication" name="xxxx" label="xxxx" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeWindow type="XCUIElementTypeWindow" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="我的xxxx" visible="true" enabled="true" x="0" y="20" width="414" height="44">
<XCUIElementTypeButton type="XCUIElementTypeButton" visible="true" enabled="true" x="12" y="26" width="41" height="30"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="返回" label="返回" visible="true" enabled="true" x="12" y="31" width="21" height="22"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="我的xxxx" name="我的xxxx" label="我的xxxx" visible="true" enabled="true" x="170" y="28" width="74" height="27"/>
<XCUIElementTypeButton type="XCUIElementTypeButton" name="MyReceiveSearch" label="MyReceiveSearch" visible="true" enabled="true" x="367" y="29" width="27" height="25"/>
</XCUIElementTypeNavigationBar>
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="64" width="414" height="672">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="64" width="414" height="57">
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="xxxx(0)" name="xxxx(0)" label="xxxx" visible="true" enabled="true" x="0" y="64" width="138" height="57"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="xxxx(14)" name="xxxx14)" label="xxxx" visible="true" enabled="true" x="138" y="64" width="138" height="57"/>
<XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="xxxx(10)" name="xxxx(10)" label="xxxx" visible="true" enabled="true" x="276" y="64" width="138" height="57"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="117" width="138" height="4"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="120" width="414" height="1"/>
</XCUIElementTypeOther>
<XCUIElementTypeScrollView type="XCUIElementTypeScrollView" visible="true" enabled="true" x="0" y="120" width="414" height="616">
<XCUIElementTypeTable type="XCUIElementTypeTable" name="无更多记录" label="无更多记录" visible="true" enabled="true" x="0" y="120" width="414" height="616"/>
</XCUIElementTypeScrollView>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeOther>
</XCUIElementTypeWindow>
<XCUIElementTypeWindow type="XCUIElementTypeWindow" visible="false" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" enabled="true" x="0" y="0" width="414" height="736"/>
</XCUIElementTypeWindow>
<XCUIElementTypeWindow type="XCUIElementTypeWindow" visible="true" enabled="true" x="0" y="0" width="414" height="736">
<XCUIElementTypeStatusBar type="XCUIElementTypeStatusBar" visible="true" enabled="true" x="0" y="0" width="414" height="20">
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="false" enabled="true" x="0" y="0" width="414" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" visible="true" enabled="true" x="0" y="0" width="414" height="20">
<XCUIElementTypeOther type="XCUIElementTypeOther" name="信号强度:5 格(共 5 格)" label="信号强度:5 格(共 5 格)" visible="true" enabled="true" x="6" y="0" width="34" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" name="中国电信 网络" label="中国电信 网络" visible="true" enabled="true" x="43" y="0" width="50" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" value="SSID" name="4G" label="4G" visible="true" enabled="true" x="102" y="0" width="17" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" name="下午6:13" label="下午6:13" visible="true" enabled="true" x="184" y="0" width="51" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" name="勿扰模式" label="勿扰模式" visible="true" enabled="true" x="343" y="0" width="9" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" name="方向已锁定" label="方向已锁定" visible="true" enabled="true" x="358" y="0" width="12" height="20"/>
<XCUIElementTypeOther type="XCUIElementTypeOther" name="电池电量:100%, 使用交流电源" label="电池电量:100%, 使用交流电源" visible="true" enabled="true" x="376" y="0" width="33" height="20"/>
</XCUIElementTypeOther>
</XCUIElementTypeStatusBar>
</XCUIElementTypeWindow>
</XCUIElementTypeApplication></AppiumAUT>

最新文章

  1. WebSphere MQ 安装
  2. vim安装YouCompleteMe 插件
  3. 轻量级应用开发之(10) UINavigationController导航控制器
  4. UI2_UITableViewDelete
  5. JavaScript基础篇最全
  6. JS Math 类库介绍
  7. ECNU1104-BFS
  8. mysql外键使用和级联
  9. perl 爬虫两个技巧
  10. 下载安装Cygwin
  11. 编译安装LAMP并实现wordpress
  12. notepad++ 代码注释快捷键
  13. ACDSee清除旧版本残余
  14. tk.mybatis通用插件updateByPrimaryKeySelective无法自动更新ON UPDATE CURRENT_TIMESTAMP列的解决办法
  15. UVALive 7512 November 11th 题解
  16. Robotium_断言方法assert、is、search
  17. spring cloud学习(三)使用Ribbon实现客户端负载均衡
  18. Postman—做各种类型的http接口测试
  19. spring boot由浅入深(一)jdk安装
  20. LVS (Linux Virtual Server) 思维导图笔记

热门文章

  1. Web支持可暂停的超大文件上传
  2. docker入门小结(二)
  3. rsync的几则tips(渗透技巧)
  4. 搭建SpringMVC+Hibernate4+Spring3+Ajax+Maven项目
  5. JavaScript 文件操作方法详解
  6. cmake学习之- set
  7. 怎样推断 ios设备的类型(iphone,ipod,ipad)
  8. 有两个好友A和B,住在一片长有蘑菇的由n*m个方格组成的草地,A在(1,1),B在(n,m)。现在A想要拜访B,由于她只想去B的家,所以每次她只会走(i,j+1)或(i+1,j)这样的路线,在草地上有k个蘑菇种在格子里(多个蘑菇可能在同一方格),问:A如果每一步随机选择的话(若她在边界上,则只有一种选择),那么她不碰到蘑菇走到B的家的概率是多少?
  9. urllib与urllib2的学习总结(python2.7.X): python urllib与urllib2
  10. 解析域名得到IP