源码信息

import os
from random import randint
from appium import webdriver
from time import sleep

app = os.path.join(os.path.dirname(__file__),
                       'test-ios/testpackage/build/Release-iphoneos',
                        'XyqMobile.app')
print app
app = os.path.abspath(app)
driver = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub',desired_capabilities={
                'app': app,
                'platformName': 'iOS',
                'platformVersion': '7.0',
                'deviceName': 'iPhone Simulator'
            })
print "--------------test-----------------"
driver.launch_app()

报错信息

info: Attempting to retry launching instruments, this is retry #3
info: Killall iPhoneSimulator
info: 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: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/game-netease/Desktop/test-ios/testpackage/build/Release-iphoneos/XyqMobile.app -e UIASCRIPT /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments
info: And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd/InstrumentsShim.dylib","LIB_PATH":"/usr/local/lib/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd"}
info: And launch timeouts (in ms): {"global":90000}
info: [INST STDERR] posix spawn failure; aborting launch (binary == /Users/game-netease/Desktop/test-ios/testpackage/build/Release-iphoneos/XyqMobile.app/XyqMobile).

info: [INST STDERR] 2014-09-03 15:54:27.917 instruments[1335:707] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Error Domain=com.apple.instruments Code=1 "Error Starting Recording" UserInfo=0x7ffc14f016f0 {NSLocalizedDescription=Error Starting Recording, NSLocalizedRecoverySuggestion=At least one target failed to launch; aborting run}
Instruments Trace Error : Failed to start trace.

info: [INSTSERVER] Instruments exited with code 253
info: Killall instruments
error: Instruments crashed on startup
info: Stopping iOS log capture
info: Killing the simulator process
info: Killing any other simulator daemons
info: Cleaning app state.
info: Deleted /Users/game-netease/Library/Application Support/iPhone Simulator/7.0.3/Applications
info: Deleted /Users/game-netease/Library/Application Support/iPhone Simulator/7.0.3/Library/Caches/locationd
info: Deleted /Users/game-netease/Library/Application Support/iPhone Simulator/7.0.3/Library/Keychains
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
info: Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:398:31)
    at null.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:328:12)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:807:12)
info: 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}


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