예제 #1
0
    def execCase(self, f, **kwargs):
        logTest = testLog.myLog().getLog()
        bc = self.getModeList(f)
        go = bo.OperateElement(driver=common.DRIVER)
        ch_check = bc[-1]
        for k in bc:
            if k["operate_type"] != "false":
                if go.operate_element(k) == False:
                    logTest.checkPointNG(common.DRIVER, kwargs["test_name"],
                                         kwargs["test_name"])
                    logTest.resultNG(kwargs["test_name"], "找不页面元素")
        if go.findElement(ch_check):
            common.test_success += 1
            self.GetWebInfoCase.test_result = "成功"
            logTest.resultOK(kwargs["test_name"])
        else:
            logTest.checkPointNG(common.DRIVER, kwargs["test_name"],
                                 kwargs["test_name"])
            common.test_failed += 1
            test_reason = "检查不到元素"
            self.GetWebInfoCase.test_result = "失败"
            self.GetWebInfoCase.test_reason = test_reason

        self.GetWebInfoCase.test_name = kwargs["test_name"]
        self.GetWebInfoCase.test_module = self.test_module
        common.test_sum += 1

        common.RESULT["info"].append(
            json.loads(json.dumps(self.GetWebInfoCase().to_primitive())))
        if kwargs["isLast"] == "1":
            # 最后case要写最下面的统计步骤
            common.RRPORT["info"].append(common.RESULT["info"])
예제 #2
0
    def execCase(self, f, **kwargs):
        logTest = testLog.myLog().getLog()
        bc = self.getModeList(f)
        go = bo.OperateElement(driver=common.DRIVER)
        ch_check = bc[-1]
        for k in bc:
            if k["operate_type"] != "false":
                if go.operate_element(k)== False:
                     logTest.checkPointNG(common.DRIVER, kwargs["test_name"], kwargs["test_name"])
                     logTest.resultNG(kwargs["test_name"], "找不页面元素")
        if go.findElement(ch_check):
            common.test_success += 1
            self.GetWebInfoCase.test_result = "成功"
            logTest.resultOK(kwargs["test_name"])
        else:
            logTest.checkPointNG(common.DRIVER, kwargs["test_name"], kwargs["test_name"])
            common.test_failed += 1
            test_reason = "检查不到元素"
            self.GetWebInfoCase.test_result = "失败"
            self.GetWebInfoCase.test_reason = test_reason

        self.GetWebInfoCase.test_name =kwargs["test_name"]
        self.GetWebInfoCase.test_module = self.test_module
        common.test_sum += 1

        common.RESULT["info"].append(json.loads(json.dumps(self.GetWebInfoCase().to_primitive())))
        if kwargs["isLast"] == "1":
        # 最后case要写最下面的统计步骤
            common.RRPORT["info"].append(common.RESULT["info"])
예제 #3
0
    def execCase(self, f, **kwargs):
        logTest = testLog.myLog().getLog()
        bc = self.getModeList(f)
        print(bc)
        chromes = webdriver.Chrome()

        go = bo.OperateElement(driver=chromes)

        print(go)
        ch_check = bc[-1]
        for k in bc:
            if k["operate_type"] != "false":
                if go.operate_element(k) == False:
                    logTest.checkPointNG(chromes, kwargs["test_name"],
                                         kwargs["test_name"])
                    logTest.resultNG(kwargs["test_name"], "找不页面元素")
        if go.findElement(ch_check):
            common.test_success += 1
            self.GetWebInfoCase.test_result = "成功"
            logTest.resultOK(kwargs["test_name"])
        else:
            logTest.checkPointNG(chromes, kwargs["test_name"],
                                 kwargs["test_name"])
            common.test_failed += 1
            test_reason = "检查不到元素"
            self.GetWebInfoCase.test_result = "失败"
            self.GetWebInfoCase.test_reason = test_reason

        self.GetWebInfoCase.test_name = kwargs["test_name"]
        self.GetWebInfoCase.test_module = self.test_module
        common.test_sum += 1
예제 #4
0
 def setUp(self):
     self.searchCases = readYaml.getYam(
         r'E:\apiTest\YAML\web\case_search_api.yml')
     self.infoma = {}
     self.response = ""
     self.infoma["module"] = self.searchCases["testinfo"]["module"]
     self.infoma["intr"] = self.searchCases["testinfo"]["intr"]
     self.logTest = testLog.myLog().getLog()
