Macaca [公告] Macaca iOS 驱动调整为 USB 通信

达峰的夏天 · 2016年11月07日 · 1928 次阅读

近期 Macaca iOS 端不稳定问题较多issues

针对真机测试将内部通信调整为 USB 通道,请各位升级驱动模块,告别 socket hang up,告别 connect ECONNREFUSED

请升级 xcode 到 8,升级最新 SDK。


升级驱动

$ cnpm i macaca-ios -g

另外需要安装 usbmuxd,走 iproxy 代理,见文档

$ brew install usbmuxd

开发者证书问题

>> xctest-client.js:160:14 [master] pid:47493   Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 10.1'
** TEST FAILED **

此类问题参考 https://testerhome.com/topics/5953

共收到 27 条回复 时间 点赞

使用 usb 后,session 还用么?

#1 楼 @Lihuazhang 有没有 session 已经不影响了,但是还是需要,因为要支持 iOS 多机

多机后 Agent 端口你们修改了么 不动态获取?

#3 楼 @lanxiangtechnical 是动态获取的 8900 后面的端口

这下真机真的可以了!!!

@pieceone 欢迎总结文章发出来哦

我按照文档上 update 了,但是会报错
Error: >> proxy.js:58:18 [master] pid:29343 xctest client proxy error with: Error: socket hang up

更新完成后,我运行 macaca server --verbose 后去运行之前写的脚本,然后看到中间的 Log 有关于 WDA 的报错

