I am trying to implement Androidviewclient to run viewbased scripts , is there any way i can install new packages using androidviewclient like the way we can with monkeyrunner using "device.installPackage()"
答案 0 :(得分:2)
AndroidViewClient/culebra版本 11.0.7 实现ViewClient.installPackage()
并且还引入了一个新的命令行选项--install-apk
,它根据安装结果生成测试前置条件的APK。有关详细信息,请参阅https://github.com/dtmilano/AndroidViewClient/wiki/Test-Cookbook#installing-apks-as-preconditions。
installPackage
尚未在AdbClient
中实施,因为它可以替换为subprocess
:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2014 Diego Torres Milano
Created on 2015-11-14 by Culebra v10.8.2
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
import subprocess
try:
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient
TAG = 'CULEBRA'
_s = 5
_v = '--verbose' in sys.argv
kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
vc = ViewClient(device, serialno, **kwargs2)
apk="/path/to/my/app-debug.apk"
subprocess.check_call([vc.adb, "install", "-r", apk], shell=False)