示例#1
0
    def _install_apk_upgrade(self, apk_path, package):
        """
        Install or update the `.apk` file on the device

        Args:
            apk_path: full path `.apk` file
            package: package name

        Returns:
            None

        """
        apk_version = int(APK(apk_path).androidversion_code)
        installed_version = self.adb.get_package_version(package)
        if installed_version is None or apk_version > int(installed_version):
            LOGGING.info(
                "local version code is {}, installed version code is {}".
                format(apk_version, installed_version))
            try:
                self.adb.install_app(apk_path,
                                     replace=True,
                                     install_options=["-t", "-g"])
            except:
                if installed_version is None:
                    raise
                # If the installation fails, but the phone has an old version, do not force the installation
                warnings.warn(
                    "Yosemite.apk update failed, please try to reinstall manually(airtest/core/android/static/apks/Yosemite.apk)."
                )
示例#2
0
 def __init__(self,mdevice=""):
     #获取当前文件的上层路径
     self._parentPath=os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())) + os.path.sep + ".")
     #获取当前项目的根路径
     self._rootPath=os.path.abspath(os.path.dirname(self._parentPath) + os.path.sep + ".")
     self._configPath=self._rootPath+"\config.ini"
     self._devicesList = Config.getValue(self._configPath, "deviceslist", )
     self._packagePath = Config.getValue(self._configPath, "apkpath")[0]
     self._packageName = Config.getValue(self._configPath, "packname")[0]
     self._activityName = Config.getValue(self._configPath, "activityname")[0]
     self._needClickInstall = Config.getValue(self._configPath, "needclickinstall")[0]
     self._needClickStartApp = Config.getValue(self._configPath, "needclickstartapp")[0]
     self._startTime=time.time()
     self._timeoutAction=int(Config.getValue(self._configPath, "timeoutperaction")[0])
     self._timeoutStartApp=int(Config.getValue(self._configPath, "timeoutofstartapp")[0])
     self._mdevice=mdevice
     # 处理模拟器端口用的冒号
     if ":" in self._mdevice:
         self._nickName = self._mdevice.split(":")[1]
     else:
         self._nickName=self._mdevice
     self._iteration=int(Config.getValue(self._configPath, "iteration")[0])
     self._allTestcase=Config.getValue(self._configPath, "testcase")
     try:
         self._testcaseForSelfDevice =Config.getTestCase(self._configPath, self._nickName)
         if self._testcaseForSelfDevice[0]=="":
             self._testcaseForSelfDevice = self._allTestcase
     except Exception:
         self._testcaseForSelfDevice=self._allTestcase
     self._testCasePath=Config.getValue(self._configPath, "testcasepath")
     if self._testCasePath[0]=="":
         self._testCasePath=os.path.join(self._rootPath, "TestCase")
     self._needPerformance=Config.getValue(self._configPath,"needPerformance")[0]
     if self._activityName=="":
         self._activityName=APK(self.get_apkpath()).activities[0]
示例#3
0
    def __init__(self, mdevice=""):
        #获取当前文件的上层路径
        self._parentPath = os.path.abspath(
            os.path.dirname(inspect.getfile(inspect.currentframe())) +
            os.path.sep + ".")
        #获取当前项目的根路径
        self._rootPath = os.path.abspath(
            os.path.dirname(self._parentPath) + os.path.sep + ".")
        self._configPath = self._rootPath + "\config.ini"
        self._devicesList = Config.getValue(
            self._configPath,
            "deviceslist",
        )
        self._packagePath = Config.getValue(self._configPath, "apkpath")[0]
        self._packageName = Config.getValue(self._configPath, "packname")[0]
        self._activityName = Config.getValue(self._configPath,
                                             "activityname")[0]
        self._skip_pushapk2devices = Config.getValue(self._configPath,
                                                     "skip_pushapk2devices")[0]
        self._auto_delete_package = Config.getValue(self._configPath,
                                                    "auto_delete_package")[0]
        self._auto_install_package = Config.getValue(self._configPath,
                                                     "auto_install_package")[0]
        self._skip_check_of_install = Config.getValue(
            self._configPath, "skip_check_of_install")[0]
        self._skip_check_of_startapp = Config.getValue(
            self._configPath, "skip_check_of_startapp")[0]
        self._skip_performance = Config.getValue(self._configPath,
                                                 "skip_performance")[0]
        self._storage_by_excel = Config.getValue(self._configPath,
                                                 "storage_by_excel")[0]
        self._screenoff = Config.getValue(self._configPath, "screenoff")[0]
        self._startTime = time.time()
        self._timeout_of_per_action = int(
            Config.getValue(self._configPath, "timeout_of_per_action")[0])
        self._timeout_of_startapp = int(
            Config.getValue(self._configPath, "timeout_of_startapp")[0])
        self._mdevice = mdevice
        # 处理模拟器端口用的冒号
        if ":" in self._mdevice:
            self._nickName = self._mdevice.split(":")[1]
        else:
            self._nickName = self._mdevice
        self._iteration = int(
            Config.getValue(self._configPath, "iteration")[0])
        self._allTestcase = Config.getValue(self._configPath, "testcase")
        try:
            self._testcaseForSelfDevice = Config.getTestCase(
                self._configPath, self._nickName)
            if self._testcaseForSelfDevice[0] == "":
                self._testcaseForSelfDevice = self._allTestcase
        except Exception:
            self._testcaseForSelfDevice = self._allTestcase
        self._testCasePath = Config.getValue(self._configPath, "testcasepath")
        if self._testCasePath[0] == "":
            self._testCasePath = os.path.join(self._rootPath, "TestCase")

        if self._activityName == "":
            self._activityName = APK(self.get_apkpath()).activities[0]