예제 #5
0
 def __init__(self, **kwargs):
     self.driver = kwargs["driver"]
     self.logTest = testLog.myLog().getLog()
     self.casename = kwargs["casename"]
     self.info = {}
예제 #6
0
    def execCase(self, f, **kwargs):
        logTest = testLog.myLog().getLog()
        bc = self.getModeList(f)
        go = bo.OperateElement(driver=common.DRIVER)
        ch_check = bc[-1]
        for k in bc:
            if k["operate_type"] != "false":
                if go.operate_element(k) == False:
                    logTest.checkPointNG(common.DRIVER, kwargs["test_name"],
                                         kwargs["test_name"])
                    logTest.resultNG(kwargs["test_name"], "找不页面元素")

                get_men = ap.get_men(common.PACKAGE)
                get_cpu = ap.top_cpu(common.PACKAGE)
                get_fps = ap.get_fps(common.PACKAGE)

                self.cpu.append(get_cpu)
                self.men.append(get_men)
                self.fps.append(get_fps)

                common.MEN.append(get_men)
                common.CPU.append(get_cpu)
                common.FPS.append(get_fps)

        if go.findElement(ch_check):
            common.test_success += 1
            self.GetAppCaseInfo.test_result = "成功"
            logTest.resultOK(kwargs["test_name"])
        else:
            # logTest.screenshotNG(GetVariable.DRIVER, kwargs["test_name"])
            logTest.checkPointNG(common.DRIVER, kwargs["test_name"],
                                 kwargs["test_name"])
            common.test_failed += 1
            test_reason = "检查不到元素"
            # if GetVariable.I_ANR > 0:
            #     test_reason = "有ANR错误"
            # if GetVariable.I_CRASH > 0:
            #     test_reason = "有CRASH错误"
            # if GetVariable.I_EXCEPTION > 0:
            #     test_reason = "有EXCEPTION错误"
            self.GetAppCaseInfo.test_result = "失败"
            self.GetAppCaseInfo.test_reason = test_reason

        self.GetAppCaseInfo.test_name = kwargs["test_name"]
        self.GetAppCaseInfo.test_module = self.test_module
        common.test_sum += 1

        self.GetAppCaseInfo.test_men_max = rp.phone_max_use_raw(self.men)
        avg_men = ba.get_avg_raw(self.men,
                                 get_devices().deviceName)  # 获取每次占用内存多少
        self.GetAppCaseInfo.test_men_avg = avg_men
        self.GetAppCaseInfo.test_cpu_max = rp.phone_avg_max_use_cpu(self.cpu)
        self.GetAppCaseInfo.test_cpu_avg = rp.phone_avg_use_cpu(self.cpu)
        self.GetAppCaseInfo.test_fps_max = rp.fps_max(self.fps)
        self.GetAppCaseInfo.test_fps_avg = rp.fps_avg(self.fps)

        common.RESULT["info"].append(
            json.loads(json.dumps(self.GetAppCaseInfo().to_primitive())))
        if kwargs["isLast"] == "1":
            # 最后case要写最下面的统计步骤
            common.RRPORT["info"].append(common.RESULT["info"])
예제 #7
0
 def setUp(self):
     self.info = {}
     self.response = ""
     self.logTest = testLog.myLog().getLog()
     self.brandId = '58a14827e4b01513b923378b'
예제 #8
0
 def setUp(self):
     self.info = {}
     self.response = ""
     self.logTest = testLog.myLog().getLog()
     self.brandId = '5a30dc4e17d086ac62e3ad43'
