Appium appium.app Inspector 启动方法

陈恒捷 · 2015年04月15日 · 最后由 ming 回复于 2016年12月05日 · 3913 次阅读
本帖已被设为精华帖!

最近有一些学习使用 appium 的同学在尝试使用它的 exe / app 中的 Inspector 功能时出错,因此在这里说明一下如何让 Inspector 工具能正常工作。

演示环境

  • Appium.app 1.3.4

  • iOS 模拟器:iPhone 6 (8.3 Simulator)

  • Android 模拟器:genymotion 的 Google Nexus 4 - 4.4.4 - API 19 - 768x1280

虽然演示环境使用的是 mac ,但里面对于 Android 的参数设置是和 windows exe 通用的。

什么是 Inspector 工具

Inspector 工具的作用是通过截图查看元素对应节点,进而更加直观地获取到合适的元素定位器。在可以工作的情况下,它的界面如下 ( mac 上 appium.app 的 Inspector):

它主要由两部分组成。左侧是当前屏幕的节点树(类似于 driver.getSource() 返回的结果),右侧是当前屏幕的截图 ( driver.getScreenShot() ) 辅以能标明被选中节点所指的元素位置的红色方框。

它设计用途是通过获取当前屏幕的节点树及截图,让用户直观地看到节点树的节点对应屏幕的哪个元素,并辅以简单的录制脚本功能( mac 版录制功能较多,windows 版目前相对少很多)

Inspector 的使用前提

如上面所说,Inspector 依靠 driver 的 getSource()getScreenShot() 方法获取截图及节点树,因此它的使用前提是你已经建立了 session 。

建立 session 有两种方法:

1、在你的脚本中使用合适的 caps 建立 WebDriver 实例。

2、在启动 appium server 时加入建立 session 所需参数及 --pre-launch

第一种相信能用 appium 跑通脚本的都知道如何使用。但每次都需要启动脚本才能用 Inspector 略嫌麻烦,因此我这里主要介绍第二种方法。

在图形化界面中建立 session

在 mac 版的 appium.app 的界面中,有两个设置各平台参数的菜单:

注意,虽然这里设置的值名称看起来和用例里的 caps 差不多,但这里设置的其实是 server arguments

对于建立 session ,我们必须设定的参数有:

  • Android: App path, 需要使用的模拟器或真机已经启动并能通过 adb devices 看到

  • iOS: App path, UDID(真机)或 force device(模拟器), platform version

记得要在你设定了的参数前打钩才是生效的哦。

然后我们在 General Settings 里面勾选 Pre-launch application:

最后点击 Launch 。然后 appium server 就会在启动时按照指定参数自动根据设定的参数开启 session 。这样你就能直接使用 Inspector 工具了。

附录

为了方便大家后面出错后查错,附上正常 Launch 后能直接打开 Inspector 查看元素时的所有 log(均使用模拟器)。

  • iOS 模拟器:
Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --platform-version "8.3" --platform-name "iOS" --app "/Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app" --device-name "iPhone 6" --native-instruments-lib

info: [debug] Starting Appium in pre-launch mode

info: Pre-launching app

info: [debug] Using local app from command line: /Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app

info: [debug] Creating new appium session afd48ecc-4f20-4e42-a0c3-99f76d9a4548

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.3

info: [debug] Checking whether instruments supports our device string
info: [debug] Getting list of devices instruments supports

info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.3","iOSSDKVersion":"8.3","deviceName":"iPhone 6","platformVersion":"8.3"}

info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.3 Simulator)'
info: [debug] iOS sim UDID is E23DE92A-B6B1-4AEF-9632-4DA8DD7CE630

info: [debug] Detecting automation tracetemplate

info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML

`parseFileSync()` is deprecated. Use `parseStringSync()` instead.

info: [debug] Could not parse plist file (as XML) at /Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn't exist
info: [debug] Getting bundle ID from app
info: [debug] Parsed app Info.plist (as binary)
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/hengjiechen/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"sendKeyStrategy":"oneByOne"}

info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...