示例#4
0
    def __init__(self, momentDevices=""):

        self._parentPath = os.path.dirname(
            os.path.abspath(inspect.getfile(
                inspect.currentframe())))  # 获取当前文件上层路径
        self._rootPath = os.path.dirname(os.path.abspath(
            self._parentPath))  # 获取当前目录根目录
        self._configPath = self._rootPath + '/config.ini'  # 获取config.ini的路径
        self._testCase = common.get_value(self._configPath,
                                          'testCase')  # 获取测试列表
        self._email = common.get_value(self._configPath, 'email')[0]  # 获取邮箱
        self._packageName = common.get_value(self._configPath,
                                             'packageName')[0]  # 获取安装包名称
        self._packagePath = common.get_value(self._configPath,
                                             'packagePath')[0]  # 获取安装包路径
        self._devicesList = common.get_value(self._configPath,
                                             'devicesList')  # 获取配置设备列表
        self._installApk = common.get_value(
            self._configPath, 'installApk')[0]  # 获取安装测试包开关 1 为打开 0 为关闭
        self._testType = common.get_value(self._configPath,
                                          'testType')[0]  # 获取测试类型开关 1 兼容 0 为分布
        self._performanceType = common.get_value(
            self._configPath, 'performanceType')[0]  # 获取性能测试开关 1 为打开 0 为关闭
        self._storage_by_exce = common.get_value(
            self._configPath,
            "storage_by_exce")[0]  # 获取性能报告方式 1 为excle 0 为json
        self._username = common.get_value(self._configPath, 'username')  # 获取账号
        self._password = common.get_value(self._configPath,
                                          'password')[0]  # 获取密码
        self._uwatype = common.get_value(self._configPath,
                                         "uwatype")[0]  # 获取uwa测试判断
        self._server = common.get_value(self._configPath,
                                        'server')[0]  # 获取server
        if self._server == "1server":
            self._server = "日补丁qq android一服"
        elif self._server == "2server":
            self._server = "日补丁qq android二服"
        self._momentDevices = momentDevices  # 获取连接的设备
        if ':' in self._momentDevices:
            self._devicesName = self._momentDevices.split(':')[1]
        else:
            self._devicesName = self._momentDevices

        self._activityName = common.get_value(self._configPath,
                                              'activityName')[0]  # 获取测试包的界面活动名
        if self._activityName == '':
            self._activityName = APK(self.get_apkpath()).activities[
                0]  # 如果活动包名没有填,就通过APK的activities方法,用包的路径获取活动名
示例#5
0
    def _install_apk_upgrade(self, apk_path, package):
        """
        Install or update the `.apk` file on the device

        Args:
            apk_path: full path `.apk` file
            package: package name

        Returns:
            None

        """
        apk_version = int(APK(apk_path).androidversion_code)
        installed_version = self.adb.get_package_version(package)
        LOGGING.info(
            "local version code is {}, installed version code is {}".format(
                apk_version, installed_version))
        if installed_version is None or apk_version > int(installed_version):
            self.adb.install_app(apk_path, replace=True)