Appium 【已解决】模拟器启动 safari ,报错:Failed to start an Appium session, err was: Error: Instruments crashed on startup

kristina · 2015年03月13日 · 最后由 kristina 回复于 2015年03月16日 · 2330 次阅读

基本环境
mac:10.10.2
appium : 1.3.5
iphone Simulator:iphone 5, ios 8
配置 Java 代码:

DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "iPhone 5");
    capabilities.setCapability("platformName", "iOS");
    capabilities.setCapability("platformVersion", "8.1");
    capabilities.setCapability("app", "safari");        
    driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"),
            capabilities);

日志代码

info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST STDERR] 2015-03-13 14:47:06.294 instruments[873:31261] WebKit Threading Violation - initial use of WebKit from a secondary thread.
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Unable to install app with path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/MobileSafari.app: "(null)"
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

此处省略。。。

error: Could not reset simulator. Leaving as is. Error: Command failed: An error was encountered processing the command (code=146):
Unable to erase contents and settings in current state: Booted

info: [debug] Cleaning mobile safari data files
info: [debug] Deleting /Users/Kristina/Library/Developer/CoreSimulator/Devices/65C402AB-91E1-4512-8E29-00F093463C00/data/Library/Caches/Snapshots/com.apple.mobilesafari

此处省略。。。

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:389:31)
    at null.<anonymous> (/usr/local/lib/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308: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}

Unable to install app with path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/MobileSafari.app: "(null)"
这个路径存在,但是不明白为什么不能 install?启动 safari 的时候失败,模拟器未启动成功。困扰良久,希望能解答~

PS:日志模块 不知道贴什么语言的代码,若有不当之处,还望提出

共收到 6 条回复 时间 点赞

iPhone 上面不是本身就有 Safari 了咩?为何还有 Install 捏……你把 app 路径设置删掉试试?

#1 楼 @weamylady apppath 没有设置啊~我也不知道为什么错误提示是这样的~

附上一下我能正常启动的 Log,用的是和你附上的一模一样的代码。appium 版本 1.3.4,mac:10.10.1:

...
info: [debug] Not pre-launching simulator
info: [debug] Not installing to real device since we're on sim
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 5 (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 5 (8.1 Simulator)" com.apple.mobilesafari -e UIASCRIPT "/Users/hengjiechen/Library/Application Support/appium/bootstrap/bootstrap-a4a902c9cce7b6cb.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/Applications/Appium.app/Contents/Resources/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: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"},"isShuttingDown":false},"sessionId":"ac192025-332c-4922-9c67-851dd6c93fa6"}

info: <-- GET /wd/hub/status 200 4.170 ms - 178 {"status":0,"value":{"build":{"version":"1.3.4","revision":"c8c79a85fbd6870cd6fc3d66d038a115ebe22efe"},"isShuttingDown":false},"sessionId":"ac192025-332c-4922-9c67-851dd6c93fa6"}

info: Instruments is ready to receive commands

info: [debug] Instruments launched. Starting poll loop for new commands.
info: [debug] Setting bootstrap config keys/values
info: [debug] Pushing command to appium work queue: "target = $.target();\nau = $;\n$.isVerbose = true;\n"
info: [debug] Socket data received (2 bytes)
info: [debug] Socket data being routed.
info: [debug] Sending command to instruments: target = $.target();
au = $;
$.isVerbose = true;


info: [debug] [INST] 2015-03-13 14:44:54 +0000 Debug: evaluation finished
       2015-03-13 14:44:54 +0000 Debug: responding with:
info: [debug] [INST] 2015-03-13 14:44:54 +0000 Debug: Running system command #1: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":true}...

info: [debug] Socket data received (27 bytes)

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":true}

info: [debug] Setting initial orientation to PORTRAIT
info: [debug] Pushing command to appium work queue: "au.setScreenOrientation('PORTRAIT')"

对比 log 可以发现你第一条和我不一样的 log 为:

info: [debug] [INST STDERR] 2015-03-13 14:47:06.294 instruments[873:31261] WebKit Threading Violation - initial use of WebKit from a secondary thread.

查找 stackoverflow 找到:http://stackoverflow.com/questions/25919234/webkit-threading-violation-initial-use-of-webkit-from-a-secondary-thread-in-ui。 大致解释是这是由 Xcode 6 命令行工具变化引起的。
你去那里看看能否解决你的问题?

PS:这不是 appium 的问题,是 Instruments 启动 Simulator 的问题,请对症下药,不要纠结 appium。

#3 楼 @chenhengjie123 感谢大神回答,回去升级了 Xcode,sdk 升级到 8.2,现在运行正常。

#4 楼 @kristina 能帮到你就好。那你下次就可以根据 log 来自己找答案了。
PS:我还没达到大神级别……只是我比较喜欢解决问题而已

#5 楼 @chenhengjie123 😄 嗯,自己也猜测可能是模拟器的问题,还是很感谢啊~

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