2 qq 34000757 qq_34000757 于 2016.03.10 16:20 提问

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

初学appium,使用python写测试脚本,现在可以安装上app,之后无法自动启动app。
这是我的脚本:
#coding=utf-8
from appium import webdriver
from lib2to3.pgen2.driver import Driver
from lib2to3.tests.support import driver
import os
import time

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

global driver

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

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

time.sleep(5)

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

time.sleep(1)

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

time.sleep(1)

log:

info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.4.2","deviceName":"b91b9b66","app":"D:\android\app\rtring_c_zhengyuan.apk","platformName":"Android"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: D:\android\app\rtring_c_zhengyuan.apk
info: [debug] Creating new appium session 7ab051a1-8c95-4b9a-a998-f1748ed52d47
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.7.0_79
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\android\sdk\platform-tools\adb.exe
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\android\sdk\build-tools\android-4.4W\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: D:\android\sdk\build-tools\android-4.4W\aapt.exe dump badging D:\android\app\rtring_c_zhengyuan.apk
info: [debug] badging package: com.zhengyuan.watch
info: [debug] badging act: com.zhengyuan.watch.logic.launch.AppStart
info: [debug] Parsed package and activity are: com.zhengyuan.watch/com.zhengyuan.watch.logic.launch.AppStart
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device b91b9b66
info: [debug] Setting device id to b91b9b66
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 wait-for-device
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language: zh
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
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
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
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\android\sdk\build-tools\android-4.4W\aapt.exe
info: [debug] Retrieving process from manifest.
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
info: [debug] Set app process to: com.zhengyuan.watch
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for D:\android\app\rtring_c_zhengyuan.apk.
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
info: [debug] App already signed.
info: [debug] Zip-aligning D:\android\app\rtring_c_zhengyuan.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\android\sdk\build-tools\android-4.4W\zipalign.exe
info: [debug] Zip-aligning apk.
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
info: [debug] MD5 for app is 310a577ec209ceac8a6dee5086a1bf5d
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ls /data/local/tmp/310a577ec209ceac8a6dee5086a1bf5d.apk"
info: [debug] Getting install status for com.zhengyuan.watch
info: [debug] Getting device API level
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 19
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "pm list packages -3 com.zhengyuan.watch"
info: [debug] App is installed
info: Installing App
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "mkdir -p /data/local/tmp/"
info: [debug] Removing any old apks
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ls /data/local/tmp/*.apk"
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell rm "/data/local/tmp/8f29ab35c86ad03708a23dfe9aaeeaa0.apk"
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
info: [debug] Uninstalling com.zhengyuan.watch
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "am force-stop com.zhengyuan.watch"
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 uninstall com.zhengyuan.watch
info: [debug] App was uninstalled
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "pm install -r /data/local/tmp/310a577ec209ceac8a6dee5086a1bf5d.apk"
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
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/
info: [debug] Pushing settings apk to device...
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"
info: [debug] Pushing unlock helper app to device...
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"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "ps 'uiautomator'"
info: [debug] Attempting to kill process 31936
info: [debug] executing cmd: D:\android\sdk\platform-tools\adb.exe -s b91b9b66 shell "kill 31936"
info: [debug] Running bootstrap
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
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
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] [BOOTSTRAP] [debug] Loading json...
error: Unhandled error: Error: getaddrinfo ENOENT
at Object.exports.errnoException (util.js:746:11)
at errnoException (dns.js:49:15)
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"}}]
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: <-- POST /wd/hub/session - - ms - -
undefined
之后就停住了,请大家帮我看看是什么问题,纠结了好几天了,谢谢大家!

2个回答

yixueqiubo
yixueqiubo   2016.03.30 11:22

手机上的appium setting 还有unlock删除了,再重启appium就OK了

qq_16560459
qq_16560459   2016.06.15 12:07

你这个问题解决了吗,楼主

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Appium 测试 app 滑屏
公司产品,登录登录成功之后进入首页,底部有4个tab,可以左右滑动和点击切换。 以下是首页的uiautomator的截图: 具体的实现方法如下: setup()和tearDown()就不展示了,直接展示test函数 @Test public void test() throws Exception { // 找到登录按钮并点击 WebElement Logi
appium对于混合app的webview页面的测试
当用appium测试混合型app的webview页面时,通过打印上下文driver.contexts发现只有['NATIVE_APP']无法通过driver.switch_to.context('WEBVIEW')进行转换到webview然后进行测试。 解决方法:在app代码中打开webview的debug模式 if (Build.VERSION.SDK_INT >= Build.VERSIO
Appium怎样驱动手机淘宝APP
import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.Assert; import org.testng.annota...
python自动化测试应用-第4篇(APP测试)--Appium进阶篇
篇4                安卓app自动化测试-Appium API进阶                                                                              --lamecho辣么丑 1.1概要         大家好! 我是lamecho(辣么丑),今天是《安卓app自动化测试》的第四篇,可以说是使用appi
appium 运行时不重新安装app
如果app已经安装了,在不想安装app的情况下, 可通过dos窗口,通过启动appium带上 –no-reset 即可避免执行用例的时候再次安装app –no-reset 参数解释 如下: –no-reset Don’t reset app state between sessions (iOS: don’t delete app plist files; Android: don’t unin
Appium 使用 Python 运行 Appium 测试的示例
本文转自:https://testerhome.com/topics/8038   感谢 第一步:Python sample(Python示例)下载 https://github.com/appium/sample-code/tree/master/sample-code/examples/python 其中要求安装: pip install
开始实际搭建App测试环境-Appium
搭建Appium的测试环境
appium使用uiautomatorviewer获取APP控件位置
在使用web自动化的时候,像谷歌浏览器就是使用自己自带的检查工具,可以获取到元素的位置,那么在APP方面,就使用uiautomatorviewer这个工具来获取控件的位置 ps:其实我觉得不用管市面上有多少可以获取到APP控件位置的工具,自己只要熟练使用一种就行,工具的作用就是帮助使用者,所以选一款,解决自己的问题,不要想着每一种工具都是尝试,光是安装就要浪费不少时间 uiautomato
Appium - WebView测试(Android)
Appium - WebView测试 作者: Max.Bai 时间: 2015/07 Appium - WebView测试(Android) 现在App都是混合型的,有原生的也包含WebView的,appium测试的时候就需要在原生和WebView之间切换才能完成测试。 1. 查看所有context 查看当前所有的窗口 Set contextNames = d
Appium——处理混合APP中H5的操作
文章首发:《我的博客》背景自己自学APPIUM测试公司的APP有一段时间的,Android原生的元素定位,包括数据处理和逻辑判断也基本上搞熟了,但是公司的APP很坑爹,开发过程中存在混合开发的情况,这就意味着我必须要处理APP里面的webview,真的是很坑爹的东西。操作系统:Mac OS X EI CaptionAppium: 1.4.16Java: java version “1.7.0_79”