【js3016金沙官网】0真机测试遇到的问题,解决appium安卓自动化测试时安装app需要手动允许的问题

安卓6.0上述,手提式有线电话机对于权力难点又加快了一步。基本市集上能看出的手提式有线电话机,安装app时都须求手动允许,除非您给了有的用到商铺活动安装的权力。

近年来用7.0的系统尝试做下测试,开掘appium跟7.0的同盟依旧稍微难点,网络说升级到1.5版本就可以,可是本人的是win情形,那招一时半刻不能够用了。

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

appium使用的是adb install来安装使用的,手动试行adb
install安装使用时也会弹窗。那么那几个主题材料怎么解决呢?

私家也是相比纳闷,前些天脚本都足以运转,突然之间就又相当了,很不得已~~~

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

1. root到原生系统

试了下上面二种办法,发现比照一措施说的修改了随后依然要命:(切记修改文件在此以前保留源文件,防止改乱了)

global driver

2. 手动尝试先把包push到手提式有线电话机上,再pm install

注释掉appium安装:

文本路线:/usr/local/lib/node_modules/appium/lib/devices/android/android.js

//this.uninstallApp.bind(this)

//this.installAppForTest.bind(this)

然后本身写一套install/uninstall的主意,每一遍推行case集前调用叁遍。

现实能够参见那篇文章:install/uninstall的方法

—第一种艺术初步—

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’)

3.线程消除

因为appim在运维时会先检查app有未有安装,假若设置成功就不会再去安装。前提是您曾经设置了“noReset”:
true。

搞五个线程,二个担当install
app,一个承担发送adb点击事件。另一方面设置一边防检查测是不是有弹窗。

import time

import os

from threading import Thread

PATH = lambda p: os.path.abspath(

os.path.join(os.path.dirname(__file__), p)

)

def installApp():

os.popen(“adb install ” + PATH(‘../config/app_release.apk’))

def inputEvent():

time.sleep(5)

os.popen(“adb shell input tap 785 1280”)

def install():

t1 = Thread(target=installApp)

t2 = Thread(target=inputEvent)

t1.start()

t2.start()

if __name__ == ‘__main__’:

t1 = Thread(target=installApp)

t2 = Thread(target=inputEvent)

t1.start()

t2.start()

本人用了第二种方式完美消除这一个题目。


原创,转发请声明出处。

1.一再提醒could not install io.appium.settings
和io.appium.unlocked这些五个apk. 
那八个安装过一回就绝不再行设置了,安装目录在

driver = webdriver.Remote(”, desired_caps)

