新手刚开始学这个 求各位帮忙看看

**环境**
windows7 x64 Java1.8.0_101 Appium-1.3.4.1

**相关信息**
test.py 如下:
#coding=utf-8 from appium import webdriver desired_caps={} desired_caps['platformName'] = 'Android' desired_caps['platformVersion'] = '4.3.1' desired_caps['deviceName'] = 'Android Emulator' desired_caps['appPackage']='com.android.calculator2' desired_caps['appActivity']='.Calculator' driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub,desired_caps') driver.find_element_by_id("com.android.calculator:id/digit1").click() driver.find_element_by_id("com.android.calculator:id/plus").click() driver.find_element_by_id("com.android.calculator:id/digit2").click() driver.find_element_by_id("com.android.calculator:id/equal").click() driver.quit()

APPIUM 日志如下:

Checking if an update is available Update available to new version 1.3.4.2 Starting Node Server info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe) info: Appium REST http interface listener started on 127.0.0.1:4723 info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"avd":"zq1","platformName":"Android","platformVersion":"18","automationName":"Appium"} info: Console LogLevel: debug info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"platformVersion":"4.3.1","deviceName":"Android Emulator","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"}} info: Client User-Agent string: Python-urllib/2.7 info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device info: [debug] Creating new appium session ab6c61a1-2131-4843-a570-add7e1f25c1c info: Starting android appium info: [debug] Getting Java version info: Java version is: 1.8.0_101 info: [debug] Using fast reset? true info: [debug] Preparing device for session info: [debug] Not checking whether app is present since we are assuming it's already on the device info: [debug] Checking whether adb is present info: [debug] Using adb from D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe info: [debug] Trying to find zq1 emulator info: [debug] Getting connected emulators info: [debug] Getting connected devices... info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" devices info: [debug] 1 device(s) connected info: [debug] 1 emulator(s) connected info: [debug] Sending telnet command to device: avd name info: [debug] Getting running emulator port info: [debug] Socket connection to device created info: [debug] Socket connection to device ready info: [debug] Telnet command got response: zq1 info: [debug] Found emulator zq1 in port 5554 info: [debug] Setting device id to emulator-5554 info: [debug] Did not launch AVD because it was already running. info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 wait-for-device info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ready'" info: [debug] Starting logcat capture warn: No app capability, can't parse package/activity info: [debug] Getting device API level info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "getprop ro.build.version.sdk" info: [debug] Device is at API Level 18 info: Device API level is: 18 info: [debug] Apk doesn't exist locally info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "rm -rf /data/local/tmp/strings.json" info: [debug] Not uninstalling app since server not started with --full-reset info: [debug] Skipping install since we launched with a package instead of an app path info: [debug] Forwarding system:4724 to device:4724 info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 forward tcp:4724 tcp:4724 info: [debug] Pushing appium bootstrap to device... info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 push "D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/ info: [debug] Pushing settings apk to device... info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 install "D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk" info: [debug] Pushing unlock helper app to device... info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 install "D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\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: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "ps 'uiautomator'" info: [debug] No matching processes found info: [debug] Running bootstrap info: [debug] spawning: D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap info: [debug] [UIAUTOMATOR STDOUT] Error: /data/local/tmp/AppiumBootstrap.jar does not exist info: [debug] [UIAUTOMATOR STDOUT] Usage: uiautomator [options] info: [debug] [UIAUTOMATOR STDOUT] Available subcommands: info: [debug] [UIAUTOMATOR STDOUT] help: displays help message info: [debug] [UIAUTOMATOR STDOUT] runtest: executes UI automation tests info: [debug] [UIAUTOMATOR STDOUT] runtest [options] info: [debug] [UIAUTOMATOR STDOUT] : < -c | -e class > info: [debug] [UIAUTOMATOR STDOUT] : a list of jar files containing test classes and dependencies. If info: [debug] [UIAUTOMATOR STDOUT] the path is relative, it's assumed to be under /data/local/tmp. Use info: [debug] [UIAUTOMATOR STDOUT] absolute path if the file is elsewhere. Multiple files can be info: [debug] [UIAUTOMATOR STDOUT] specified, separated by space. info: [debug] [UIAUTOMATOR STDOUT] : a list of test class names to run, separated by comma. To info: [debug] [UIAUTOMATOR STDOUT] a single method, use TestClass#testMethod format. The -e or -c option info: [debug] [UIAUTOMATOR STDOUT] may be repeated. This option is not required and if not provided then info: [debug] [UIAUTOMATOR STDOUT] all the tests in provided jars will be run automatically. info: [debug] [UIAUTOMATOR STDOUT] options: info: [debug] [UIAUTOMATOR STDOUT] --nohup: trap SIG_HUP, so test won't terminate even if parent process info: [debug] [UIAUTOMATOR STDOUT] is terminated, e.g. USB is disconnected. info: [debug] [UIAUTOMATOR STDOUT] -e debug [true|false]: wait for debugger to connect before starting. info: [debug] [UIAUTOMATOR STDOUT] -e runner [CLASS]: use specified test runner class instead. If info: [debug] [UIAUTOMATOR STDOUT] unspecified, framework default runner will be used. info: [debug] [UIAUTOMATOR STDOUT] -e : other name-value pairs to be passed to test classes. info: [debug] [UIAUTOMATOR STDOUT] May be repeated. info: [debug] [UIAUTOMATOR STDOUT] -e outputFormat simple | -s: enabled less verbose JUnit style output. info: [debug] [UIAUTOMATOR STDOUT] dump: creates an XML dump of current UI hierarchy info: [debug] [UIAUTOMATOR STDOUT] dump [--verbose][file] info: [debug] [UIAUTOMATOR STDOUT] [--compressed]: dumps compressed layout information. info: [debug] [UIAUTOMATOR STDOUT] [file]: the location where the dumped XML should be stored, default is info: [debug] [UIAUTOMATOR STDOUT] /storage/sdcard/window_dump.xml info: [debug] [UIAUTOMATOR STDOUT] events: prints out accessibility events until terminated info: [debug] UiAutomator exited info: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ping'" info: [debug] Attempting to uninstall app info: [debug] Not uninstalling app since server not started with --full-reset info: [debug] Cleaning up android objects info: [debug] Cleaning up appium session info: [debug] Error: UiAutomator quit before it successfully launched at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android.js:204:23) at Object.async.eachSeries (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\async\lib\async.js:145:20) at androidHybrid.stopChromedriverProxies (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android-hybrid.js:234:9) at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android.js:199:10) at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android.js:221:9) at androidCommon.uninstallApp (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android-common.js:479:5) at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android.js:219:12) at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\lib\devices\android\android.js:228:11) at D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:890:7 at null. (D:\娴嬭瘯\APPIUM\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:172:9) info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: UiAutomator quit before it successfully launched)","origValue":"UiAutomator quit before it successfully launched"},"sessionId":null} info: <-- POST /wd/hub/session 500 38355.472 ms - 218 error: UiAutomator quit before it successfully launched error: Failed to start an Appium session, err was: Error: UiAutomator quit before it successfully launche


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