使用 Android viewClient 安装包

Installing a package using Android viewClient

我正在尝试将 Androidviewclient 实现到 运行 基于视图的脚本,有什么方法可以使用 androidviewclient 安装新包,就像我们使用 monkey运行ner 使用“device.installPackage()"

编辑

AndroidViewClient/culebra version 11.0.7 implements ViewClient.installPackage() and also introduces a new command line option --install-apk that generates a test precondition based on the result of the installation of the APK. See https://github.com/dtmilano/AndroidViewClient/wiki/Test-Cookbook#installing-apks-as-preconditions 了解详情。

installPackageAdbClient中没有实现,因为可以用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)