Appium 在 2.3 的 htc 系统上运行的时候报错。帮忙看看什么原因

Cruise · 2014年07月30日 · 最后由 Cruise 回复于 2014年07月30日 · 1032 次阅读

Python 源码:

def htc_test():
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '2.3'
    desired_caps['deviceName'] = 'HC1AWMC01914'
    desired_caps['app'] = 'F:/source/APK/fruit/fruitSwitch_sc.apk'
    desired_caps['automationName'] = 'Selendroid'
    desired_caps['appPackage'] = 'com.game.fruit.llk'
    desired_caps['appActivity'] = '.WelActivity'

    dr = webdriver.Remote('http://10.8.3.53:4723/wd/hub', desired_caps)

    sleep(3)

appium 服务端报错:

C:\Users\Administrator>appium
info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: LogLevel: debug
info: --> POST /wd/hub/session {"sessionId":null,"desiredCapabilities":{"deviceN
ame":"HC1AWMC01914","automationName":"Selendroid","app":"F:/source/APK/fruit/fru
itSwitch_sc.apk","platformVersion":"2.3","appPackage":"com.game.fruit.llk","plat
formName":"Android","appActivity":".WelActivity"}}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"sessionId":null,"desiredCapabilities":{"d
eviceName":"HC1AWMC01914","automationName":"Selendroid","app":"F:/source/APK/fru
it/fruitSwitch_sc.apk","platformVersion":"2.3","appPackage":"com.game.fruit.llk"
,"platformName":"Android","appActivity":".WelActivity"}}
debug: Using local app from desired caps: F:\source\APK\fruit\fruitSwitch_sc.apk

debug: Creating new appium session 6bd8f678-a40b-40ef-b46f-afe98c290c50
debug: Starting selendroid server
debug: Checking whether selendroid is built yet
debug: Selendroid server exists!
debug: Preparing device for session
debug: Checking whether app is actually present
debug: Checking whether adb is present
debug: Using adb from D:\android_sdk\platform-tools\adb.exe
info: Retrieving device
debug: Trying to find a connected android device
debug: Getting connected devices...
debug: executing: "D:\android_sdk\platform-tools\adb.exe" devices
debug: 1 device(s) connected
info: Found device HC1AWMC01914
debug: Setting device id to HC1AWMC01914
debug: Waiting for device to be ready and to respond to shell commands (timeout
= 5)
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 wait-f
or-device
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"echo 'ready'"
debug: Starting logcat capture
debug: Rebuilt selendroid apk exists, doing nothing
debug: Rebuilt selendroid server already exists, no need to rebuild it with a ne
w manifest
debug: Checking signed status of C:\Windows\Temp\selendroid.com.game.fruit.llk.a
pk
debug: Checking app cert for C:\Windows\Temp\selendroid.com.game.fruit.llk.apk:
java -jar "C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\node_m
odules\appium-adb\jars\verify.jar" "C:\Windows\Temp\selendroid.com.game.fruit.ll
k.apk"
debug: Checking signed status of F:\source\APK\fruit\fruitSwitch_sc.apk
debug: Checking app cert for F:\source\APK\fruit\fruitSwitch_sc.apk: java -jar "
C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\node_modules\appi
um-adb\jars\verify.jar" "F:\source\APK\fruit\fruitSwitch_sc.apk"
debug: App already signed.
debug: Zip-aligning C:\Windows\Temp\selendroid.com.game.fruit.llk.apk
debug: Checking whether zipalign is present
debug: Using zipalign from D:\android_sdk\tools\zipalign.exe
debug: zipAlignApk: "D:\android_sdk\tools\zipalign.exe" -f 4 "C:\Windows\Temp\se
lendroid.com.game.fruit.llk.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\appium114
630-31184-1ms4nje.tmp"
debug: App already signed.
debug: Zip-aligning F:\source\APK\fruit\fruitSwitch_sc.apk
debug: Checking whether zipalign is present
debug: Using zipalign from D:\android_sdk\tools\zipalign.exe
debug: zipAlignApk: "D:\android_sdk\tools\zipalign.exe" -f 4 "F:\source\APK\frui
t\fruitSwitch_sc.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\appium114630-31184-1
7t55jb.tmp"
debug: Getting install status for com.game.fruit.llk.selendroid
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"pm list packages -3 com.game.fruit.llk.selendroid"
debug: App is not installed
debug: Rebuilt selendroid is not installed, installing it
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 instal
l -r "C:\Windows\Temp\selendroid.com.game.fruit.llk.apk"
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"getprop persist.sys.language"
debug: Current device language: zh
debug: java -jar "C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium
\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\source\APK\fruit\fruitSw
itch_sc.apk" "C:\Windows\Temp\com.game.fruit.llk" zh
debug: No strings.xml for language 'zh', getting default strings.xml
debug: java -jar "C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium
\node_modules\appium-adb\jars\strings_from_apk.jar" "F:\source\APK\fruit\fruitSw
itch_sc.apk" "C:\Windows\Temp\com.game.fruit.llk"
debug: Not uninstalling app since server not started with --full-reset
debug: Checking app cert for F:\source\APK\fruit\fruitSwitch_sc.apk: java -jar "
C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\node_modules\appi
um-adb\jars\verify.jar" "F:\source\APK\fruit\fruitSwitch_sc.apk"
debug: App already signed.
debug: Zip-aligning F:\source\APK\fruit\fruitSwitch_sc.apk
debug: Checking whether zipalign is present
debug: Using zipalign from D:\android_sdk\tools\zipalign.exe
debug: zipAlignApk: "D:\android_sdk\tools\zipalign.exe" -f 4 "F:\source\APK\frui
t\fruitSwitch_sc.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\appium114630-31184-1
a9uki3.tmp"
debug: MD5 for app is e2c2efd502d760469e0ecb92087ce727
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"ls /data/local/tmp/e2c2efd502d760469e0ecb92087ce727.apk"
debug: Getting install status for com.game.fruit.llk
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"pm list packages -3 com.game.fruit.llk"
debug: App is not installed
info: Installing App
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"mkdir -p /data/local/tmp/"
debug: Removing any old apks
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"ls /data/local/tmp/*.apk"
debug: Found an apk we want to keep at /data/local/tmp/e2c2efd502d760469e0ecb920
87ce727.apk
debug: Couldn't find any apks to remove
debug: Uninstalling com.game.fruit.llk
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"am force-stop com.game.fruit.llk"
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 uninst
all com.game.fruit.llk
debug: App was uninstalled
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"pm install -r /data/local/tmp/e2c2efd502d760469e0ecb92087ce727.apk"
debug: Forwarding system:8080 to device:8080
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 forwar
d tcp:8080 tcp:8080
debug: Pushing settings apk to device...
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 instal
l "C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\build\settings
_apk\settings_apk-debug.apk"
debug: Pushing unlock helper app to device...
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 instal
l "C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\build\unlock_a
pk\unlock_apk-debug.apk"
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window"
debug: Writing dumpsys output to C:\Users\Administrator\AppData\Roaming\npm\node
_modules\appium\.dumpsys.log
debug: Screen already unlocked, continuing.
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"am instrument -e main_activity 'com.game.fruit.llk.WelActivity' com.game.fruit.
llk.selendroid/io.selendroid.ServerInstrumentation"
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/statu
s","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/statu
s","method":"GET"}
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/statu
s","method":"GET"}
debug: Selendroid server is alive!
debug: Listening for Selendroid logs
debug: Creating Selendroid session
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/sessi
on","method":"POST","json":{"desiredCapabilities":{"warnings":{},"desired":{"dev
iceName":"HC1AWMC01914","automationName":"Selendroid","app":"F:/source/APK/fruit
/fruitSwitch_sc.apk","platformVersion":"2.3","appPackage":"com.game.fruit.llk","
platformName":"Android","appActivity":".WelActivity"},"deviceName":"HC1AWMC01914
","automationName":"Selendroid","app":"F:/source/APK/fruit/fruitSwitch_sc.apk","
platformVersion":"2.3","appPackage":"com.game.fruit.llk","platformName":"Android
","appActivity":".WelActivity"}}}
debug: Successfully started selendroid session
debug: Waiting for pkg "com.game.fruit.llk" and activity ".WelActivity" to be fo
cused
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug: [SELENDROID] http://localhost:8080/wd/hub/session/f8547056-b165-d1ba-4566
-4eafabc168dd
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
error: com.game.fruit.llk/.WelActivity never started. Current: undefined/undefin
ed
debug: Selendroid hasn't started app yet, let's do it manually with adb.startApp

debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -
f 0x10200000 -n com.game.fruit.llk/.WelActivity"
debug: Waiting for pkg "com.game.fruit.llk" and activity ".WelActivity" to be fo
cused
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
debug:
debug: Getting focused package and activity
debug: executing: "D:\android_sdk\platform-tools\adb.exe" -s HC1AWMC01914 shell
"dumpsys window windows"
error: com.game.fruit.llk/.WelActivity never started. Current: undefined/undefin
ed
debug: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: com.game.fruit.llk/.We
lActivity never started. Current: undefined/undefined
debug: Error: com.game.fruit.llk/.WelActivity never started. Current: undefined/
undefined
    at null.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules
\appium\node_modules\appium-adb\lib\adb.js:1278:12)
    at null.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules
\appium\node_modules\appium-adb\lib\adb.js:1227:7)
    at C:\Users\Administrator\AppData\Roaming\npm\node_modules\appium\node_modul
es\appium-adb\lib\adb.js:162:5
    at ChildProcess.exithandler (child_process.js:645:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Socket.<anonymous> (child_process.js:968:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)
debug: Responding to client with error: {"status":33,"value":{"message":"A new s
ession could not be created. (Original error: com.game.fruit.llk/.WelActivity ne
ver started. Current: undefined/undefined)","origValue":"com.game.fruit.llk/.Wel
Activity never started. Current: undefined/undefined"},"sessionId":null}
info: <-- POST /wd/hub/session 500 53205.997 ms - 272

提示:error: Failed to start an Appium session, err was: Error: com.game.fruit.llk/.We
lActivity never started. Current: undefined/undefined

这个代码在 4.2 的模拟器上执行没有问题,但是在 2.3 的 HTC 的真机上执行的时候就报上边的错误。
selenium.common.exceptions.WebDriverException: Message: u'A new session could not be created. (Original error: com.game.fruit.llk/.WelActivity never started. Current: undefined/undefined)'

帮忙看看什么原因导致的??

共收到 4 条回复 时间 点赞

有 2 点猜测:

  1. 被测 app 可以正常在 2.3 系统中运行吗?
  2. 从报错来看,被测 app 没有启动,那么去观察 logcat 日志,看看日志中在启动的时候是否有报错

个人建议:1. 你直接手动安装一下这个 APK,APK 损坏也会出现这样的情况。2. python 写 windows 的路径的时候保持一个好习惯,要么写一个 lambda 返回 abspath,要么你自行转义一下,像这种写法"F:/source/APK/fruit/fruitSwitch_sc.apk" 很危险。。。。

我手动安装 apk 都是么有问题的,我用同事的 4.3 的三星的也是可以打开程序的 ,但是会报错:
selenium.common.exceptions.WebDriverException: Message: u'An unknown server-side error occurred while processing the command.'

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