自动化测试/CI测试

App Inspector 安装笔记及IOS端使用简介

2017-01-22  本文已影响5503人  唐T唐X

做过APP端自动化测试都知道,我们需要一个能够获得手机端控件信息的程序,这样我们才能编写自动化用例。今天我就和大家分享下我是怎么用App Inspector获得IOS端控件信息的。

首先,我们需要安装App Inspector:

我是根据网页 https://testerhome.com/topics/5808 安装的 App Inspector,安装完毕后同样按照里面的说明运行:

安装
$ npm install app-inspector -g
使用
$ app-inspector -u YOUR-DEVICE-ID

安装的时候运气不错,没有出现问题。建议安装前找好一点的代理,否则遇到网络的问题那感觉绝对是酸爽。下面来说说运行的时候遇到的2个问题:

  1. WebDriverAgent编译
    自从开始接触Appuim 1.6.3以来就注定要和WDA有不解之缘。下载了App Inspector后本身它自己就包含了WDA,如我的路径是:/usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/,大家可以从运行App Inspector时的log里面看到自己的路径。一定要在Xcode里面sign并编译它,否则运行肯定是无法成功的,日志里会报需要Develop Team的错误信息。如何sign请查看:http://blog.csdn.net/wuxuehong0306/article/details/54377957

  2. 确保没有冲突的WebDriverAgent在手机端安装
    我在运行时遇到了下面的报错:

>> xctest-client.js:171:14 [master] pid:32671 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:32671 2017-01-22 14:23:19.903 xcodebuild[32677:7859112] 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                     0x00000001164b037b DTDKCreateNSError + 113
    1   DTDeviceKitBase                     0x00000001164b0ab9 DTDK_AMDErrorToNSError + 791
    2   DTDeviceKitBase                     0x00000001164f09df __90-[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 158
    3   DVTFoundation                       0x000000010d680989 DVTInvokeWithStrongOwnership + 75
    4   DTDeviceKitBase                     0x00000001164f0725 -[DTDKRemoteDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1181
    5   IDEiOSSupportCore                   0x00000001163e6e1f __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.336 + 4597
    6   DVTFoundation                       0x000000010d7a4cb7 __DVTDispatchAsync_block_invoke + 827
    7   libdispatch.dylib                   0x00007fff978e4f5f _dispatch_call_block_and_release + 12
    8   libdispatch.dylib                   0x00007fff978dc128 _dispatch_client_callout + 8
    9   libdispatch.dylib                   0x00007fff978f2b97 _dispatch_queue_serial_drain + 896
    10  libdispatch.dylib                   0x00007fff978e4d41 _dispatch_queue_invoke + 1046
    11  libdispatch.dylib                   0x00007fff978ddee0 _dispatch_root_queue_drain + 476
    12  libdispatch.dylib                   0x00007fff978ddcb7 _dispatch_worker_thread3 + 99
    13  libsystem_pthread.dylib             0x00007fff97b28746 _pthread_wqthread + 1299
    14  libsystem_pthread.dylib             0x00007fff97b28221 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}
2017-01-22 14:23:19.903 xcodebuild[32677:7859112] 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:171:14 [master] pid:32671 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:32671 
Testing failed:
>> xctest-client.js:171:14 [master] pid:32671 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:170:14 [master] pid:32671   Test target WebDriverAgentRunner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
** TEST FAILED **
>> xctest-client.js:171:14 [master] pid:32671 please check project: /usr/local/lib/node_modules/app-inspector/node_modules/webdriveragent/WebDriverAgent/WebDriverAgent.xcodeproj
>> xctest-client.js:267:14 [master] pid:32671 killing deviceLogProc pid: 32674
>> xctest-client.js:272:14 [master] pid:32671 killing runnerProc pid: 32677
>> xctest-client.js:278:14 [master] pid:32671 killing iproxyProc pid: 32676
>> xctest-client.js:181:14 [master] pid:32671 xctest client exit with code: 65, signal: null
>> xctest-client.js:145:16 [master] pid:32671 deviceconsole exit with code: null, signal: SIGKILL
>> xctest-client.js:255:14 [master] pid:32671 Fail to start xctest: undefined
>> app-inspector:66:44 [master] pid:32671 undefined
(node:32671) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: >> app-inspector:66:44 [master] pid:32671 undefined
(node:32671) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
>> xctest-client.js:209:14 [master] pid:32671 iproxy exit with code: null, signal: SIGKILL

如果只看最后的log说实话,我根本不知道问题出在哪里。不过我关注到了里面的一句话:

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}

从字面上理解我的手机上貌似有个和现在这个信息不一致的WDA,一查,还真是存在一个之前跑自动化测试时装的一个,删之,再运行,成功!App Inspector会自动打开一个网页:

{4446EE74-A3E3-4377-0938-E65D1946574E}.png

这样,就可以自由的获取ios手机上的空间信息了。

上一篇下一篇

猜你喜欢

热点阅读