巴黎的灯光下 发表于 2017-11-23 13:34:42

使用手机可以启动进入应用,但是任何操作都不行。

测试环境:Appium v1.4.16+android6.0.1
测试代码如下:
#coding=utf-8
from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = '1df0f13d'
desired_caps['appPackage'] = 'com.android.calculator2'
desired_caps['appActivity'] = '.Calculator'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

driver.find_element_by_name("1").click()

driver.find_element_by_name("5").click()

driver.find_element_by_name("9").click()

driver.find_element_by_name("delete").click()

driver.find_element_by_name("9").click()

driver.find_element_by_name("5").click()

driver.find_element_by_name("+").click()

driver.find_element_by_name("6").click()

driver.find_element_by_name("=").click()

driver.quit()

巴黎的灯光下 发表于 2017-11-23 13:36:19

测试时可以进入计算器,但是点击就报错了,
> info: --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"1df0f13d","appActivity":".Calculator","platformVersion":"6.0","appPackage":"com.android.calculator2","platformName":"Android"}}
> info: Client User-Agent string: Python-urllib/3.5
> info: Didn't get app but did get Android package, will attempt to launch it on the device
> info: Creating new appium session bbb18055-561a-40a2-bfc5-bf93b7c9069d
> info: Starting android appium
> info: Getting Java version
> info: Java version is: 1.8.0_91
> info: Checking whether adb is present
> info: Using adb from E:\android-sdk\platform-tools\adb.exe
> warn: No app capability, can't parse package/activity
> info: Using fast reset? false
> info: Preparing device for session
> info: Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: Trying to find a connected android device
> info: Getting connected devices...
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe devices
> info: 1 device(s) connected
> info: Found device 1df0f13d
> info: Setting device id to 1df0f13d
> info: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d wait-for-device
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "echo 'ready'"
> info: Starting logcat capture
> info: Getting device API level
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "getprop ro.build.version.sdk"
> info: Device is at API Level 23
> info: Device API level is: 23
> info: Extracting strings for language: default
> info: Apk doesn't exist locally
> info: Could not get strings, but it looks like we had an old strings file anyway, so ignoring
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "rm -rf /data/local/tmp/strings.json"
> info: Not uninstalling app since server not started with --full-reset
> info: Skipping install since we launched with a package instead of an app path
> info: Forwarding system:4724 to device:4724
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d forward tcp:4724 tcp:4724
> info: Pushing appium bootstrap to device...
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
> info: Pushing settings apk to device...
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> info: Pushing unlock helper app to device...
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
> info: Starting App
> info: Attempting to kill all 'uiautomator' processes
> info: Getting all processes with 'uiautomator'
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "ps 'uiautomator'"
> info: No matching processes found
> info: Running bootstrap
> info: spawning: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.calculator2 -e disableAndroidWatchers false
> info: INSTRUMENTATION_STATUS: numtests=1
> info: INSTRUMENTATION_STATUS: stream=
> info: io.appium.android.bootstrap.Bootstrap:
> info: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: INSTRUMENTATION_STATUS: test=testRunServer
> info: INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: INSTRUMENTATION_STATUS: current=1
> info: INSTRUMENTATION_STATUS_CODE: 1
> info: Socket opened on port 4724
> info: Appium Socket Server Ready
> info: Loading json...
> info: Registered crash watchers.
> info: Waking up device if it's not alive
> info: Pushing command to appium work queue: ["wake",{}]
> info: Client connected
> info: Got data from client: {"cmd":"action","action":"wake","params":{}}
> info: Got command of type ACTION
> info: Got command action: wake
> info: Returning result: {"status":0,"value":true}
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window"
> info: Screen already unlocked, continuing.
> info: Pushing command to appium work queue: ["getDataDir",{}]
> info: Got data from client: {"cmd":"action","action":"getDataDir","params":{}}


巴黎的灯光下 发表于 2017-11-23 13:36:43

> info: Got command of type ACTION
> info: Got command action: getDataDir
> info: Returning result: {"status":0,"value":"\/data"}
> info: dataDir set to: /data
> info: Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> info: Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
> info: Got command of type ACTION
> info: Got command action: compressedLayoutHierarchy
> info: Returning result: {"status":0,"value":false}
> info: Getting device API level
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "getprop ro.build.version.sdk"
> info: Device is at API Level 23
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.calculator2/.Calculator"
> info: Waiting for pkg "com.android.calculator2" and activity ".Calculator" to be focused
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> info: Getting focused package and activity
> info: executing cmd: E:\android-sdk\platform-tools\adb.exe -s 1df0f13d shell "dumpsys window windows"
> error: com.android.calculator2/.Calculator never started. Current: com.android.calculator2/.Calculator,
> info: Stopping logcat capture
> info: Logcat terminated with code null, signal SIGTERM
> info: Got data from client: {"cmd":"shutdown"}
> info: Got command of type SHUTDOWN
> info: Returning result: {"status":0,"value":"OK, shutting down"}
> info: Sent shutdown command, waiting for UiAutomator to stop...
> info: Closed client connection
> info: INSTRUMENTATION_STATUS: numtests=1
> info: INSTRUMENTATION_STATUS: stream=.
> info: INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: INSTRUMENTATION_STATUS: test=testRunServer
> info: INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
> info: INSTRUMENTATION_STATUS: current=1
> info: INSTRUMENTATION_STATUS_CODE: 0
> info: INSTRUMENTATION_STATUS: stream=
> info: Test results for WatcherResultPrinter=.
> info: Time: 22.544
> info: OK (1 test)
> info: INSTRUMENTATION_STATUS_CODE: -1
> info: UiAutomator shut down normally
> info: Cleaning up android objects
> info: Cleaning up appium session
> error: Failed to start an Appium session, err was: Error: com.android.calculator2/.Calculator never started. Current: com.android.calculator2/.Calculator,
> info: Error: com.android.calculator2/.Calculator never started. Current: com.android.calculator2/.Calculator,
> at .<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1314:12)
> at .<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1258:7)
> at .<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
> at ChildProcess.exithandler (child_process.js:742:7)
> at ChildProcess.emit (events.js:110:17)
> at maybeClose (child_process.js:1016:16)
> at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
> info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: com.android.calculator2/.Calculator never started. Current: com.android.calculator2/.Calculator,)","origValue":"com.android.calculator2/.Calculator never started. Current: com.android.calculator2/.Calculator,"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 26817.004 ms - 314来个好人帮忙,谢谢!!解决方式:更新到新版本,安装了1.6.4的desktop就可以了。

草帽路飞UU 发表于 2017-11-23 13:46:12

换手机或者更新Appium版本可以解决或者直接下载了个appium desktop就可以了。
页: [1]
查看完整版本: 使用手机可以启动进入应用,但是任何操作都不行。