D:\Program Files
(x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk

time.sleep

D:\Program Files
(x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk

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

设置过后在appium里面安装为不用每一回都重装那七个apk,不仅仅浪费时间还或许会扭转弹窗,非常烦,屏蔽措施,注释掉一部分内容,如下:

time.sleep

Appium\node_modules\appium\lib\devices\android\android.jasync.series([

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

this.initJavaVersion.bind(this),this.initAdb.bind(this),this.packageAndLaunchActivityFromManifest.bind(this),this.initUiautomator.bind(this),this.prepareDevice.bind(this),this.checkApiLevel.bind(this),this.pushStrings.bind(this),this.processFromManifest.bind(this),this.uninstallApp.bind(this),this.installAppForTest.bind(this),this.forwardPort.bind(this),//this.pushAppium.bind(this),this.initUnicode.bind(this),//
DO NOT push settings app and unlock
app//this.pushSettingsApp.bind(this),//this.pushUnlock.bind(this),function(cb){this.uiautomator.start(cb);}.bind(this),this.wakeUp.bind(this),this.unlock.bind(this),this.getDataDir.bind(this),this.setupCompressedLayoutHierarchy.bind(this),this.startAppUnderTest.bind(this),this.initAutoWebview.bind(this),this.setActualCapabilities.bind(this)],function(err){

time.sleep

2撤销重新安装IME.APK

log:

Appium\node_modules\appium\lib\devices\android\android-common.js

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 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
\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
\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
\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
\Appium\node_modules\appium\build\settings_apk\【js3016金沙官网】0真机测试遇到的问题,解决appium安卓自动化测试时安装app需要手动允许的问题。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
\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
【js3016金沙官网】0真机测试遇到的问题,解决appium安卓自动化测试时安装app需要手动允许的问题。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] [【js3016金沙官网】0真机测试遇到的问题,解决appium安卓自动化测试时安装app需要手动允许的问题。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
从此现在就停住了,请大家帮笔者看看是什么难题,纠结了少好多天了,多谢我们!

androidCommon.pushUnicodeIME=function(cb){cb()/*  logger.debug(“Pushing
unicode ime to device…”);  var imePath = path.resolve(__dirname,
“..”, “..”, “..”, “build”,      “unicode_ime_apk”,
“UnicodeIME-debug.apk”);  fs.stat(imePath, function (err) {    if (err)
{      cb(new Error(“Could not find Unicode IME apk; please run ” +     
            “‘reset.sh –android’ to build it.”));    } else {     
this.adb.install(imePath, false, cb);    }  }.bind(this)); 
*/};3.报错shell “ps ‘uiautomator'”  bad pid uiautomator

查看大许多资料说的是做如下更动:

修改appium中adb.js文件,在代码var outlines =
stdout.split(“\n”);后加outlines.shift();

目录:C:\Program
Files\Appium\node_modules\appium\node_modules\appium-adb\lib

—首先种方法截止—

地点这种艺术修改后只怕要命,就依照下边第三种方法修改了下,成功运维了:

—次之种情势开首—

1.往往提醒could not install io.appium.settings
和io.appium.unlocked这几个多个apk. 
那三个安装过贰次就绝不再行设置了,安装目录在

D:\Program Files
(x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk

D:\Program Files
(x86)\Appium\node_modules\appium\build\【js3016金沙官网】0真机测试遇到的问题,解决appium安卓自动化测试时安装app需要手动允许的问题。unlock_apk\unlock_apk-debug.apk

设置过后在appium里面安装为不用每便都重装那多个apk,不仅仅浪费时间还有大概会变动掸窗,非常烦,屏蔽措施,注释掉一部分内容,如下:

Appium\node_modules\appium\lib\devices\android\android.jasync.series([

this.initJavaVersion.bind(this),this.initAdb.bind(this),this.packageAndLaunchActivityFromManifest.bind(this),this.initUiautomator.bind(this),this.prepareDevice.bind(this),this.checkApiLevel.bind(this),this.pushStrings.bind(this),this.processFromManifest.bind(this),this.uninstallApp.bind(this),this.installAppForTest.bind(this),this.forwardPort.bind(this),//this.pushAppium.bind(this),this.initUnicode.bind(this),//
DO NOT push settings app and unlock
app//this.pushSettingsApp.bind(this),//this.pushUnlock.bind(this),function(cb){this.uiautomator.start(cb);}.bind(this),this.wakeUp.bind(this),this.unlock.bind(this),this.getDataDir.bind(this),this.setupCompressedLayoutHierarchy.bind(this),this.startAppUnderTest.bind(this),this.initAutoWebview.bind(this),this.setActualCapabilities.bind(this)],function(err){

2撤废重新安装IME.APK

Appium\node_modules\appium\lib\devices\android\android-common.js

androidCommon.pushUnicodeIME=function(cb){cb()/*  logger.debug(“Pushing
unicode ime to device…”);  var imePath = path.resolve(__dirname,
“..”, “..”, “..”, “build”,      “unicode_ime_apk”,
“UnicodeIME-debug.apk”);  fs.stat(imePath, function (err) {    if (err)
{      cb(new Error(“Could not find Unicode IME apk; please run ” +     
            “‘reset.sh –android’ to build it.”));    } else {     
this.adb.install(imePath, false, cb);    }  }.bind(this)); 
*/};3.报错shell “ps ‘uiautomator'”  bad pid uiautomator

查看大大多材质说的是做如下改造:

修改appium中adb.js文件,在代码var outlines =
stdout.split(“\n”);后加outlines.shift();

目录:C:\Program
Files\Appium\node_modules\appium\node_modules\appium-adb\lib

如下:

ADB.prototype.getPIDsByName = function (name, cb) {

logger.debug(“Getting all processes with ‘” + name + “‘”);

this.shell(“ps ‘” + name + “‘”, function (err, stdout) {

if (err) return cb(err);

stdout = stdout.trim();

var procs = [];

var outlines = stdout.split(“\n”);

相关文章