51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 548|回复: 3
打印 上一主题 下一主题

appium 测试无法打开 app,请各位大神帮忙

[复制链接]
  • TA的每日心情
    无聊
    4 天前
  • 签到天数: 530 天

    连续签到: 2 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2022-7-1 10:50:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    初学appium,使用python写测试脚本,现在可以安装上app,之后无法自动启动app。
    这是我的脚本:
    1. #coding=utf-8
    2. from appium import webdriver
    3. from lib2to3.pgen2.driver import Driver
    4. from lib2to3.tests.support import driver
    5. import os
    6. import time

    7. PATH=lambda p:os.path.abspath(os.path.join(os.path.dirname(file),p))

    8. global driver

    9. desired_caps = {}
    10. desired_caps['platformName'] = 'Android'
    11. desired_caps['platformVersion'] = '4.4.2'
    12. desired_caps['deviceName'] = 'b91b9b66'
    13. #desired_caps['appPackage'] = 'com.zhengyuan.watch'
    14. #desired_caps['appActivity'] = 'com.zhengyuan.watch.logic.launch.AppStart'
    15. desired_caps['app'] = PATH('D:\android\app\rtring_c_zhengyuan.apk')

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

    17. time.sleep(5)

    18. driver.swipe(600,660,10,660,1000)

    19. time.sleep(1)

    20. driver.swipe(600,660,10,660,1000)

    21. time.sleep(1)

    22. log:

    23. info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.4.2","deviceName":"b91b9b66","app":"D:\android\app\rtring_c_zhengyuan.apk","platformName":"Android"}}
    24. info: Client User-Agent string: Python-urllib/2.7
    25. info: [debug] No appActivity desired capability or server param. Parsing from apk.
    26. info: [debug] No appPackage desired capability or server param. Parsing from apk.
    27. info: [debug] Using local app from desired caps: D:\android\app\rtring_c_zhengyuan.apk
    28. info: [debug] Creating new appium session 7ab051a1-8c95-4b9a-a998-f1748ed52d47
    29. info: Starting android appium
    30. info: [debug] Getting Java version
    31. info: Java version is: 1.7.0_79
    32. info: [debug] Checking whether adb is present
    33. info: [debug] Using adb from D:\android\sdk\platform-tools\adb.exe
    34. info: [debug] Parsing package and activity from app manifest
    35. info: [debug] Checking whether aapt is present
    36. info: [debug] Using aapt from D:\android\sdk\build-tools\android-4.4W\aapt.exe
    37. info: [debug] Extracting package and launch activity from manifest.
    38. info: [debug] executing cmd: D:\android\sdk\build-tools\android-4.4W\aapt.exe dump badging D:\android\app\rtring_c_zhengyuan.apk
    39. info: [debug] badging package: com.zhengyuan.watch
    40. info: [debug] badging act: com.zhengyuan.watch.logic.launch.AppStart
    41. info: [debug] Parsed package and activity are: com.zhengyuan.watch/com.zhengyuan.watch.logic.launch.AppStart
    42. info: [debug] Using fast reset? true
    43. info: [debug] Preparing device for session
    44. info: [debug] Checking whether app is actually present
    45. info: Retrieving device
    46. info: [debug] Trying to find a connected android device
    47. info: [debug] Getting connected devices...
    48. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe devices
    49. info: [debug] 1 device(s) connected
    50. info: Found device b91b9b66
    51. info: [debug] Setting device id to b91b9b66
    52. info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
    53. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 wait-for-device
    54. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "echo 'ready'"
    55. info: [debug] Starting logcat capture
    56. info: [debug] Getting device API level
    57. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop ro.build.version.sdk"
    58. info: [debug] Device is at API Level 19
    59. info: Device API level is: 19
    60. info: [debug] Extracting strings for language: default
    61. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop persist.sys.language"
    62. info: [debug] Current device persist.sys.language: zh
    63. info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "D:\android\app\rtring_c_zhengyuan.apk" "C:\Users\admin\AppData\Local\Temp\com.zhengyuan.watch" zh
    64. info: [debug] Reading strings from converted strings.json
    65. info: [debug] Setting language to default
    66. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 push "C:\Users\admin\AppData\Local\Temp\com.zhengyuan.watch\strings.json" /data/local/tmp
    67. info: [debug] Checking whether aapt is present
    68. info: [debug] Using aapt from D:\android\sdk\build-tools\android-4.4W\aapt.exe
    69. info: [debug] Retrieving process from manifest.
    70. info: [debug] executing cmd: D:\android\sdk\build-tools\android-4.4W\aapt.exe dump xmltree D:\android\app\rtring_c_zhengyuan.apk AndroidManifest.xml
    71. info: [debug] Set app process to: com.zhengyuan.watch
    72. info: [debug] Not uninstalling app since server not started with --full-reset
    73. info: [debug] Checking app cert for D:\android\app\rtring_c_zhengyuan.apk.
    74. info: [debug] executing cmd: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" D:\android\app\rtring_c_zhengyuan.apk
    75. info: [debug] App already signed.
    76. info: [debug] Zip-aligning D:\android\app\rtring_c_zhengyuan.apk
    77. info: [debug] Checking whether zipalign is present
    78. info: [debug] Using zipalign from D:\android\sdk\build-tools\android-4.4W\zipalign.exe
    79. info: [debug] Zip-aligning apk.
    80. info: [debug] executing cmd: D:\android\sdk\build-tools\android-4.4W\zipalign.exe -f 4 D:\android\app\rtring_c_zhengyuan.apk C:\Users\admin\AppData\Local\Temp\116210-428-1fgurq6\appium.tmp
    81. info: [debug] MD5 for app is 310a577ec209ceac8a6dee5086a1bf5d
    82. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ls /data/local/tmp/310a577ec209ceac8a6dee5086a1bf5d.apk"
    83. info: [debug] Getting install status for com.zhengyuan.watch
    84. info: [debug] Getting device API level
    85. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop ro.build.version.sdk"
    86. info: [debug] Device is at API Level 19
    87. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "pm list packages -3 com.zhengyuan.watch"
    88. info: [debug] App is installed
    89. info: Installing App
    90. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "mkdir -p /data/local/tmp/"
    91. info: [debug] Removing any old apks
    92. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ls /data/local/tmp/*.apk"
    93. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell rm "/data/local/tmp/8f29ab35c86ad03708a23dfe9aaeeaa0.apk"
    94. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 push "D:\android\app\rtring_c_zhengyuan.apk" /data/local/tmp/310a577ec209ceac8a6dee5086a1bf5d.apk
    95. info: [debug] Uninstalling com.zhengyuan.watch
    96. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "am force-stop com.zhengyuan.watch"
    97. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 uninstall com.zhengyuan.watch
    98. info: [debug] App was uninstalled
    99. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "pm install -r /data/local/tmp/310a577ec209ceac8a6dee5086a1bf5d.apk"
    100. info: [debug] Forwarding system:4724 to device:4724
    101. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 forward tcp:4724 tcp:4724
    102. info: [debug] Pushing appium bootstrap to device...
    103. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
    104. info: [debug] Pushing settings apk to device...
    105. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
    106. info: [debug] Pushing unlock helper app to device...
    107. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
    108. info: Starting App
    109. info: [debug] Attempting to kill all 'uiautomator' processes
    110. info: [debug] Getting all processes with 'uiautomator'
    111. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ps 'uiautomator'"
    112. info: [debug] Attempting to kill process 31936
    113. info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "kill 31936"
    114. info: [debug] Running bootstrap
    115. info: [debug] spawning: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.zhengyuan.watch -e disableAndroidWatchers false
    116. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
    117. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
    118. info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
    119. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
    120. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
    121. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
    122. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
    123. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
    124. info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
    125. info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
    126. info: [debug] [BOOTSTRAP] [debug] Loading json...
    127. error: Unhandled error: Error: getaddrinfo ENOENT
    128. at Object.exports.errnoException (util.js:746:11)
    129. at errnoException (dns.js:49:15)
    130. at GetAddrInfoReqWrap.onlookup as oncomplete context: [POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.4.2","deviceName":"b91b9b66","app":"D:\android\app\rtringc_zhengyuan.apk","platformName":"Android"}}]
    131. info: [debug] [BOOTSTRAP] [debug] json loading complete.
    132. info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
    133. info: <-- POST /wd/hub/session - - ms - -
    134. undefined
    复制代码
    之后就停住了,请大家帮我看看是什么问题,纠结了好几天了,谢谢大家!

    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 1521 天

    连续签到: 5 天

    [LV.Master]测试大本营

    2#
    发表于 2022-7-4 11:04:19 | 只看该作者
    脚本不用安装到手机
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    3 天前
  • 签到天数: 1806 天

    连续签到: 5 天

    [LV.Master]测试大本营

    3#
    发表于 2022-7-4 11:16:56 | 只看该作者
    #desired_caps['appPackage'] = 'com.zhengyuan.watch'
    #desired_caps['appActivity'] = 'com.zhengyuan.watch.logic.launch.AppStart'
    把注释符去掉,让两行代码正常运行
    这个是指定app启动的,我用的是java,这两行是必须声明的,否则appium根本找不到你的app的启动项!
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    前天 08:51
  • 签到天数: 668 天

    连续签到: 6 天

    [LV.9]测试副司令

    4#
    发表于 2022-7-4 11:47:57 | 只看该作者
    不清楚
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-25 04:49 , Processed in 0.066680 second(s), 22 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表