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>

转载于:https://www.cnblogs.com/testway/p/6298126.html

mac 系统使用macaca inspector 获取iphone真机应用元素相关推荐

  1. Xcode证书破解 iphone真机部署

    Xcode证书破解 iphone真机部署 证书伪造: 先按照该教程的步骤添加证书.注意,原教程选择的是"系统"证书,这里我们用"登录"证书,切记. Xcode破 ...

  2. iphone真机调试时上下两端出现黑边

    iphone5s真机调试时上下有黑边问题 xcode7中的iphone真机调试 作为一个初学者,看了网上很多资料,都说要想在iphone真机上进行调试,需要购买苹果开发者个人账号,有一天突然在知乎上看 ...

  3. XCode - 无法对iPhone真机调试的解决方法!

    XCode - 无法对iPhone真机调试的解决方法! 参考文章: (1)XCode - 无法对iPhone真机调试的解决方法! (2)https://www.cnblogs.com/sunylat/ ...

  4. Appium 实现iPhone真机自动化-常见问题

    摘要: 首先 Appium 支持 iPhone 真机,以下4个条件必须满足: 1. 苹果开发者账号和开发者证书 2. 苹果设备,确保这个设备已经被配置为开发机器.怎么配置? 3. 签名过的 .ipa ...

  5. 获取iPhone本机IP地址新方法

    最近在项目中要获取iphone手机本机的ip地址.在我一博客中也写到方法了.但是那种方法只适合于非3G网络.今天网上找了下一个不同以前的获取方式.特记录下.先感谢作者. 转至 http://mobil ...

  6. MacOS虚拟机中xcode调试识别不出iPhone真机问题

    作为一个开发者,高配置的Windows电脑安装虚拟机学习iOS是不错的选择既节约,又经济.但是在调试iPhone真机的时候发现,Xcode识别不了,虽然虚拟机中显示iPhone连接成功,但是还是没有真 ...

  7. iphone固件升级到3.1.3 ,HelloWorld成功安装到iPhone真机测试

    2010-07-04 iphone固件升级到3.1.3 , XCode iPhone SDK 3.1.3 HelloWorld成功安装到iPhone真机测试

  8. ionic应用在mac上使用Xcode7.2(7C68)进行iphone真机测试

    1.前提环境 : 假设已经在mac(OS X El Capitan 版本 10.11.2)上装好了Xcode7.2(7C68)和ionic环境 2.运行添加ios平台命令 ionic platform ...

  9. WebDriverAgent安装到iphone真机

    一.背景 Appium ios平台自动化测试需要将WebDriverAgent安装到真机上,通过它驱动手机进行自动化测试,但实际往真机安装过程中会遇到各种各样的问题,特此记录一下. 二.问题汇总: 1 ...

最新文章

  1. k8s系列~mgr的应用
  2. 如何将本地项目发布到gitee?
  3. App乱世,3721离我们有多远
  4. mysql安装了老版本_Windows环境下MySQL安装教程
  5. vim 的寄存器/剪贴板
  6. 移动端开发——javascript
  7. [Mojava 10.14.4] Clover隐藏多余分区, 原来可以这么简单
  8. 鸿蒙空间是什么星辰变,飞升之后做什么《星辰变》神魔妖界收伏奇珍异兽
  9. 反汇编基础-数据类型以及C++引用、指针反汇编后的概括
  10. AndroidStudio_安卓原生开发_精美自定义多选控件_多选Spinner_MultiSpinner_拿来即用---Android原生开发工作笔记144
  11. 电脑文件夹加密软件_上海靠谱电脑资料加密软件解决方案
  12. 第三章:变量与字符串等基础知识
  13. android开发 手写签名,Android实现手写签名
  14. 计算机网络应用层和传输层及网络层协议有哪些
  15. linux查看照片命令,php 及 linux 命令行方式读取 图片 exif 信息
  16. kali linux安装firefox,Kali安装firefox浏览器
  17. 简单记录使用org.slf4j.MDC进行日志追踪
  18. 学习笔记1—元胞自动机(CA)模型①
  19. C语言通讯录管理系统(含完整代码)
  20. OJ 1471 小鱼买水果

热门文章

  1. docker run常用参数说明
  2. 图解Hadoop hdfs的基本工作机制及相关概念
  3. Linux centos 6.7 设置主机名
  4. 重启docker 服务命令
  5. 笔试题:写一个ArrayList 的动态代理类
  6. JVM 调优实战--常用JVM命令:jps/jinfo/jstat/jmap/jstack/jhat
  7. spring boot整合mybatis步骤
  8. c 最大子序列和_最大子序列和暴力法、分治+递归法、妙法
  9. 关于齐次坐标的理解记录
  10. leetcode(2)495——提莫攻击(C++),运算符优先级(+=,?,+,-)