最近老大要求调研 macaca 自动化测试框架的使用,折腾半天终于可以使用了。
这里首先感谢 adfghzhang 的Macaca iOS 真机测试帖子让我少走不少路
(参见Macaca iOS 真机测试)
其中我和他的环境有点小区别
node-v return v6.4.0
nmp-v returm v3.10.3
按照步骤安装到检查环境
ps:如果有测试 android 的朋友没有 Platforms 不要紧 这是因为你的 android 环境没有下载任意一个 api 命令行键入 android 打开 sdk manager 下载你需要的就可以我这里下载的是 4.4.4 也就是 android-20 这里我们主要介绍的是 ios-inspector 所以只要 iOS checklist 和 Installed driver list:下的 ios: 1.0.36 存在就行 ios 真机测试这里我补充一点 adfghzhang 大神勿喷,有些同学安装大神的方法装 WebDriverAgent 到真机时会出现 A team must be selected to run 'WebDriverAgentRunner' on a device 的问题,这其实是一个自己开发 ios 小应用是经常遇到的问题这里需要修改如下的地方,选择自己的 team 就可以了
到这里我们环境基本搭建完成,在真机上也可以执行测试了,我们作为测试有时候项目经理不愿意吧源码开放给我们这就导致我们不能在模拟器抓取元素只能依赖于开发给我们运行在测试机器上的包 (或者打包的时候证书里面有你所用到的手机 uuid),那么问题来了 我们的元素怎么抓取最开始的时候 macaca 不支持 ios 真机抓取元素后来经过与 xdf 沟通,他们说正在解决了,大神就是大神,几天后大神和我说可以支持了怀着激动的心情我试了试果然不负众望
npm install app-inspector -g
安装成功后/usr/local/lib/node_modules 目录下多出一个 app-inspector 的目录,ok 接下来就是把 app-inspector 下找到/usr/local/lib/node_modules/macacaios/node_modules/webdriveragent/WebDriverAgent 用 xcode 打开修改 bundle id 因为之前运行的时候我们已经安装过一个如果再次安装会覆盖原本的那个,这里由于本人也没搞明白 2 个的区别在哪里为了防止这个弄完,上个不能用了所以本菜鸟在修改 bundle id 的同时修改了其 product Name
这样手机上就有 2 个
通过 $ app-inspector -u your-iphone-uuid 安装到手机上我这里由于和之前安装的运行时的 WebDriverAgent 用的是同一个开发者证书 所以不需要再次信任直接就成功,如果有同学第一次就先安装 inspector 的话 参见上文提到的[Macaca iOS 真机测试下的 给 ios-app-bootstrap 重签名,日志中出现 iOS device started: your-iphone-uuid 如下图
打开浏览器访问http://172.16.4.100:5678/如下图
好了,至此是不是可以开心的抓元素了
首先安装依赖模块 wd 额外提下 wd 不支持 python2.7 需要 3.x 以上版本 升级 mac 自带的 python 参见http://blog.csdn.net/wirelessqa/article/details/23261723
然后编码
由于不喜欢睡眠所以自己写个 wait
def wait_element(dr, us, value):
end = time.time() + 30
while 1:
try:
ele = dr.element(us, value)
if ele:
return ele
except:
if time.time() < end:
time.sleep(0.5)
首先在 shell 窗口执行 macaca server --verbose 然后运行代码,执行后台日志如下:
wecashmac:~ wangfang$ macaca server --verbose
{ port: 3456,
verbose: true,
ip: xxx.xxx.x.xxx',
host: 'wecashmac.local',
loaded_time: '2016-09-18 15:49:15' }
hhhhhhhhhhhhh
index.js:17:12 [master] pid:19413 webdriver server start with config:
{ port: 3456,
verbose: true,
ip: '172.16.4.100',
host: 'wecashmac.local',
loaded_time: '2016-09-18 15:49:15' }
middlewares.js:17:10 [master] pid:19413 base middlewares attached
router.js:108:10 [master] pid:19413 router set
webdriver sdk launched
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"autoAcceptAlerts":true,"platformVersion":"9.3","udid":"bbe44d7261aebe28ea51d2f24e35f7913d2171aa","deviceName":"Test","autoDismissAlerts":true,"platformName":"iOS","bundleId":"com.wecash.speed","reuse":2}}
session.js:47:10 [master] pid:19413 Creating session, sessionId: b753f573-3e5a-4bfd-9d98-c0f593833de7.
xctest-client.js:43:14 [master] pid:19413 project path: /usr/local/lib/node_modules/macaca-ios/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
macaca-ios.js:130:10 [master] pid:19413 {
"bundleId": "com.wecash.speed",
"platformVersion": "9.3",
"platformName": "iOS"
}
xctest-client.js:183:12 [master] pid:19413 xcode version: 7.3.1
WebDriverAgent version: 1.0.27
xctest-client.js:156:14 [master] pid:19413 2016-09-18 15:49:27.672 xcodebuild[19419:986656] [MT] IDETestOperationsObserverDebug: (37C074D0-0C4A-4B29-9658-ACE0BA5A2C9C) Beginning test session 37C074D0-0C4A-4B29-9658-ACE0BA5A2C9C with Xcode 7D1014 on target {
deviceSerialNumber: CCQQC4HDGGK3
identifier: bbe44d7261aebe28ea51d2f24e35f7913d2171aa
deviceClass: iPod
deviceName: Test
deviceIdentifier: bbe44d7261aebe28ea51d2f24e35f7913d2171aa
productVersion: 9.3.2
buildVersion: 13F69
deviceSoftwareVersion: 9.3.2 (13F69)
deviceArchitecture: arm64
deviceTotalCapacity: 12827009024
deviceAvailableCapacity: 9248399360
deviceIsTransient: NO
ignored: NO
deviceIsBusy: NO
deviceIsActivated: YES
deviceActivationState: Activated
deviceType:
supportedDeviceFamilies: (
1
)
applications: (null)
provisioningProfiles: (null)
activityProgress: -2
activityTitle:
hasInternalSupport: NO
isSupportedOS: YES
developerDiskMountError: (null)
(null)
} (9.3.2 (13F69))xctest-client.js:156:14 [master] pid:19413 2016-09-18 15:49:27.674 xcodebuild[19419:986692] IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
/Users/wangfang/Library/Developer/Xcode/DerivedData/WebDriverAgent-earnspoghlsscjbxlmzvvcsmvulx/Logs/Test/59FBA46A-CEF9-456C-8085-C48A4A7D72A0/Session-2016-09-18_15:49:27-oqRHeC.logxctest-client.js:156:14 [master] pid:19413 MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/nr/7xm3j0b16bz7nf0qfqthrst00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/b022145f1f79f1b67f08dcbde4a4589d/bbe44d7261aebe28ea51d2f24e35f7913d2171aa/runner-Runner.app
state->new_bundle: /Users/wangfang/Library/Developer/Xcode/DerivedData/WebDriverAgent-earnspoghlsscjbxlmzvvcsmvulx/Build/Products/Debug-iphoneos/runner-Runner.app
state->dst_bundle: /var/folders/nr/7xm3j0b16bz7nf0qfqthrst00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/runner-Runner.app.XDMVjB/runner-Runner.app_sparse.ipa/Payload//runner-Runner.app, binaryDiff flag: FALSE
dst_ipa: /var/folders/nr/7xm3j0b16bz7nf0qfqthrst00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/runner-Runner.app.XDMVjB/runner-Runner.app_sparse.ipaxctest-client.js:156:14 [master] pid:19413 __MDMDirectoryDiff_block_invoke37:1473 calling writeDictToFile with: /var/folders/nr/7xm3j0b16bz7nf0qfqthrst00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/runner-Runner.app.XDMVjB/runner-Runner.app_sparse.ipa/ManifestCache.plist
xctest-client.js:156:14 [master] pid:19413 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/nr/7xm3j0b16bz7nf0qfqthrst00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/runner-Runner.app.XDMVjB/runner-Runner.app_sparse.ipa/ManifestCache.plist
proxy.js:54:14 [master] pid:19413 Proxy: /session:POST to http://192.168.2.254:8100/session:POST with body: {"desiredCapabilities":{"bundleId":"com.wecash.speed","platformVersion":"9.3","platformName":"iOS"}}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"sessionId":"C632B625-BD4D-4A25-82AC-5DF8696213CB","capabilities":{"device":"iphone","browserName":"闪银极速版","sdkVersion":"9.3.2","CFBundleIdentifier":"com.wecash.speed"}},"sessionId":null,...
responseHandler.js:43:14 [master] pid:19413 Send HTTP Respone to Client: {"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0,"value":"{\"autoAcceptAlerts\":true,\"platformVersion\":\"9.3\",\"udid\":\"bbe44d7261aebe28ea51d2f24e35f7913d2171aa\",\"deviceName\":\"Test\",\"autoDismissAlerts\":true,\"platformName\":\"iOS\",\"bundleId\":\"com.wecash.speed\",\"reuse\":2}"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeButton2"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeButton2"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"1D718C35-8D16-4B46-9276-ECD487ADC725","type":"XCUIElementTypeButton","label":"btn login"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"1D718C35-8D16-4B46-9276-ECD487ADC725\",\"type\":\"XCUIElementTypeButton\",\"label\":\"btn login\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/1D718C35-8D16-4B46-9276-ECD487ADC725/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/1D718C35-8D16-4B46-9276-ECD487ADC725/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/1D718C35-8D16-4B46-9276-ECD487ADC725/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"1D718C35-8D16-4B46-9276-ECD487ADC725","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"1D718C35-8D16-4B46-9276-ECD487ADC725","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeTextField1"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeTextField1"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"32019CE8-A0C8-4501-BC0A-309AFEE7A40E","type":"XCUIElementTypeTextField","label":""},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"32019CE8-A0C8-4501-BC0A-309AFEE7A40E\",\"type\":\"XCUIElementTypeTextField\",\"label\":\"\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/32019CE8-A0C8-4501-BC0A-309AFEE7A40E/value, jsonBody: {"value":["1","8","6","3","6","8","4","6","3","7","8"]}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/32019CE8-A0C8-4501-BC0A-309AFEE7A40E/value:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/32019CE8-A0C8-4501-BC0A-309AFEE7A40E/value:POST with body: {"value":["x","x","x","x","x","x","x","x","x","x","x"]}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"32019CE8-A0C8-4501-BC0A-309AFEE7A40E","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"32019CE8-A0C8-4501-BC0A-309AFEE7A40E","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeSecureTextField1"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeSecureTextField1"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"CBA87565-C25A-4683-B73E-B48292520D66","type":"XCUIElementTypeSecureTextField","label":null},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"CBA87565-C25A-4683-B73E-B48292520D66\",\"type\":\"XCUIElementTypeSecureTextField\",\"label\":null}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/CBA87565-C25A-4683-B73E-B48292520D66/value, jsonBody: {"value":["x","x","x","x","x","x","x","x","x","x"]}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/CBA87565-C25A-4683-B73E-B48292520D66/value:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/CBA87565-C25A-4683-B73E-B48292520D66/value:POST with body: {"value":["t","e","s","t","1","2","3","4","5","6"]}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"CBA87565-C25A-4683-B73E-B48292520D66","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"CBA87565-C25A-4683-B73E-B48292520D66","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeButton3"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeButton3"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"89546A55-052E-4650-A177-1CD07FC57D34","type":"XCUIElementTypeButton","label":"登录"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"89546A55-052E-4650-A177-1CD07FC57D34\",\"type\":\"XCUIElementTypeButton\",\"label\":\"登录\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/89546A55-052E-4650-A177-1CD07FC57D34/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/89546A55-052E-4650-A177-1CD07FC57D34/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/89546A55-052E-4650-A177-1CD07FC57D34/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"89546A55-052E-4650-A177-1CD07FC57D34","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"89546A55-052E-4650-A177-1CD07FC57D34","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeButton[@name=\"我\"]"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeButton[@name=\"我\"]"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"using":"xpath","value":"//XCUIElementTypeButton[@name=\"我\"]","description":"unable to find an element"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":7}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"using\":\"xpath\",\"value\":\"//XCUIElementTypeButton[@name=\\"我\\"]\",\"description\":\"unable to find an element\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":7}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeButton[@name=\"我\"]"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeButton[@name=\"我\"]"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F","type":"XCUIElementTypeButton","label":"我"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F\",\"type\":\"XCUIElementTypeButton\",\"label\":\"我\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"E826CE73-DE36-4E14-8ABD-E0BD6DFEEA8F","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//[@name=\"个人设置\"]"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//[@name=\"个人设置\"]"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"25F373DF-FC8A-46D7-BB0C-131ECF75075B","type":"XCUIElementTypeStaticText","label":"个人设置"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"25F373DF-FC8A-46D7-BB0C-131ECF75075B\",\"type\":\"XCUIElementTypeStaticText\",\"label\":\"个人设置\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/25F373DF-FC8A-46D7-BB0C-131ECF75075B/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/25F373DF-FC8A-46D7-BB0C-131ECF75075B/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/25F373DF-FC8A-46D7-BB0C-131ECF75075B/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"25F373DF-FC8A-46D7-BB0C-131ECF75075B","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"25F373DF-FC8A-46D7-BB0C-131ECF75075B","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//[@name=\"退出账号\"]"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//[@name=\"退出账号\"]"}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"EE423EC2-7343-4E79-BBCB-4ADAD1791C7B","type":"XCUIElementTypeButton","label":"退出账号"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"EE423EC2-7343-4E79-BBCB-4ADAD1791C7B\",\"type\":\"XCUIElementTypeButton\",\"label\":\"退出账号\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/EE423EC2-7343-4E79-BBCB-4ADAD1791C7B/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/EE423EC2-7343-4E79-BBCB-4ADAD1791C7B/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/EE423EC2-7343-4E79-BBCB-4ADAD1791C7B/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"EE423EC2-7343-4E79-BBCB-4ADAD1791C7B","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"EE423EC2-7343-4E79-BBCB-4ADAD1791C7B","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element, jsonBody: {"using":"xpath","value":"//XCUIElementTypeApplication1/XCUIElementTypeWindow1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther[4]/XCUIElementTypeOther2/XCUIElementTypeStaticText1"}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element:POST with body: {"using":"xpath","value":"//XCUIElementTypeApplication1/XCUIElementTypeWindow1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOther1/XCUIElementTypeOth...
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{"ELEMENT":"F960DEED-9AF5-4D62-AE41-CCFC09536943","type":"XCUIElementTypeStaticText","label":"确定"},"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"value":"{\"ELEMENT\":\"F960DEED-9AF5-4D62-AE41-CCFC09536943\",\"type\":\"XCUIElementTypeStaticText\",\"label\":\"确定\"}","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: POST url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/F960DEED-9AF5-4D62-AE41-CCFC09536943/click, jsonBody: {}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/temp/accept_alert:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/accept_alert:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"value":{},"sessionId":"temp","status":27}
proxy.js:54:14 [master] pid:19413 Proxy: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7/element/F960DEED-9AF5-4D62-AE41-CCFC09536943/click:POST to http://192.168.2.254:8100/session/C632B625-BD4D-4A25-82AC-5DF8696213CB/element/F960DEED-9AF5-4D62-AE41-CCFC09536943/click:POST with body: {}
proxy.js:67:16 [master] pid:19413 Got response with status 200: {"status":0,"id":"F960DEED-9AF5-4D62-AE41-CCFC09536943","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
session.js:107:14 [master] pid:19413 Send HTTP Respone to Client: {"status":0,"id":"F960DEED-9AF5-4D62-AE41-CCFC09536943","value":"","sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7"}
responseHandler.js:11:12 [master] pid:19413 Recieve HTTP Request from Client: method: DELETE url: /wd/hub/session/b753f573-3e5a-4bfd-9d98-c0f593833de7, jsonBody: {}
macaca-ios.js:258:10 [master] pid:19413 Stoping iOS driver...
macaca-ios.js:284:10 [master] pid:19413 iOS driver cleaned up.
session.js:80:12 [master] pid:19413 Delete session, sessionId: b753f573-3e5a-4bfd-9d98-c0f593833de7
responseHandler.js:43:14 [master] pid:19413 Send HTTP Respone to Client: {"sessionId":"b753f573-3e5a-4bfd-9d98-c0f593833de7","status":0}
xctest-client.js:123:16 [master] pid:19413
Exiting...
python 控制台日志
至此 python 上调用 macaca 执行第一个测试用例成功
ps 关于更多 macaca 命令参见macaca 官方 api