Appium appium iOS 真机问题

Ti Wang · 2015年04月23日 · 最后由 lihuazhangXNMBYY 回复于 2015年09月11日 · 1797 次阅读

我是新接触在 ios 真机上自动化测试的,以下是配置详情:
Mobile:4s 版本 IOS7.1.1(11D201)
XCODE:6.2(6C131e)
appium:1.3.7
os x:10.9.5

测试用例则在 Windows 机器上,Appium Server 搭建在 Mac 机上,Mobile 是通过 USB 连接在 Mac 机上。
测试的 app 提前安装在 Mobile 上了。

以下则是传给 appium server 的 capabilities,及相关代码:

///capabilities;
capabilities.SetCapability(MobileCapabilityType.AppiumVersion, "1.3.7");
capabilities.SetCapability(MobileCapabilityType.PlatformName, MobilePlatform.IOS);
capabilities.SetCapability(MobileCapabilityType.PlatformVersion, "7.1.1");
capabilities.SetCapability(MobileCapabilityType.DeviceName, "ADiPhone 4S");
capabilities.SetCapability(MobileCapabilityType.App, "com.qiyi.iphone");
capabilities.SetCapability(MobileCapabilityType.UDID, "8bfe0b4ff5aleac8981524cf50edc6710041ed2a");

///appium server;
public static Uri MacRemoteUri = new Uri("http://172.18.20.230:4723/wd/hub");

///远程appium server;
DesiredCapabilities cap = Caps.GetiOS7Caps();
Uri serverUrl = AppiumServers.MacRemoteUri;
Driver = new IOSDriver(serverUrl, cap, TimeSpan.FromSeconds(180));

以下则是 Log 日志:

info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"appium-version":"1.3.7","platformName":"iOS","platformVersion":"7.1.1","deviceName":"ADiPhone 4S","app":"com.qiyi.iphone","udid":"8bfe0b4ff5aleac8981524cf50edc6710041ed2a"}}
info: Client User-Agent string: undefined
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version
info: [debug] App is an iOS bundle, will attempt to run as pre-existing
info: [debug] Creating new appium session 0357334b-a040-4792-b629-a998fbb3bd11
info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Setting Xcode folder
info: [debug] Setting Xcode version
info: [debug] Setting iOS SDK Version
info: [debug] Getting sdk version from xcrun with a timeout
info: [debug] iOS SDK Version set to 8.2
info: [debug] Not checking whether simulator is available since we're on a real device
info: [debug] Detecting automation tracetemplate
info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /usr/local/lib/node_modules/appium/com.qiyi.iphone/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /usr/local/lib/node_modules/appium/com.qiyi.iphone/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings assuming it doesn't exist
info: [debug] Creating instruments
info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/hivs/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/usr/local/Cellar/node/0.12.0/bin/node","commandProxyClientPath":"/usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"grouped"}
info: [debug] Dynamic bootstrap code: // This file is automatically generated. D...ot manually modify!
info: [debug] Dynamic bootstrap path: /Users/hivs/Library/Application Support/appium/bootstrap/bootstrap-bd23e525087f1d93.js
info: [debug] Reusing dynamic bootstrap: /Users/hivs/Library/Application Support/appium/bootstrap/bootstrap-bd23e525087f1d93.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"ADiPhone 4S","platformVersion":"7.1.1"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'ADiPhone 4S (7.1.1 Simulator)'
info: [debug] Not setting device type since we're on a real device
info: [debug] Checking whether we need to set app preferences
info: [debug] Not setting iOS and app preferences since we're on a real device
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons
info: [debug] On a real device; cannot clean device state
info: [debug] Not setting locale because we're using a real device
info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS device log capture via deviceconsole
error: Log capture did not start in a reasonable amount of time
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Log capture did not start in a reasonable amount of time
info: [debug] Error: Log capture did not start in a reasonable amount of time
    at null._onTimeout (/usr/local/lib/node_modules/appium/lib/devices/ios/ios-log.js:137:10)
    at Timer.listOnTimeout (timers.js:110:15)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Log capture did not start in a reasonable amount of time)","origValue":"Log capture did not start in a reasonable amount of time"},"sessionId":null}
info: <-- POST /wd/hub/session 500 10482.361 ms - 234 
info: [debug] Not pre-launching simulator
info: [debug] Creating iDevice object with udid 8bfe0b4ff5aleac8981524cf50edc6710041ed2a
info: [debug] Checking app install status using: /usr/local/lib/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id 8bfe0b4ff5aleac8981524cf50edc6710041ed2a --bundle com.qiyi.iphone

手机也没有交互相应,请大神帮忙分析一下是什么地方出问题了,非常感谢!

共收到 11 条回复 时间 点赞

从 log 来看两台电脑之间通讯没啥问题。问题出在 mac 安装 app 前面的步骤,这里应该是环境配置的问题。
在官方论坛找到这个:https://discuss.appium.io/t/log-capture-did-not-start-in-a-reasonable-amount-of-time/1204/20
你参考一下 43d 的解决方案。

PS:请加头像

多谢你的分析见解,我会尽快上传个人头像。

