Appium IOS 使用 appium 提示 Instruments crashed on startup

panzhigang · November 12, 2014 · Last by panzhigang replied at November 13, 2014 · 1734 hits

环境信息
appium:1.3.1
ios:8.1

代码:

public void setUp() throws Exception
{
    // 配置appiumDriver
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "IOS");
    capabilities.setCapability("deviceName", "iPhone 6");
    capabilities.setCapability("platformVersion", "8.1");
    capabilities.setCapability("app", "/Users/pan/Music/iTunes/iTunes Media/Mobile Applications/ecmc 4.4.0.ipa");
    driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

appium server 日志:

...
info: [debug] Not setting locale
info: [debug] No iOS / app preferences to set
info: [debug] Starting iOS 8.* simulator log capture
info: [debug] Not pre-launching simulator
info: [debug] No device id or app, not installing to real device.
info: [debug] Starting command proxy.
info: [debug] Instruments socket server started at /tmp/instruments_sock
info: [debug] Starting instruments
info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (8.1 Simulator)
info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (8.1 Simulator)" /var/folders/mk/6zc3832x0xq6wyzf_vb9dyth0000gp/T/1141012-1123-18r1mft/Payload/ecmc.app -e UIASCRIPT "/Users/pan/Library/Application Support/appium/bootstrap/bootstrap-06a3f3a7491d04aa.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Failed looking up pid of launched process
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
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] Cleaning sim data files
info: [debug] Executing: xcrun simctl erase A98CA3E4-F325-4BEF-862D-392022427324
info: [debug] Executing: xcrun simctl erase A98CA3E4-F325-4BEF-862D-392022427324
info: [debug] Executing: xcrun simctl erase A98CA3E4-F325-4BEF-862D-392022427324
info: [debug] Executing: xcrun simctl erase A98CA3E4-F325-4BEF-862D-392022427324
info: [debug] Executing: xcrun simctl erase A98CA3E4-F325-4BEF-862D-392022427324
error: Could not reset simulator. Leaving as is. Error: Command failed:  // stderr: 
info: [debug] Cleaning app data files
info: [debug] Deleting /Users/pan/Library/Developer/CoreSimulator/Devices/A98CA3E4-F325-4BEF-862D-392022427324/data/Containers/Data/Application/87EDDD84-876A-4919-BC01-4A13112401A4
info: [debug] Deleting /Users/pan/Library/Developer/CoreSimulator/Devices/A98CA3E4-F325-4BEF-862D-392022427324/data/Containers/Bundle/Application/A842B069-2BCD-4CF9-A5A5-A18ADF48673B
info: [debug] Deleting /Users/pan/Library/Developer/CoreSimulator/Devices/A98CA3E4-F325-4BEF-862D-392022427324/data/Library/Preferences/com.jsmcc.ZP7267A6ES.plist
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: [debug] Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:392:31)
    at null.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:313:12)
    at ChildProcess.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:810:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Instruments crashed on startup)","origValue":"Instruments crashed on startup"},"sessionId":null}
info: <-- POST /wd/hub/session 500 236396.827 ms - 182 

eclipse 错误信息:

org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Instruments crashed on startup) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 237.89 seconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: 'promote.cache-dns.local', ip: '192.168.134.128', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.6.0_65'
Driver info: io.appium.java_client.AppiumDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:84)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:43)
    at cn.xwtec.app.Connection.setUp(Connection.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException
    at cn.xwtec.app.Connection.tearDown(Connection.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
......

有哪个兄弟遇到这问题的帮忙看下吧

共收到 15 条回复 时间 点赞

ios 8.1 在设置里面 有个 developer ,把里面的 enable ui automation 打开

@wozaihouma 我用的是模拟器,enable ui automation 已经打开,执行出现上面的问题

#2 楼 @panzhigang 重启机子试试或者直接用 UIAutomation 跑一下

用的模拟器吗?ipa 文件好像不能安装到模拟器上。换 app 为后缀的文件试试。

@xiaomayi0323 已经重启了,还是不行 请问下你说的用 UIAutomation 跑一下是怎么玩的

@liqing380 我看那个建议里面有这么一句 “i don't think it's a good idea to use an app that's already in the sim folder” 是说不建议把 app 存在手机里的意思吗? 我 app 是在 mac 系统里的

@april46 是用的模拟器 我用 app 后缀的试了,还是一样的问题

@xiaomayi0323 @liqing380 @april46
我手动使用 Instruments -w 51DC074E-59DC-437B-AD4B-4EC70B715047 执行了下,提示

Waiting for device to boot...
Instruments Usage Error : Could not remove existing output document 'file:///Applications/Xcode.app/Contents/Applications/instrumentscli0.trace': Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “instrumentscli0.trace” in the folder “Applications”." UserInfo=0x7fefe0604160 {NSFilePath=/Applications/Xcode.app/Contents/Applications/instrumentscli0.trace, NSUnderlyingError=0x7fefe06c0890 "The operation couldn’t be completed. Permission denied"}.

我看了下/Applications/Xcode.app/Contents/Applications 里文件用户和组分别是:root wheel
能不能麻烦看下这个目录下文件的属主

@panzhigang 没遇到这种情况~~我上次配置 8.1 也打不开。。。不然你试试 7.1?如果 7.1 可以的话。。。

#6 楼 @panzhigang 就是直接使用 UIAutomation,可以看一下我发的这篇帖子
http://testerhome.com/topics/1432

楼主我也遇到来这样的问题,请问你解决了吗

@kristina 重新编译个模拟器的 app 文件就可以了

14Floor has deleted

#13 楼 @panzhigang 嗯谢了,不过后来发现不是这个问题导致~

请问你是怎么解决的呢,谢谢!

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up