info: [debug] Dynamic bootstrap path: /Users/hengjiechen/Library/Application Support/appium/bootstrap/bootstrap-a4a902c9cce7b6cb.js
info: [debug] Reusing dynamic bootstrap: /Users/hengjiechen/Library/Application Support/appium/bootstrap/bootstrap-a4a902c9cce7b6cb.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.3","iOSSDKVersion":"8.3","deviceName":"iPhone 6","platformVersion":"8.3"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.3 Simulator)'
info: [debug] We're on iOS7.1+ so forcing defaultDevice on
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.3","iOSSDKVersion":"8.3","deviceName":"iPhone 6","platformVersion":"8.3"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 6 (8.3 Simulator)'
info: [debug] Parsed app Info.plist (as binary)

info: [debug] Wrote new app Info.plist with device type
info: [debug] Checking whether we need to set app preferences
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 E23DE92A-B6B1-4AEF-9632-4DA8DD7CE630

info: [debug] Cleaning app data files

warn: Applications directory /Users/hengjiechen/Library/Developer/CoreSimulator/Devices/E23DE92A-B6B1-4AEF-9632-4DA8DD7CE630/data/Containers/Data/Application doesn't exist. Have you run this simulator before?

warn: Applications directory /Users/hengjiechen/Library/Developer/CoreSimulator/Devices/E23DE92A-B6B1-4AEF-9632-4DA8DD7CE630/data/Containers/Bundle/Application doesn't exist. Have you run this simulator before?
info: Couldn't find app directories to delete. Probably it's not installed
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.3 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.3 Simulator)" /Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app -e UIASCRIPT "/Users/hengjiechen/Library/Application Support/appium/bootstrap/bootstrap-a4a902c9cce7b6cb.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {"global":90000}

info: [debug] [INST] Waiting for device to boot...

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-04-15 15:09:11 +0000 Debug: evaluation finished

info: [debug] [INST] 2015-04-15 15:09:11 +0000 Debug: responding with:
info: [debug] [INST] 2015-04-15 15:09:11 +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')"
info: [debug] Sending command to instruments: au.setScreenOrientation('PORTRAIT')

info: [debug] [INST] 2015-04-15 15:09:12 +0000 Debug: Got new command 1 from instruments: au.setScreenOrientation('PORTRAIT')
info: [debug] [INST] 2015-04-15 15:09:12 +0000 Debug: evaluating au.setScreenOrientation('PORTRAIT')

info: [debug] [INST] 2015-04-15 15:09:12 +0000 Debug: target.setDeviceOrientation("1")

info: [debug] [INST] 2015-04-15 15:09:13 +0000 Debug: evaluation finished

info: [debug] [INST] 2015-04-15 15:09:13 +0000 Debug: responding with:
info: [debug] [INST] 2015-04-15 15:09:13 +0000 Debug: Running system command #2: /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":"PORTRAIT"}...

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

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

info: [debug] Waiting for app source to contain elements
info: [debug] Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
info: [debug] Sending command to instruments: au.mainApp().getTreeForXML()

info: [debug] [INST] 2015-04-15 15:09:14 +0000 Debug: Got new command 2 from instruments: au.mainApp().getTreeForXML()

info: [debug] [INST] 2015-04-15 15:09:14 +0000 Debug: evaluating au.mainApp().getTreeForXML()

info: [debug] [INST] 2015-04-15 15:09:15 +0000 Debug: evaluation finished