예제 #9
0
    def execCase(self, f, **kwargs):
        '''

        :param f: 用例文件
        :param kwargs:
        test_name: 用例名
        is_last: 最后一个用例 1, 0
        :return:
        '''
        logTest = testLog.myLog().getLog()
        bc = self.getModeList(f)
        go = bo.OperateElement(driver=self.driver)
        ch_check = bc[-1]
        # l_report = {"info": [], "init": []}  # case的init,info信息
        # _init = []
        # _info = []
        _d_report_common = {
            "test_success": 0,
            "test_failed": 0,
            "test_sum": 0
        }  #case的运行次数和性能
        for k in bc:
            if k["operate_type"] != "false":
                k["devices"] = self.devices
                if go.operate_element(k) == False:
                    logTest.checkPointNG(driver=self.driver,
                                         caseName=kwargs["test_name"],
                                         checkPoint=kwargs["test_name"])
                    logTest.resultNG(kwargs["test_name"], "找不页面元素")

                get_men = ap.get_men(devices=self.devices,
                                     pkg_name=self.package)
                get_cpu = ap.top_cpu(devices=self.devices,
                                     pkg_name=self.package)
                get_fps = ap.get_fps(devices=self.devices,
                                     pkg_name=self.package)

                # 单个case
                self.GetAppCaseInfo.test_devices = self.get_phone_name()
                self.cpu.append(get_cpu)
                self.men.append(get_men)
                self.fps.append(get_fps)

        _d_report_common["test_sum"] += 1
        if go.findElement(ch_check):
            _d_report_common["test_success"] += 1
            self.GetAppCaseInfo.test_result = "成功"
            logTest.resultOK(kwargs["test_name"])
            self.write_report_collect(
                _d_report_common, f=common.REPORT_COLLECT_PATH)  # 写入case运行的总个数

        else:
            # logTest.screenshotNG(GetVariable.DRIVER, kwargs["test_name"])
            logTest.checkPointNG(driver=self.driver,
                                 caseName=kwargs["test_name"],
                                 checkPoint=kwargs["test_name"])
            _d_report_common["test_failed"] += 1
            test_reason = "检查不到元素"
            self.write_report_collect(
                _d_report_common, f=common.REPORT_COLLECT_PATH)  # 写入case运行的总个数

            self.GetAppCaseInfo.test_result = "失败"
            self.GetAppCaseInfo.test_reason = test_reason

        self.GetAppCaseInfo.test_name = kwargs["test_name"]
        self.GetAppCaseInfo.test_module = self.test_module

        self.GetAppCaseInfo.test_men_max = rp.phone_max_use_raw(
            self.men)  #内存最大使用情况
        avg_men = ba.get_avg_raw(self.men, self.devices)  # 获取每次占用内存平均值
        self.GetAppCaseInfo.test_men_avg = avg_men
        self.GetAppCaseInfo.test_cpu_max = rp.phone_avg_max_use_cpu(
            self.cpu)  #cpu最大使用
        self.GetAppCaseInfo.test_cpu_avg = rp.phone_avg_use_cpu(
            self.cpu)  #cpu平均使用
        self.GetAppCaseInfo.test_fps_max = rp.fps_max(self.fps)
        self.GetAppCaseInfo.test_fps_avg = rp.fps_avg(self.fps)
        self.GetAppCaseInfo.test_phone_name = self.get_phone_name()

        info_case = json.loads(json.dumps(
            self.GetAppCaseInfo().to_primitive()))
        # _info.append(info_case)
        self.write_detail(info_case, f=common.REPORT_INFO_PATH,
                          key="info")  # 写入所有的case包括,init,info中的excel中的case情况
        if kwargs["isLast"] == "1":
            d_report = {}
            raw = ba.get_men_total(devices=self.devices)
            d_report["phone_name"] = self.get_phone_name()
            d_report["phone_pix"] = ba.get_app_pix(self.devices)
            d_report["phone_cpu"] = ba.get_cpu_kel(self.devices)
            d_report["phone_raw"] = rp.phone_raw(raw / 1024)
            # 记录每个设备的case运行情况
            d_report["phone_avg_use_cpu"] = self.GetAppCaseInfo.test_cpu_avg
            d_report[
                "phone_avg_max_use_cpu"] = self.GetAppCaseInfo.test_cpu_max
            d_report["phone_avg_use_raw"] = self.GetAppCaseInfo.test_men_avg
            d_report["phone_max_use_raw"] = self.GetAppCaseInfo.test_men_max
            d_report["fps_avg"] = self.GetAppCaseInfo.test_fps_avg
            d_report["fps_max"] = self.GetAppCaseInfo.test_fps_max
            # _init.append(d_report)
            #最后case要写最下面的统计步骤
            self.write_detail(
                d_report, f=common.REPORT_INIT,
                key="init")  #写入所有的case包括,init,info中的excel中的case情况
예제 #10
0
 def setUp(self):
     self.info = {}
     self.response = ""
     self.logTest = testLog.myLog().getLog()