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"])
def execCase(self, f): # logger = logTest.getMyLogger() getCase = ap.getYam(f) go = bo.OperateElement(driver=self.driver) for case in getCase["testcase"]: go.operate_element(case) # 操作用例 self.logTest.buildStartLine(case["element_info"] + " " + case["operate_type"]) if go.findElement(getCase["check"]): self.writeLog(getCase["check"], flag=True) util.DATA["pass"] = util.DATA["pass"] + 1 self.info["result"] = "通过" else: self.writeLog(getCase["check"], flag=False, testinfo=getCase["testinfo"]) util.DATA["fail"] = util.DATA["fail"] + 1 self.info["result"] = "失败" self.info["reason"] = "无法找到检查点" self.info["id"] = getCase["testinfo"][0]["id"] self.info["moudle"] = getCase["testinfo"][0]["moudle"] self.info["casename"] = self.casename self.info["intr"] = getCase["testinfo"][0]["intr"] util.DATA["sum"] = util.DATA["sum"] + 1 util.INFO.append(self.info)
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
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] _d_report_common = {"test_success": 0, "test_failed": 0, "test_sum": 0} #case的运行次数和性能 is_crash = NORMAL # 0表示没有闪退,1标识有闪退,2标识没有闪退,找不到页面元素 for k in bc: if k["operate_type"] != "false": k["devices"] = self.devices # _d_report_common["test_sum"] += 1 _operate = go.operate_element(k) if _operate: is_crash = NORMAL if len(self.pull_crash_log()) > 0: is_crash = IS_CRASH elif _operate == False: is_crash = NO_ELEMENT 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.cpu.append(get_cpu) self.men.append(get_men) self.fps.append(get_fps) _d_report_common["test_sum"] += 1 self.report(go, ch_check, _d_report_common, kwargs, is_crash=is_crash)
def execCase(self, f, **kwargs): ''' :param f: test file :param kwargs: test_name: test name is_last: latest test 1, 0 :return: ''' # logTest = testLog.myLog().getLog() bc = self.getModeList(f) go = bo.OperateElement(driver=self.driver) ch_check = bc[-1] _d_report_common = { "test_success": 0, "test_failed": 0, "test_sum": 0 } #case run account is_crash = NORMAL # 0 no crash,1 crash,2 no crash,just cannot find element for k in bc: if k["operate_type"] != "false": k["devices"] = self.devices # _d_report_common["test_sum"] += 1 _operate = go.operate_element(k) if _operate: is_crash = NORMAL if len(self.pull_crash_log()) > 0: is_crash = IS_CRASH elif _operate == False: is_crash = NO_ELEMENT
def execCase(self, f, **kwargs): ''' :param f: 用例文件 :param kwargs: test_name: 用例名 is_last: 最后一个用例 1, 0 :return: ''' bc = self.getModeList(f) go = bo.OperateElement(driver=self.driver) ch_check = bc[-1] if self.crashLog: ba.remove_file(self.device, self.crashLog) _d_report_common = { "test_success": 0, "test_failed": 0, "test_sum": 0 } #case的运行次数和性能 operate_result = NORMAL # 0表示没有闪退,1标识有闪退,2标识没有闪退,找不到页面元素 ng_img = None for k in bc: if k[common.OPERATION_TYPE] != "false": # 单个case的情况收集 self.cpu.append( ap.top_cpu(devices=self.device, pkg_name=self.package)) self.men.append( ap.get_men(devices=self.device, pkg_name=self.package)) # self.fps.append(ap.get_fps(devices=self.device, pkg_name=self.package)) _operate = go.operate_element(k) if len(self.pull_crash_log()) > 0: operate_result = IS_CRASH ng_img = screenShots.screen_shot( case_name=kwargs["test_name"], driver=self.driver, result_path=common.SCREEN_IMG_PATH) break elif not _operate: operate_result = NO_ELEMENT ng_img = screenShots.screen_shot( case_name=kwargs["test_name"], driver=self.driver, result_path=common.SCREEN_IMG_PATH) break time.sleep(2) _d_report_common["test_sum"] += 1 if ng_img is None: ng_img = screenShots.screen_shot( case_name=kwargs["test_name"], driver=self.driver, result_path=common.SCREEN_IMG_PATH) self.report(go, ch_check, _d_report_common, kwargs, operate_result, ng_img)
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"])
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情况