info: [debug] [INST] 2015-04-15 15:09:15 +0000 Debug: responding with:d":true,"valid":true,"visible":true,"hint":null,"path":"/0/0","x":0,"y":0,"width":375,"height":667},">":[]}},{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1","x":0,"y":0.6875,"width":375,"height":665.625},">":[{"UIANavigationBar":{"@":{"name":"My To-Do List","label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/0","x":0,"y":24.125,"width":375,"height":51.5625},">":[{"UIAImage":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/0/0","x":0,"y":0.6875,"width":375,"height":75},">":[{"UIAImage":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/0/0/0","x":0,"y":75.6875,"width":375,"height":0.5859375},">":[]}}]}},{"UIAButton":{"@":{"name":"Back","label":"Back","value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/0/1","x":9.375,"y":37.6015625,"width":24.609375,"height":24.609375},">":[]}},{"UIAStaticText":{"@":{"name":"My To-Do List","label":"My To-Do List","value":"My To-Do List","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/0/2","x":123.6328125,"y":33.5,"width":128.3203125,"height":31.640625},">":[]}},{"UIAButton":{"@":{"name":"Add","label":"Add","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/0/3","x":322.8515625,"y":31.15625,"width":46.875,"height":35.15625},">":[]}}]}},{"UIATableView":{"@":{"name":null,"label":null,"value":"rows 1 to 3 of 3","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1","x":0,"y":0.6875,"width":375,"height":665.625},">":[{"UIATableCell":{"@":{"name":"Buy milk","label":null,"value":"","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/0","x":0,"y":75.6875,"width":375,"height":51.5625},">":[{"UIAStaticText":{"@":{"name":"Buy milk","label":"Buy milk","value":"Buy milk","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/0/0","x":17.578125,"y":75.6875,"width":339.84375,"height":50.9765625},">":[]}}]}},{"UIATableCell":{"@":{"name":"Buy eggs","label":null,"value":"","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/1","x":0,"y":127.25,"width":375,"height":51.5625},">":[{"UIAStaticText":{"@":{"name":"Buy eggs","label":"Buy eggs","value":"Buy eggs","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/1/0","x":17.578125,"y":127.25,"width":339.84375,"height":50.9765625},">":[]}}]}},{"UIATableCell":{"@":{"name":"Read a book","label":null,"value":"","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/2","x":0,"y":178.8125,"width":375,"height":51.5625},">":[{"UIAStaticText":{"@":{"name":"Read a book","label":"Read a book","value":"Read a book","dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/1/1/2/0","x":17.578125,"y":178.8125,"width":339.84375,"height":50.9765625},">":[]}}]}}]}},{"UIAToolbar":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/2","x":0,"y":666.3125,"width":375,"height":51.5625},">":[{"UIAImage":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/2/0","x":0,"y":665.7265625,"width":375,"height":0.5859375},">":[]}},{"UIAImage":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/1/2/1","x":0,"y":666.3125,"width":375,"height":51.5625},">":[]}}]}}]}},{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":false,"hint":null,"path":"/0/2","x":0,"y":0.6875,"width":375,"height":665.625},">":[]}},{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enab
led":true,"valid":true,"visible":true,"hint":null,"path":"/0/3","x":0,"y":0.6875,"width":375,"height":665.625},">":[{"UIAStatusBar":{"@":{"name":null,"label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0/3/0","x":0,"y":0.6875,"width":375,"height":23.4375},">":[{"UIAElement":{"@":{"name":"Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top","label":null,"value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":"Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top","path":"/0/3/0/0","x":7.03125,"y":0.6875,"width":44.53125,"height":23.4375},">":[]}},{"UIAElement":{"@":{"name":"3 of 3 Wi-Fi bars","label":"3 of 3 Wi-Fi bars","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":"Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top","path":"/0/3/0/1","x":57.421875,"y":0.6875,"width":15.234375,"height":23.4375},">":[]}},{"UIAElement":{"@":{"name":"11:09 PM","label":"11:09 PM","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":"Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top","path":"/0/3/0/2","x":158.203125,"y":0.6875,"width":59.765625,"height":23.4375},">":[]}},{"UIAElement":{"@":{"name":"100% battery power","label":"100% battery power","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":"Swipe down with three fingers to reveal the notification center., Swipe up with three fingers to reveal the control center, Double-tap to scroll to top","path":"/0/3/0/3","x":339.84375,"y":0.6875,"width":29.296875,"height":23.4375},">":[]}}]}}]}}]}}}
info: [debug] [INST] 2015-04-15 15:09:15 +0000 Debug: Running system command #3: /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":{"UIAApplication":{"@":{"name":"ToDoList","label":"ToDoList","value":null,"dom"...

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

info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":{"UIAApplication":{"@":{"name":"ToDoList","label":"ToDoList","value":null,"dom":null,"enabled":true,"valid":true,"visible":true,"hint":null,"path":"/0","x":0,"y":24.125,"width":375,"height":642.1875},">":[{"UIAWindow":{"@":{"name":null,"label":null,"value":null,"dom":null,"enable
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 7200 secs
info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {"app":"/Users/hengjiechen/Develop/IOSTutorial/ToDoList/build/Release-iphonesimulator/ToDoList.app","launch":true,"nativeInstrumentsLib":true,"deviceName":"iPhone 6","platformName":"iOS","platformVersion":"8.3","defaultCommandTimeout":7200}
info: Console LogLevel: debug
  • Android 模拟器:
Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --automation-name "Appium" --platform-name "Android" --platform-version "4.4" --app "/Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk"

info: [debug] Starting Appium in pre-launch mode

info: Pre-launching app
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from command line: /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk
info: [debug] Creating new appium session 7f9dca21-0764-4c47-982c-127d88383f91
info: Starting android appium
info: [debug] Getting Java version

info: Java version is: 1.8.0_25

info: [debug] Using fast reset? true
info: [debug] Preparing device for session

info: [debug] Checking whether app is actually present
info: [debug] Checking whether adb is present

info: [debug] Using adb from /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb devices

info: [debug] 1 device(s) connected

info: Found device 192.168.56.101:5555
info: [debug] Setting device id to 192.168.56.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 wait-for-device

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "echo 'ready'"

info: [debug] Starting logcat capture

info: [debug] Parsing package and activity from app manifest

info: [debug] Checking whether aapt is present

info: [debug] Using aapt from /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt dump badging /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk

info: [debug] badging package: com.chjvps.hengjiechen.chjapp
info: [debug] badging act: com.chjvps.hengjiechen.chjapp.MainActivity
info: [debug] Parsed package and activity are: com.chjvps.hengjiechen.chjapp/com.chjvps.hengjiechen.chjapp.MainActivity
info: [debug] Getting device API level

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"

info: [debug] Device is at API Level 19
info: Device API level is: 19

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "getprop persist.sys.language"

info: [debug] Current device persist.sys.language: en

info: [debug] java -jar "/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk" "/tmp/com.chjvps.hengjiechen.chjapp" en

info: [debug] No strings.xml for language 'en', getting default strings.xml

info: [debug] java -jar "/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar" "stringsFromApk" "/Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk" "/tmp/com.chjvps.hengjiechen.chjapp"

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 push "/tmp/com.chjvps.hengjiechen.chjapp/strings.json" /data/local/tmp

info: [debug] Checking whether aapt is present

info: [debug] Using aapt from /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/aapt dump xmltree /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk AndroidManifest.xml

info: [debug] Set app process to: com.chjvps.hengjiechen.chjapp
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk.
info: [debug] executing cmd: java -jar /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/jars/verify.jar /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk

info: [debug] App already signed.

info: [debug] Zip-aligning /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign

info: [debug] Zip-aligning apk.
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/build-tools/android-4.4W/zipalign -f 4 /Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk /var/folders/_c/j72s8y7x1cld6t7mvpvtxtnh0000gn/T/appium115315-12453-1pzget8.tmp

info: [debug] MD5 for app is 8cc24b300a7b1f9b2d3b762646b06745

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "ls /data/local/tmp/8cc24b300a7b1f9b2d3b762646b06745.apk"

info: [debug] Getting install status for com.chjvps.hengjiechen.chjapp

info: [debug] Getting device API level
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"

info: [debug] Device is at API Level 19

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "pm list packages -3 com.chjvps.hengjiechen.chjapp"

info: [debug] App is installed

info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "am force-stop com.chjvps.hengjiechen.chjapp"

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "pm clear com.chjvps.hengjiechen.chjapp"

info: [debug] Forwarding system:4724 to device:4724

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 forward tcp:4724 tcp:4724

info: [debug] Pushing appium bootstrap to device...

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 push "/Applications/Appium.app/Contents/Resources/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar" /data/local/tmp/

info: [debug] Pushing settings apk to device...

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 install "/Applications/Appium.app/Contents/Resources/node_modules/appium/build/settings_apk/settings_apk-debug.apk"

info: [debug] Pushing unlock helper app to device...

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 install "/Applications/Appium.app/Contents/Resources/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk"

info: Starting App

info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "ps 'uiautomator'"

info: [debug] No matching processes found

info: [debug] Running bootstrap
info: [debug] spawning: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap

info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1

info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1

info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.

info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "dumpsys window"

info: [debug] Screen already unlocked, continuing.

info: [debug] Pushing command to appium work queue: ["getDataDir",{}]

info: [debug] dataDir set to: /data
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data","status":0}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] Getting device API level
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "getprop ro.build.version.sdk"
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}