从提到的官方论坛找到了如下解释:
This issue got resolved as this issue was because the app was not developed for testing once some additional things added to app it starts working without any issue. I'll recommend please check you setup, that might be the reason of the appium not working.

因为我使用的 app 是不知道源码的,是他人所提供,并不知晓是不是 developer 版本, 所以请问你是否也赞同以上所说的原因么?

@chenhengjie123, 如果是 app 的问题,那是不是需要开发者账号,安装 provisioning profile 证书在 Mobile 上呢? thanks.

开发者账号不是这么用的。。。你的 app 没有源码,所以你也不可能改得了它的签名。
从你的 log 来看,你还没走到那一步(必须要 developer 签名的错误信息是instruments Permission to debug com.xxxx.xxxxx was denied , The app must be signed with a devepoment identity (e.g. iOS Developer)

你这个错误的原因是运行 ./deviceconsole -u (your phone udid) 这个命令出错。
如果你使用 npm 安装 appium 的,你可以去 /lib/node_modules/appium/build/ 下运行 ./deviceconsole -u 8bfe0b4ff5aleac8981524cf50edc6710041ed2a 看看输出结果是什么。
如果是使用 appium.app,你用命令行在 appium.app 这个文件夹里找一下 deviceconsole 在哪里,然后再运行上面那个命令。

@chenhengjie123, 谢谢啊, 我对这个 Mac 机不是很熟悉。根据你的方法我是这么操作的在终端:
cd /usr/local/lib/node_modules/appium/build/
然后
./deviceconsole -u 8bfe0b4ff5aleac8981524cf50edc6710041ed2a

在终端得到的结果是:
./deviceconsole: is a directory

貌似没有找到 deviceconsole, 然后我接着在 deviceconsole 目录下运行:
./deviceconsole -u 8bfe0b4ff5aleac8981524cf50edc6710041ed2a

得到以下结果:
hivsSilverlightiMac2:deviceconsole hivs$ ./deviceconsole -u 8bfe0b4ff5a1eac8981524cf50edc6710041ed2a

========================
ASL is here to serve you

Apr 24 18:20:30 mstreamd[169] : (Note ) AS: : Shared Streams daemon has shut down.
Apr 24 18:20:30 mstreamd[169] : (Warn ) mstreamd: mstreamd shutting down.
Apr 24 18:20:30 mstreamd[170] : (Note ) mstreamd: mstreamd starting up.
Apr 24 18:20:30 mstreamd[170] : (Note ) PS: Media stream daemon starting...
Apr 24 18:20:34 AppleIDAuthAgent[68] : SERVER Didn't succeed with .authenticate, and error is ERROR:"CSIdentityErrorDomain" #-100 kCSIdentityAppleIDUnknownError { "file"="/SourceCache/OSServicesAgents/OSServices-616.1/AppleIDAuthentication/AppleIDXMLServerCommunications.cpp", "function"="copyAndHandleXMLErrorResponse", "line"=375, "NSUnderlyingError"=ERROR:"CSIdentityErrorDomain" #-1 { "file"="/SourceCache/OSServicesAgents/OSServices-616.1/AppleIDAuthentication/XMLRPC/XMLRPCShim.mm", "function"="xmlInvoke", "line"=90, "NSLocalizedFailureReason"="NULL response from server", "NSUnderlyingError"=ERROR:"NSURLErrorDomain" #-1009 { "NSErrorFailingURLKey"="https://identity.apple.com/dsservices/dsxmlrpc", "NSErrorFailingURLStringKey"="https://identity.apple.com/dsservices/dsxmlrpc", "NSLocalizedDescription"="The Internet connection appears to be offline.", "NSUnderlyingError"=ERROR:"kCFErrorDomainCFNetwork" #-1009 { "NSErrorFailingURLKey"="https://identity.apple.com/dsservices/dsxmlrpc", "NSErrorFailingURLStringKey"="https://identity.apple.com/dsservices/dsxmlrpc", "NSLocalizedDescription"="The Internet connection appears to be offline." } } } } so releasing session.

请帮忙分析一下什么原因,如果操作不对请帮忙矫正一下,多谢!

#5 楼 @dream_tiwan 大哥,你好好使用下 markdown 啊。。。

@dream_tiwan 还是看下论坛或者 appium 官网文档里关于 appium 如何在 ios 真机上 run 吧,不是简单那个 ipa 就能 run 的,你要拿开发者证书生成证书,并且 device udid 要加到 account 的 device list 里面,并且 provisioning file 要安装在 device 上。如果是 hybird 应用,还要中转 ios-webkit-debug-proxy.

#5 楼 @dream_tiwan 这么看你的 log 能正常输出啊(别管 log 里有没有 error ,这个工具只是负责把 iOS log 输出到 console 里面而已)。
不过建议你还是参考一下 @luis 的说法,先保证你的应用使用正确的编译方式吧。真机运行限制还是挺多的。
官网文档可以看这里: https://github.com/appium/appium/tree/master/docs/cn/appium-setup

9楼 已删除

@luis, chenhengjie123, 非常感谢,我会朝着这个思路去捣鼓捣鼓,少走些弯路。

楼主问个问题 app path iOS 路径在哪里

#6 楼 @lihuazhang 你这个人,每次搜个答案,都看见你冷嘲热讽的

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