环境信息
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)
......

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


↙↙↙阅读原文可查看相关链接,并与作者交流