info: [debug] Device is at API Level 19

info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.chjvps.hengjiechen.chjapp/com.chjvps.hengjiechen.chjapp.MainActivity"

info: [debug] Waiting for pkg "com.chjvps.hengjiechen.chjapp" and activity "com.chjvps.hengjiechen.chjapp.MainActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: /Applications/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb -s 192.168.56.101:5555 shell "dumpsys window windows"

info: [debug] Device launched! Ready for commands

info: [debug] Setting command timeout to the default of 7200 secs

info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {"app":"/Users/hengjiechen/Develop/uiautomator_test/app/chjapp/app/build/outputs/apk/app-debug.apk","launch":true,"platformName":"Android","platformVersion":"4.4","automationName":"Appium","defaultCommandTimeout":7200}
info: Console LogLevel: debug
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 30 条回复 时间 点赞

不错啊,恒洁,详细的基础分享

#1 楼 @testly 谢谢支持。本来没打算写的,只是最近 Q 群问这个的人比较多,而且让他们先开 session ,大多都不大清楚什么是 session ,所以写一下。

#2 楼 @chenhengjie123 挺好的,很给力

@chenhengjie123 ,您好,按你说的设置,Launch 失败,能帮我看下是什么问题吗?
日志如下:Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --platform-version "8.2" --platform-name "iOS" --app "com.newgrand.i6" --udid "4508F7A0D193925CBE0441686496409FF000A39A" --show-ios-log --device-name "iPhone 5s" --native-instruments-lib

