def checkBefore(self, scene='RULE_CHECK_BEFORE'): ''' 根据场景编码校验业务受理前置规则 :param scene: :return: ''' '''个人业务前置业务规则判断''' self.screen_step('CheckRuleBefore业务规则判断') rulemsg = PageAssert(self.driver).assert_WadePage() logger.info('Wade页面返回的业务规则校验信息:'.format(rulemsg)) TR().updateRuleCheckInfo(msg=rulemsg, sceneCode=scene) Assertion().assertNotIn('校验失败', rulemsg, msg='[规则校验通过]') Assertion().assertNotIn('校验不通过', rulemsg, msg='[规则校验通过]') return rulemsg
def checkSaleActiveExists(self,offerCode): '''检查是否传入的营销活动是否存在''' loc_PackageList = (By.XPATH,'//*[@id="PackageListPart"]/div/ul/li[1]/div/div') packgeInfo = self.get(loc_PackageList,Type='text') logger.info('查询结果列表展示的营销包:' + packgeInfo) Assertion().assertIn(offerCode,packgeInfo,msg='营销包不存在,终止执行!') #先断言一下,如果不存在则直接终止测试 return packgeInfo
def checkSaleActiveExists(self,OfferCode): '''检查是否传入的营销活动是否存在''' loc_PackageList = (By.XPATH,'//*[@id="PackageListPart"]/div/ul/li[1]/div/div') packgeId = self.get(loc_PackageList,Type='text') logger.info('查询结果列表展示的营销包:' + packgeId) Assertion().assertIsNotNone(packgeId,msg='营销包不存在,终止执行!') #先断言一下,如果不存在则直接终止测试 return self.is_value_in_text(loc_PackageList,OfferCode)
def AuthUserInfo(self,accessNum): '''用户鉴权''' text_SerialNum = (By.ID,'AUTH_SERIAL_NUMBER') self.element_sendkey_enter(text_SerialNum,accessNum) time.sleep(3) # busiVerify = RuleCheckBefore(self.driver).checkRule() busiVerify = RuleCheckBefore(self.driver).checkRule() print(type(busiVerify)) # logger.info('业务校验检查结果:'.format(busiVerify)) print('=============业务校验检查结果:' + busiVerify) PageAssert(self.driver).dealDialogPage() #关闭营销推荐 loc_CustInfoViewPart = (By.ID,'CustInfoViewPart') flag = self.isElementDisplay(loc_CustInfoViewPart) print(flag) # Assertion().verifyassertTrue(flag,message='用户鉴权失败,终止测试') Assertion().assertTrue(flag,msg='用户鉴权失败,终止测试')
def checkRule(self, scene='ruleCheck'): '''页面执行规则判断''' # stackInfo = retStackFunc() # # # funcCode = stackInfo['func'] # print('=====被调用的函数:') # logger.info(stackInfo) '''处理Wade弹出的各种提示窗口(Error、Success、Warn、Help、Tips)''' loc_WadeMessage = ( By.XPATH, '//div[starts-with(@id,"wade_messagebox") and not(contains(@style,"display: none"))]' ) try: ele_wadeMsg = self.find(loc_WadeMessage) logger.info('找到WadeMsg弹出框:{}'.format(str(ele_wadeMsg))) classname = self.get(loc_WadeMessage, Type='attribute', name='class') #取出WadeMsg的class属性值,判断是什么类型弹出 logger.info('wadeMsg的类型:{}'.format(classname)) time.sleep(2) WadeMsg = ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[1]/div[2]').text logger.info('WadeMessageBox返回的信息:{}'.format(WadeMsg)) '''根据classname类型按钮处理''' if 'c_msg-error' in classname: print('弹出WadeMsg的是错误提示') logger.info("业务校验失败:{}".format(WadeMsg)) print('业务校验信息:{}'.format(WadeMsg)) step_str = "业务校验" self.screen_step(step_str) # 这个保存在测试记录文档中 self.screenshot_SaveAsDoc(step_str) # 截图单独保存到doc time.sleep(3) WadeMsg = '业务校验失败' + WadeMsg elif 'c_msg-success' in classname: print('弹出WadeMsg的是成功提示') ele_suc = ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[2]/button') self.click_on_element(ele_suc) self.sendEnter() time.sleep(2) WadeMsg = '弹出校验成功信息:' + WadeMsg elif 'c_msg-warn' in classname: print('弹出WadeMsg的是告警提示') step_str = "业务受理提示信息" self.screenshot_SaveAsDoc(step_str) ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[2]/button').click() # 关闭提示窗口 self.sendEnter() time.sleep(2) WadeMsg = '警告信息:' + WadeMsg elif 'c_msg-however' in classname: print('弹出WadeMsg的是however') step_str = "业务受理提示信息" self.screenshot_SaveAsDoc(step_str) ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[2]/button').click() # 关闭提示窗口 self.sendEnter() time.sleep(2) WadeMsg = '业务校验:' + WadeMsg logger.info(WadeMsg) elif 'c_msg-help' in classname: print('弹出WadeMsg的是帮助提示') ele_help = ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[2]/button[1]') self.click_on_element(ele_help) self.sendEnter() time.sleep(3) elif 'c_msg c_msg-h c_msg-phone-v c_msg-full' == classname: print('弹出WadeMsg的是普通提示') step_str = "业务受理提示信息" logger.info('业务受理提示信息:{}'.format(WadeMsg)) self.screenshot_SaveAsDoc(step_str) ele_wadeMsg.find_element_by_xpath( './div/div[2]/div[2]/button[1]').click() # 关闭提示窗口 time.sleep(2) WadeMsg = '出现提示信息:' + WadeMsg self.sendEnter() except: WadeMsg = '没有弹出WadeMessage提示,校验通过' logger.info('======WadeMessageBox页面返回============={}'.format(WadeMsg)) TR().updateRuleCheckInfo(msg=WadeMsg, sceneCode=scene) Assertion().assertNotIn('校验失败', WadeMsg, msg='[规则校验通过]') Assertion().assertNotIn('校验不通过', WadeMsg, msg='[规则校验通过]') return WadeMsg
def isAuthSuc(self): '''判断是否鉴权成功''' loc_CustInfoViewPart = (By.ID,'CustInfoViewPart') flag = self.isElementDisplay(loc_CustInfoViewPart) # Assertion().assertTrue(flag,msg='用户鉴权失败,终止测试') return Assertion().verifyassertTrue(flag,msg='用户鉴权失败,终止测试') #这里返回一个Flag,