xctest-client.js:163:14 [master] pid:29035 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
xctest-client.js:162:14 [master] pid:29035 2016-11-08 17:08:29.011 xcodebuild[29049:597969] Error Domain=com.apple.dtdevicekit Code=-402652994 "App installation failed" UserInfo={NSLocalizedFailureReason=This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed., com.apple.dtdevicekit.stacktrace=(
0 DTDeviceKitBase 0x00000001171f237b DTDKCreateNSError + 113
1 DTDeviceKitBase 0x00000001171f2ab9 DTDK_AMDErrorToNSError + 791
2 DTDeviceKitBase 0x00000001172329df __90-[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 158
3 DVTFoundation 0x000000010ffae9c9 DVTInvokeWithStrongOwnership + 75
4 DTDeviceKitBase 0x0000000117232725 -[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1181
5 IDEiOSSupportCore 0x0000000117128f2f __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.336 + 4597
6 DVTFoundation 0x00000001100d2ce7 __DVTDispatchAsync_block_invoke + 827
7 libdispatch.dylib 0x00007fff96ba6f5f _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x00007fff96b9e128 _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fff96bb4b97 _dispatch_queue_serial_drain + 896
10 libdispatch.dylib 0x00007fff96ba6d41 _dispatch_queue_invoke + 1046
11 libdispatch.dylib 0x00007fff96b9fee0 _dispatch_root_queue_drain + 476
12 libdispatch.dylib 0x00007fff96b9fcb7 _dispatch_worker_thread3 + 99
13 libsystem_pthread.dylib 0x00007fff96deb736 _pthread_wqthread + 1299
14 libsystem_pthread.dylib 0x00007fff96deb211 start_wqthread + 13
), NSLocalizedRecoverySuggestion=This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed., NSLocalizedDescription=App installation failed}
xctest-client.js:163:14 [master] pid:29035 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
xctest-client.js:162:14 [master] pid:29035 2016-11-08 17:08:29.011 xcodebuild[29049:597969] Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}

xctest-client.js:163:14 [master] pid:29035 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
xctest-client.js:162:14 [master] pid:29035
Testing failed:
Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
** TEST FAILED **

然后我把真机上的 WDA 手动删了,这时候重装运行 macaca server --verbose,再去运行脚本时,依然报错,但是错误就变成了 socket hang up

proxy.js:58:18 [master] pid:29035 xctest client proxy error with: Error: socket hang up
/usr/local/lib/node_modules/macaca-ios/node_modules/xlogger/lib/xlogger.js:169
throw new Error(res);
^

Error: >> proxy.js:58:18 [master] pid:29035 xctest client proxy error with: Error: socket hang up
at Logger.error (/usr/local/lib/node_modules/macaca-ios/node_modules/xlogger/lib/xlogger.js:169:9)
at Request.request as _callback
at self.callback (/usr/local/lib/node_modules/macaca-ios/node_modules/xctest-client/node_modules/request/request.js:199:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (/usr/local/lib/node_modules/macaca-ios/node_modules/xctest-client/node_modules/request/request.js:821:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketOnEnd (_http_client.js:346:9)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

#8 楼 @mercynoo 没解决,后来把 macaca 相关的全部删了,然后重新部署也没用,还是报那个错...之前写的 case 都跑不了了。

达峰的夏天 [该话题已被删除] 中提及了此贴 11月10日 09:44

#8 楼 @mercynoo 解决了..是这个不支持 ios9 的手机,把手机升级 ios10 就行了。😭

#11 楼 @fengytn 奇怪 我自己的就是 10.0.2 也出现你那个 encountered an error 怎么都好不了

#12 楼 @mercynoo 那你把环境什么的删了,重新部属一次,估计能行。反正 ios9 上我怎么都弄不好,昨天把环境什么的全删了,重新部署了一次,现在换 ios10 的手机就好了。不过跑 case 跑结束时,也会出 socket hang up,但是之前写的 case 能跑了。

#13 楼 @fengytn 好,我找个时间重新搞一次

请问下,刚入手 macaca,真机测试是不是都是安装的 wda 这个 webdriveragent,wd 这个 python 封装的 webdriveragent 只适用于 simulator 和 web 的测试?

另外,macaca-cli 的安装,完成之后,还要在本机执行一个 macaca server 作用是什么?既然都已经安装了 macaca-cli,而 macaca 的文件夹里面就已经有了 webdriver.py 这个模块,为啥不直接引入,使用就好了?还要 run cases 之前跑一下 macaca server?

谢谢,刚接触,问题可能比较多(google 和百度过,可能是 keyword 不对,但是没有 search 到能引导我解惑的)还请不吝赐教,感谢

@onionyao
自己答下自己,通过不在安装 macaca 的机器上跑 cases 之前,直接执行对应的 py 脚本,从报错的信息来看:(截取部分)
Traceback (most recent call last):
File "./macacaTwo.py", line 19, in setUpClass
cls.driver.init()
File "/Users/onion/.pyenv/versions/3.5.2/lib/python3.5/site-packages/macaca/util.py", line 145, in fluent_interface
ret = func(instance, *args, **kwargs)
File "/Users/onion/.pyenv/versions/3.5.2/lib/python3.5/site-packages/macaca/webdriver.py", line 132, in init
}, False)
File "/Users/onion/.pyenv/versions/3.5.2/lib/python3.5/site-packages/macaca/webdriver.py", line 66, in _execute
...
推测,macaca-cli 的安装成功之后,执行 macaca server,从而使得作为 server 的 webdriver 服务,应用被正常拉起,而该 server 的正常的拉起,决定了在使用 from macaca import webdriver 进行编程的时候,脚本执行过程中,当执行到 init, ret = func(instance, *args, **kwargs) 等需要跟 server 进行交互的时候,就直接报错了

所以需要执行 macaca server 拉起 webdriver 的 server 服务,从而保障 client 脚本与 server 的正常交互(server 底部自行封装完成对浏览器等的调用)。。

不知道理解对不对,不对还请轻喷。。。-。- 总之对执行 macaca server 的原因和意义还不是很清楚

总算是改了。。。。不然真的,真机执行得好蛋疼,各种不稳定。

是代码有问题的,端口转发出错。。要修改 xctest-client.js
具体看这个 issue: https://github.com/alibaba/macaca/issues/304

升级后问题解决

#13 楼 @fengytn 我怎么升级都解决不了 Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)

30楼 已删除

支持

匿名 #23 · 2016年12月28日

使用 usb 后,怎么去连接它得到 session 呢?用 ip+8100 端口是不行的。这里没有弄明白。

匿名 #27 · 2016年12月28日

还有个问题。连接手机得到 sesion 后,怎么得到手机里 xcode 打出的日志呢。PS:脚本代码不是在打包的 mac 机器上

老马 MacOs 环境安装配置 macaca 总结记 中提及了此贴 01月18日 10:58

@xdf “另外需要安装 usbmuxd,走 iproxy 代理”,请问能重新给下这个参考文章的连接吗,原链接 404。

匿名 #32 · 2017年07月05日

use iproxy 127.0.0.1 can connect iphone but ip address can't connect iphone
when i use webdriveragent,i excute iproxy 8100 8100,i can access 127.0.0.1:8100 but can't access 10.243.242.19:8100 10.243.242.19 is my ip.

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册