info: [debug] Starting Appium in pre-launch mode

info: Pre-launching app
info: [debug] App is an iOS bundle, will attempt to run as pre-existing

info: [debug] Creating new appium session 9eef2f0c-89ef-4b8d-8267-99ed029564cd

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 /Applications/Appium.app/Contents/Resources/node_modules/appium/com.newgrand.i6/en.lproj/Localizable.strings

info: Will try to parse the plist file as XML

info: [debug] Could not parse plist file (as XML) at /Applications/Appium.app/Contents/Resources/node_modules/appium/com.newgrand.i6/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings assuming it doesn't exist
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/lee/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/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. Do not manually modify!
...
info: [debug] Dynamic bootstrap path: /Users/lee/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js

info: [debug] Reusing dynamic bootstrap: /Users/lee/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js

info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"iPhone 5s","platformVersion":"8.2"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 5s (8.2 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

info: [debug] Cleaning up appium session

error: Log capture did not start in a reasonable amount of time

error: Could not pre-launch appium: Error: Log capture did not start in a reasonable amount of time

我查到这个相关 issue :
https://github.com/appium/appium/issues/4216
里面有一个人提到

@ShiranDadon was correct about the UDID being incorrect. On my Windows device, I retrieved the UDID from iTunes (not sure where else to get it from on Windows), and iTunes makes all characters in the UDID uppercase. If you use XCode on a Mac to get the UDID, the alphabetic characters are all lowercase (as least for my device).

By using the uppercase UDID, I am able to reproduce the issue. By using the correct UDID from XCode, the issue is NOT reproducible.

你试试把 UDID 改为全小写?

PS:下次贴代码或 log 麻烦用代码块。

@chenhengjie123 ,udid 改成小写出现了新的错误,日志如下

补充:/Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller 我查过这个文件是存在的

Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --platform-version "8.2" --platform-name "iOS" --app "com.newgrand.i6" --udid "4508f7a0d193925cbe0441686496409ff000a39a" --show-ios-log --device-name "iPhone 5s" --native-instruments-lib

info: [debug] Starting Appium in pre-launch mode

info: Pre-launching app

info: [debug] App is an iOS bundle, will attempt to run as pre-existing

info: [debug] Creating new appium session efdb8784-d024-41c8-a9cb-6c55e36768c4

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 /Applications/Appium.app/Contents/Resources/node_modules/appium/com.newgrand.i6/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Applications/Appium.app/Contents/Resources/node_modules/appium/com.newgrand.i6/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings assuming it doesn't exist

info: [debug] Creating instruments

info: [debug] Preparing uiauto bootstrap

info: [debug] Dynamic bootstrap dir: /Users/lee/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/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. Do not manually modify!
...

info: [debug] Dynamic bootstrap path: /Users/lee/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js

info: [debug] Reusing dynamic bootstrap: /Users/lee/Library/Application Support/appium/bootstrap/bootstrap-d5a0fb924946d8d3.js
info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.2","iOSSDKVersion":"8.2","deviceName":"iPhone 5s","platformVersion":"8.2"}
info: [debug] fixDevice is on
info: [debug] Final device string is: 'iPhone 5s (8.2 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

info: [IOS_SYSLOG_ROW ] Apr 16 10:20:19 iPhone locationd[56] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

info: [IOS_SYSLOG_ROW ] Apr 16 10:20:19 iPhone locationd[56] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

info: [debug] Not pre-launching simulator

info: [debug] Creating iDevice object with udid 4508f7a0d193925cbe0441686496409ff000a39a

info: [debug] Couldn't find ideviceinstaller, trying built-in at /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller

error: Could not initialize ideviceinstaller; make sure it is installed and works on your system

info: [debug] Cleaning up appium session

error: Could not pre-launch appium: Error: Could not initialize ideviceinstaller; make sure it is installed and works on your system```





#6 楼 @lsz7741brew install ideviceinstaller 试试? build-in 的那个貌似用不了。

8楼 已删除

@chenhengjie123 非常感谢,我这边终于能启动啦!

之前摸索过一段时间,在 iOS 模拟器上怎么也搞不起来,后来直接用真机,放弃模拟器了!

#10 楼 @mildshark 模拟器没问题啊。只是模拟器的名字和 iOS 版本要对应起来。否则会找不到模拟器。
举个例子,有个模拟器 iPhone 6 ( 8.3 Simulator )
你必须选择 deviceName: iPhone 6, 然后 platformVersion: 8.3 ,否则可能起不来(它会自动把 deviceName 和 platformVersion 组合起来成为 iPhone 6 ( 8.3 Simulator )

这些设置都对,当时的问题是无法在模拟器上安装被测的 app。

为什么 appium 安装 APK 之后,APK 启动闪退啊?用 ADB 命令安装 APP 是没有问题的

#13 楼 @wqy8576 求 logcat 和 appium server 的 log。。。

#13 楼 @wqy8576 或者你另外发帖问吧。
在这里跟帖问不是太合适。

#13 楼 @wqy8576 你的应用是不是有签名校验,appium 安装是会重签名的

若问,如何在 appium 的图形化界面设置比较详细的 desire capability

#18 楼 @turinblueice desired capability 是脚本里设置的,appium 图形化界面主要管 server 的参数。desired capability 属于会话参数。

error: Could not find a device to launch. You requested 'IPhone (8.3)', but the available devices were: ["iPad 2 (8.1) [0596C2E4-3EC7-4F59-9C1E-B914A93A8DC3]","iPad 2 (8.2) [BDCD6A0B-643E-4131-92C8-563A4F6F28B7]","iPad 2 (8.3) [4764BED3-7045-442A-95F4-8D3DE20217E8]","iPad 2 (8.4) [82927FFA-C92D-49CD-A45C-3DED2A508DDD]","iPad 2 (9.0) [D2A87BB7-5675-49FE-92D3-7B7A26B59F24]","iPad 2 (9.1) [F1F5E930-5EBD-4114-81A8-FD7E4E4E20F7]","iPad 2 (9.2) [F103AF2D-526C-49C3-A5EF-BF2BAE568370]","iPad Air (8.1) [3DAA3F31-8FE6-49C1-8ECC-67AC571CCD8A]","iPad Air (8.2) [CC12D1A9-77FD-46FD-9621-6D2BA94A93D2]","iPad Air (8.3) [073C7695-3C3F-4537-89BD-916D5959D5FE]","iPad Air (8.4) [FC1A9F54-8500-49E0-9C23-DB7B40B18296]","iPad Air (9.0) [96D28E79-DA72-4C8C-BE6E-BB062D5FC79A]","iPad Air (9.1) [34008DB7-3AF3-4F80-B153-7D2F0BF371DB]","iPad Air (9.2) [09D37898-1969-4782-BCCA-770E26B27041]","iPad Air 2 (9.0) [369F939A-0547-4672-9604-839E1B9AA25F]","iPad Air 2 (9.1) ...."iPhone 6 (8.1) [ED7B4765-046A-4FED-8C0C-BDC4F55D57F1]","iPhone 6 (8.2) [4262260D-F558-4C43-A09B-2561873E6D21]","iPhone 6 (8.3) [B9281D32-C302-472F-A752-7625FE014DEF]","iPhone 6 (9.0) [47BC2DC1-CC47-445A-90DB-8722571F51E1]","iPhone 6 (9.1) [E2105EE1-E5C2-41F3-B757-54FE9964AA06]","iPhone 6 Plus (8.1) [F6320A87-F071-4FC2-A95E-B51DBAA08255]",....
其实里面是有 Iphone6(8.3)但是不知道为什么 appium 按照 IPhone(8.3)来找,结果就是找不到

21楼 已删除

#2 楼 @chenhengjie123 Hi 楼主 我想请教下,appium1.4.8,ios 真机调试,我勾选了 prelaunch application,已经根据楼上的回复安装了 ideviceinstaller,手机 enable UI Automation。目前 appium 不报错了,但是卡住不动很久以后弹框如下:

appium 日志如下:

Launching Appium with command: '/Applications/Appium.app/Contents/Resources/node/bin/node' lib/server/main.js --command-timeout "7200" --pre-launch --debug-log-spacing --platform-version "9.1" --platform-name "iOS" --app "com.alipay.iphoneclient.butazyh" --udid "187ba13bf48e075f3c201368927d45a5d3d2XXXX" --no-reset --show-ios-log --device-name "iPhone 6 Plus" --native-instruments-lib

info: [debug] Starting Appium in pre-launch mode

info: Pre-launching app
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: ****        NEW SESSION           ***
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************
info: *************************************

info: [debug] App is an iOS bundle, will attempt to run as pre-existing
info: [debug] Creating new appium session b27041bb-beeb-4b5c-99af-04d3e350a49d

info: [debug] Removing any remaining instruments sockets
info: [debug] Cleaned up instruments socket /tmp/instruments_sock
info: [debug] Auto-detecting iOS udid...
info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /Applications/Appium.app/Contents/Resources/node_modules/appium/com.alipay.iphoneclient.butazyh/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Applications/Appium.app/Contents/Resources/node_modules/appium/com.alipay.iphoneclient.butazyh/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings assuming it doesn't exist
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/buta/Library/Application Support/appium/bootstrap
info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/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. Do not manually modify!
...
info: [debug] Dynamic bootstrap path: /Users/buta/Library/Application Support/appium/bootstrap/bootstrap-6745615c424bb0c0.js

info: [debug] Reusing dynamic bootstrap: /Users/buta/Library/Application Support/appium/bootstrap/bootstrap-6745615c424bb0c0.js
info: [debug] Attempting iOS device log capture via libimobiledevice idevicesyslog

info: [debug] Creating iDevice object with udid 187ba13bf48e075f3c201368927d45a5d3d2XXXX 

#22 楼 @huiniuer 貌似原因是创建 iDevice 不成功。

你这个 ipa 直接通过 ideviceinstaller -i app.ipa 可以装成功和打开成功不?

#23 楼 @chenhengjie123 找到原因了,我原来报错的时候根据网上的建议修改了/node_modules/appium/node_modules/node-idevice 文件,所以创建失败了。现在已经 ok 了,多谢~

#13 楼 @wqy8576 请问这个问题怎么解决的?

@chenhengjie123 楼主 ,我的 launch 后报错,“error: Could not pre-launch appium: Error: App did not have elements” 请问什么原因呢

#27 楼 @chuduoluo App did not have elements

你用的是什么 app ?换个试试?

#28 楼 @chenhengjie123 用 xcodebuild 打的 模拟器的 debug 包,曾成功过一次,后来又不行了。。。

#28 楼 @chenhengjie123 xcodebuild -workspace xxx.xcworkspace -scheme xxx -configuration Debug -sdk iphonesimulator9.3 用这个打包的,appium 上的模拟器也是自定义的 9.3,(appium 1.4.13,xcode7.3),Use Native Instruments Library 也勾选了
info: [debug] Waited for 8880ms so far
info: [debug] Pushing command to appium work queue: "au.mainApp().getTreeForXML()"
info[3
9m: [debug] Sending command to instruments: au.mainApp().getTreeForXML()

: [debug] Waited for 9987ms so far

info: [debug] Pushing command to appium work queue: "au.mainApp().getTreeForXML()"

info: [debug] Sending command to instruments: au.mainApp().getTreeForXML()
info: [IOS_SYSLOG_ROW ] Apr 28 10:13:59 MACdeMacBook-Pro-3 mstreamd[865]: (Note ) PS: Media stream daemon stopping.
info: [IOS_SYSLOG_ROW ] Apr 28 10:13:59 MACdeMacBook-Pro-3 mstreamd[865]: (Note ) AS: : Shared Streams daemon has shut down.
info: [IOS_SYSLOG_ROW ] Apr 28 10:13:59 MACdeMacBook-Pro-3 mstreamd[865]: (Warn ) mstreamd: mstreamd shutting down.

error: Could not pre-launch appium: Error: App did not have elements

#30 楼 @chuduoluo 要不你用打真机的包,用真机试试?

[HTTP] --> GET /wd/hub/sessions {}
[MJSONWP] Calling AppiumDriver.getSessions() with args: []
[MJSONWP] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 200 3 ms - 40

[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","newCommandTimeout":"7200","app":"/Users/xiaomingqi/Desktop/ming/TestApp.app","platformVersion":"10.1.1","deviceName":"iPhone 5s","bundleId":"com.pinjian.ghdoctor","automationName":"Appium","udid":"04db8ba37c488014b5adef0bf6ea559893ea84ad"}}

[MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"iOS","new...

[Appium] Creating new IosDriver session
[Appium] Capabilities:
[Appium] platformName: 'iOS'
[Appium] newCommandTimeout: '7200'
[Appium] app: '/Users/xiaomingqi/Desktop/ming/TestApp.app'
[Appium] platformVersion: '10.1.1'
[Appium] deviceName: 'iPhone 5s'
[Appium] bundleId: 'com.pinjian.ghdoctor'
[Appium] automationName: 'Appium'
[Appium] udid: '04db8ba37c488014b5adef0bf6ea559893ea84ad'
[Appium] nativeInstrumentsLib: true
[Appium] showIOSLog: true
[BaseDriver] Capability 'newCommandTimeout' changed from string ('7200') to integer (7200). This may cause unexpected behavior

[BaseDriver] Session created with session id: cf145f4e-85da-458a-84e4-ef1d0bb11dbe

[debug] [iOS] Not auto-detecting udid.
[BaseDriver] Using local app '/Users/xiaomingqi/Desktop/ming/TestApp.app'
[debug] [iOS] Removing any remaining instruments sockets
[debug] [iOS] Cleaned up instruments socket /var/folders/0s/9h3r2djd3hx044c79hs2hg7w0000gn/T/instruments_sock
[debug] [iOS] No language specified. Using default strings

[debug] [iOS] Strings file not found. Looking in 'en.lproj' directory

[debug] [iOS] Parsed app 'Localizable.strings'

[debug] [iOS] Creating instruments
[debug] [UIAuto] Preparing bootstrap code
[debug] [UIAuto] Dynamic bootstrap dir: /Users/xiaomingqi/Library/Application Support/appium/bootstrap
[debug] [UIAuto] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/appium-uiauto/build/lib/bin/command-proxy-client.js","instrumentsSock":"/var/folders/0s/9h3r2djd3hx044c79hs2hg7w0000gn/T/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false,"autoDismissAlerts":false,"sendKeyStrategy":"grouped"}

[debug] [UIAuto] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
...

[debug] [UIAuto] Dynamic bootstrap path: /Users/xiaomingqi/Library/Application Support/appium/bootstrap/bootstrap-2ef1e5134d4d6b1c.js

[debug] [UIAuto] Reusing dynamic bootstrap: /Users/xiaomingqi/Library/Application Support/appium/bootstrap/bootstrap-2ef1e5134d4d6b1c.js

[debug] [iOS] Running ios real device reset flow

[debug] [iOSLog] Attempting iOS device log capture via libimobiledevice idevicesyslog

[debug] [iOSLog] Found idevicesyslog: '/usr/local/bin/idevicesyslog'

[debug] [iOS] Creating iDevice object with udid 04db8ba37c488014b5adef0bf6ea559893ea84ad

[debug] [iOS] App is not installed. Will try to install.

[MJSONWP] Encountered internal error running command: Error: Installing /Users/xiaomingqi/Desktop/ming/TestApp.app failed
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-ios-driver/node_modules/node-idevice/main.js:159:6
at ChildProcess.exithandler (child_process.js:193:7)
at emitTwo (events.js💯13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

[HTTP] <-- POST /wd/hub/session 500 433 ms - 197

[HTTP] --> GET /wd/hub/status {}

[MJSONWP] Calling AppiumDriver.getStatus() with args: []

楼主报安装不成功!麻烦你给看看就什么问题?

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