Appium 求助:运行 test.py 后 appium 启动报 UiAutomator quit before it successfully launched

蜗牛 · 2016年11月17日 · 最后由 蜗牛 回复于 2016年11月18日 · 2064 次阅读

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

**环境**
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

共收到 12 条回复 时间 点赞

为什么发出来这么乱了。。。

应该是 adb 端口被占用了。markdown 一下吧

#2 楼 @neyo 我今天重新弄了一遍没有这个错误了 但是现在dos窗口的提示是这样的

继续求助下
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 dc861be2-d7df-4282-95b7-2bdc34bba51c
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 "C:\Program Files (x86)\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 "C:\Program Files (x86)\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 "C:\Program Files (x86)\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] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
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] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Loading json...
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: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
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] 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":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
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: [debug] executing cmd: "D:\Program Files (x86)\android-sdk_r24.4.1-windows\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.calculator2/.Calculator"
info: [debug] Waiting for pkg "com.android.calculator2" and activity ".Calculator" to be focused
info: [debug] Getting focused package and activity
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 "dumpsys window windows"
info: [debug] Getting focused package and activity
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 "dumpsys window windows"
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId dc861be2-d7df-4282-95b7-2bdc34bba51c
info: <-- POST /wd/hub/session 303 40407.543 ms - 9
info: --> GET /wd/hub/session/dc861be2-d7df-4282-95b7-2bdc34bba51c {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.3.1","deviceName":"Android Emulator","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"},"deviceName":"Android Emulator","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"},"sessionId":"dc861be2-d7df-4282-95b7-2bdc34bba51c"}
info: <-- GET /wd/hub/session/dc861be2-d7df-4282-95b7-2bdc34bba51c 200 2.313 ms - 603 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"4.3.1","deviceName":"Android Emulator","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"},"deviceName":"Android Emulator","platformName":"Android","appActivity":".Calculator","appPackage":"com.android.calculator2"},"sessionId":"dc861be2-d7df-4282-95b7-2bdc34bba51c"}
info: --> POST /wd/hub/session/dc861be2-d7df-4282-95b7-2bdc34bba51c/element {"using":"id","sessionId":"dc861be2-d7df-4282-95b7-2bdc34bba51c","value":"com.android.calculator:id/digit1"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.android.calculator:id/digit1","context":"","multiple":false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.android.calculator:id/digit1","context":"","multiple":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.android.calculator:id/digit1 using ID with the contextId: multiple: false
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.android.calculator:id/digit1]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"No element found","status":7}
info: [debug] Condition unmet after 4887ms. Timing out.
info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"No element found"},"sessionId":"dc861be2-d7df-4282-95b7-2bdc34bba51c"}
info: <-- POST /wd/hub/session/dc861be2-d7df-4282-95b7-2bdc34bba51c/element 500 4888.818 ms - 195
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session
info: [debug] Pressing the HOME button
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 "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 75.818
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in

看起来好乱,格式整一下。你可以先搜下 log 中 error 的信息

#3 楼 @crazysnail 你跑的是计算器的 demo 吗。。你自己实际定位下啊,id 不对

#5 楼 @youkayk 是有点乱== 请问下你说的搜 log 中的 error 的信息是怎么弄--

#6 楼 @neyo 对啊==是计算器的 demo 我看了 ID 好像没错啊--

#8 楼 @crazysnail id 没错的话,在做操作之前加点等待时间,因为 app 刚启动

蜗牛 #10 · 2016年11月18日 Author

#9 楼 @neyo 请问要怎么弄呢 在 python 脚本里面加吗😭

#10 楼 @crazysnail import time ... 然后在 webdriver.Remote 下面加一行 time.sleep(5)

蜗牛 #12 · 2016年11月18日 Author

#11 楼 @neyo import time
import os from selenium import webdriver
import os from selenium.webdriver.remote.command
time.sleep(5)
desired_caps={}
desired_caps['platformName'] ='Android'
desired_caps['version']='4.3.1'
desired_caps['deviceName']='Android emulator-zq1:5554'
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.calculator2:id/digit1").click()
driver.find_element_by_id("com.android.calculator2:id/plus").click()
driver.find_element_by_id("com.android.calculator2:id/digit2").click()
driver.find_element_by_id("com.android.calculator2:id/equal").click()
driver.quit()
这样吗==

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