def acceptChgMainProduct(self, accessNum, productId, elementList=[], scene='ChgMainProduct'): ''' 个人业务-变更主产品 :param accessNum:服务号码 :param productId:主产品编码 :param elementList:可选组元素列表 :return: ''' title = '主产品变更测试记录%s' % accessNum self.add_dochead(title) self.openProductChange() self.screen_step("进入产品变更菜单") authUser = DealUserCommon(self.driver).AuthUserInfo( accessNum) #用户鉴权,包含了用户鉴权都结果和规则校验信息 TR().updateRuleCheckInfo(sceneCode=scene, msg=authUser['msg']) Assert().assertTrue(authUser['IsAuthSuc'], msg='用户鉴权失败') #做个鉴权认证 self.screen_step("点击变更按钮") Btn_changeProduct = (By.ID, 'changeButton') self.isElementDisplay(Btn_changeProduct, 'click') #点击产品变更按钮 time.sleep(2) self.screen_step("选择主套餐") MainPlanSelectPart(self.driver).MainProductSel(productId, elementList) RuleCheckBefore(self.driver).checkRule() #规则校验 time.sleep(3) self.sendEnter() PageCommonPart(self.driver).submit() #点击提交 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) self.save_docreport(title)
def accept_CreateUser(self, accessNum, simId, mainPlanId, elementList, scene=''): ''' 个人用户开户业务受理 :param accessNum: 开户手机号码 :param simId: 开户SIM卡号 :param mainPlan: 主套餐 :param elementList: :return: ''' self.openCrtUserPage() #打开开户菜单 self.inputSerialNum(accessNum) #输入手机号并校验 self.inputSim(simId) #输入SIM卡并校验 RN(self.driver).openUserVerify(accessNum) #开户时按手机号码做实名制校验(在线验证) self.addMainPlan(mainPlanId=mainPlanId, elementList=elementList) #主套餐选择 PageCommon(self.driver).submit() RuleCheckBefore(self.driver).checkRule(scene) submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg))
def accept_DstMb(self, groupId, serialNum, grpUserId): ''' 成员商品受理-订购集团成员产品 :param groupId: 集团编码 :param serialNum: 成员服务号码 :param grpUserId: 集团用户标识 :return: ''' LoginPage(self.driver).login(rc.get_ngboss('username'), rc.get_ngboss('password')) # 登录 MainPage(self.driver).open_CataMenu( 'crm8000', 'crm8200', 'crm8206', menuPath='page/order.page.pc.enterprise.operenterprisemember' ) # 进入成员商品受理 self.GroupQryPart(groupId) #按集团编码查询集团客户 time.sleep(1) DealMebElements(self.driver).QryMebInfo(serialNum) #查询成员用户信息 self.OfferSubCata() #点击已订购目录 time.sleep(3) self.DstMebOffer(grpUserId) ####这个还差一个重新认证集团客户的确认动作 RuleCheckBefore(self.driver).checkRule() #业务规则判断 DealMebElements(self.driver).InputDstMbRemark() #填写备注 DealMebElements(self.driver).DelSubmitGrpMebOffer() #注销提交按钮 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) orderId = getDigitFromStr(submitMsg) time.sleep(2) orderTrace = DataCheck().retOrderTrace(orderId) logger.info('=========订单轨迹检查结果========') logger.info(orderTrace)
def accept_addSaleActive(self, accessNum, offerCode, scene='AddSaleActive'): ''' 个人业务-新增预存营销活动办理 :param accessNum:服务号码 :param OfferCode:营销活动编码 :return: ''' title = '%s办理营销活动%s_测试记录' % (accessNum, offerCode) self.add_dochead(title) self.openSaleActive() self.screen_step("进入营销活动受理(存送营销)菜单") authUser = DealUserCommon(self.driver).AuthUserInfo( accessNum) #用户鉴权,包含了用户鉴权都结果和规则校验信息 TR().updateRuleCheckInfo(sceneCode=scene, msg=authUser['msg']) Assert().assertTrue(authUser['IsAuthSuc'], msg='用户鉴权失败') #做个鉴权认证 SaleActivePart(self.driver).addSaleActive(offerCode) RuleCheckBefore(self.driver).checkRule( scene) #规则校验,如果失败则终止,并将校验结果写入到数据库中 ####校验码的问题###### PageCommonPart(self.driver).submit() #点击提交 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) self.save_docreport(title)
def acceptAddSaleActive(self, accessNum, OfferCode): ''' 个人业务-新增预存营销活动办理 :param accessNum:服务号码 :param OfferCode:营销活动编码 :return: ''' title = '%s办理营销活动%s_测试记录%s' % (accessNum, OfferCode) self.add_dochead(title) self.openSaleActive() self.screen_step("进入营销活动受理(存送营销)菜单") DealUserCommon(self.driver).AuthUserInfo(accessNum) #用户鉴权 # if not flag : # logger.info('用户鉴权失败,终止测试') # self.save_docreport(title) # # self.driver.close() #直接关闭浏览器 SaleActivePart(self.driver).selActivePop() self.screen_step("点击营销包,选择营销营销活动") SaleActivePart(self.driver).searchSaleActive(OfferCode) self.screen_step("选择营销活动") SaleActivePart(self.driver).selectActive(OfferCode) #选择营销包 # RuleCheckBefore(self.driver).checkRule() #规则校验 RuleCheckBefore(self.driver).checkRule() #规则校验 time.sleep(3) ####校验码的问题###### PageCommonPart(self.driver).submit() #点击提交 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) self.save_docreport(title)
def acceptChgMainProduct(self, accessNum, productId, elementList=[]): ''' 个人业务-变更主产品 :param accessNum:服务号码 :param productId:主产品编码 :param elementList:可选组元素列表 :return: ''' title = '主产品变更测试记录%s' % accessNum self.add_dochead(title) self.openProductChange() self.screen_step("进入产品变更菜单") flag = DealUserCommon(self.driver).AuthUserInfo(accessNum) #用户鉴权 if not flag: logger.info('用户鉴权失败,终止测试') self.save_docreport(title) # self.driver.close() #直接关闭浏览器 self.screen_step("点击变更按钮") Btn_changeProduct = (By.ID, 'changeButton') self.isElementDisplay(Btn_changeProduct, 'click') #点击产品变更按钮 time.sleep(2) self.screen_step("选择主套餐") MainPlanSelectPart(self.driver).MainProductSel(productId, elementList) RuleCheckBefore(self.driver).checkRule() #规则校验 time.sleep(3) self.sendEnter() PageCommonPart(self.driver).submit() #点击提交 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) self.save_docreport(title)
def accept_CrtUs(self, scene, groupId, brandCode, offerCode, elementAttrBizList=[], contractId=''): ''' 集团商品受理(开户) :param groupId: 场景编码 :param groupId: 集团编码 :param brandCode: 商品品牌 :param offerCode: 商品编码 :param AttrBizList:商品特征属性 :param elementAttrBizList:资费或者服务包括属性列表 :param contractId: :return: ''' title = '集团商品受理测试记录%s' % offerCode self.add_dochead(title) LoginPage(self.driver).login(rc.get_ngboss('username'), rc.get_ngboss('password')) # 登录 MainPage(self.driver).open_CataMenu( 'crm8000', 'crm8200', 'crm8207', menuPath= 'order.page.pc.enterprise.operenterprisesubscriber.OperEnterpriseSubscriber' ) # 进入集团商品受理 self.GroupQryPart(groupId) #按集团编码查询集团客户 time.sleep(2) self.SelOfferTypePart(brandCode) # 选择商品目录 self.SubGrpOffer(offerCode) #选择集团商品 RuleCheckBefore(self.driver).checkRule(scene) # DealElements(self.driver).initOfferAttrInfo() #点击商品待设置或者点击商品特征设置 self.screen_step("进入集团商品设置页面") # DealElements(self.driver).setOfferAttr(AttrBizList) #传入需要设置属性列表并设置商品属性 DealElements(self.driver).setOfferAttrNew( elementAttrBizList) #传入需设置属性列表并设置商品属性 DealElements(self.driver).submitOfferAttr(offerCode) #设置商品属性完成 DealElements(self.driver).initGroupOffer() #点击新增子商品 DealElements(self.driver).selectElements( elementAttrBizList) #选择要订购的资费和服务并且设置属性 self.screen_step("进入子商品选择页面,选择资费和服务") # DealElements(self.driver).submitOffers() #页面选择完资费和服务后点击确定 DealElements(self.driver).selectGroupContract(contractId) #选择集团对应合同 time.sleep(2) if '2222' == offerCode: DealElements(self.driver).setApprovalInfo(staffId='AJF00189') DealElements(self.driver).submitAccept() submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) orderId = getDigitFromStr(submitMsg) time.sleep(2) orderTrace = DataCheck().retOrderTrace(orderId) logger.info(orderTrace) print(orderTrace) #输出到控制台。方便在测试报告html中查看订单轨迹 self.save_docreport(title)
def verifyShortNum(self): '''校验短号''' btn_vaildShortNum = ( By.XPATH, '//button[contains(@onclick,"validateShortNum") and contains(@id,"validButton")]' ) self.isElementDisplay(btn_vaildShortNum, 'click') RuleCheckBefore(self.driver).checkRule()
def DstMebOffer(self, grpUserId): ''' :param grpUserId: 传入集团用户标识 :return: ''' dstMebOfferCodeStr = "//button[contains(@value,'%s') and contains(@ontap,'DstMb')]" % grpUserId # 传入集团编码并通过Xpath定位 loc_dstMebOfferCode = (By.XPATH, dstMebOfferCodeStr) self.isElementDisplay(loc_dstMebOfferCode, 'click') RuleCheckBefore(self.driver).checkRule() return self.driver
def DstGrpOfferCodeNew(self, offerCode): ''' 只传入Offercode去找对应的集团已订购商品 :param offerCode: :return: ''' DstOfferCodeStr = "//button[contains(@offer_code,'%s') and contains(@ontap,'DstUs')]" % ( offerCode) #传入集团编码并通过Xpath定位 loc_dstOfferCode = (By.XPATH, DstOfferCodeStr) self.isElementDisplay(loc_dstOfferCode, 'click') PageAssert(self.driver).pageLoading() RuleCheckBefore(self.driver).checkRule() return self.driver
def SubMebOffer(self, grpUserId): '''根据集团用户标识获取成员可订购产品 :param grpUserId: 传入集团用户标识 :return: ''' # self.subOfferCata() #先点击可订购商品 self.OfferCata() subMebOfferCodeStr = "//button[contains(@value,'%s') and contains(@ontap,'CrtMb')]" % grpUserId #传入集团编码并通过Xpath定位 loc_subMebOfferCode = (By.XPATH, subMebOfferCodeStr) self.isElementDisplay(loc_subMebOfferCode, 'click') PageAssert(self.driver).pageLoading() RuleCheckBefore(self.driver).checkRule() return self.driver
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 addElements(self,scene,elementList=[]): ''' 传入elementList包含改笔订单要订购资费或者服务以及类型 :param elementList: 字典数组,包含 OFFER_CODE 和 Offer_type 2个key eg : [{"OFFER_CODE":"120000008174","OFFER_TYPE":"S"},{"OFFER_CODE":"120010122813","OFFER_TYPE":"D"}] :return: ''' print(type(elementList)) print('新增元素列表:{}'.format(elementList)) for i in range(0,len(elementList)): offerCode = elementList[i]['OFFER_CODE'] offerType = elementList[i]['OFFER_TYPE'] if not isinstance(offerCode,str): offerType = str(offerCode) logger.info('要新增的元素类型:%s'.format(offerType)) logger.info('要新增的元素编码:%s'.format(offerCode)) self.searchElementByCode(offerCode) btnAddElementStr = "//button[contains(@onclick,'elementList.order') and contains(@offertype,'%s') and contains(@offercode,'%s')]" %(offerType,offerCode) Btn_AddElement = (By.XPATH,btnAddElementStr) self.isElementDisplay(Btn_AddElement,'click') PageAssert(self.driver).pageLoading() RuleCheckBefore(self.driver).checkRule(scene=scene)
def accept_DstUs(self, groupId, offerCode, reason='不必要使用该产品', scene='DstUs'): '''集团商品受理(销户)''' title = '集团商品退订测试记录%s' % offerCode self.add_dochead(title) LoginPage(self.driver).login(rc.get_ngboss('username'), rc.get_ngboss('password')) # 登录 MainPage(self.driver).open_CataMenu( 'crm8000', 'crm8200', 'crm8207', menuPath= 'order.page.pc.enterprise.operenterprisesubscriber.OperEnterpriseSubscriber' ) # 进入集团商品受理 self.screen_step("进入集团商品受理菜单") self.GroupQryPart(groupId) #按集团编码查询集团客户 time.sleep(2) self.selectGroupOffer() # 选择集团商品按钮 self.OfferSubCata() #点击已订购目录 time.sleep(2) self.screen_step("选择要注销的集团商品") # self.DstGrpOfferCode(offerCode,userId) #传入要注销的集团商品编码和用户标识点击注销 self.DstGrpOfferCodeNew(offerCode) #传入要注销的集团商品编码和用户标识点击注销 RuleCheckBefore(self.driver).checkRule(scene) #点击注销后判断规则 DealElements(self.driver).selectRemoveReason(reason) #选择注销原因 DealElements(self.driver).submitAccept() submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) orderId = getDigitFromStr(submitMsg) time.sleep(2) orderTrace = DataCheck().retOrderTrace(orderId) logger.info(orderTrace) self.save_docreport(title)
def ChgMebOffer(self, grpUserId): chgMebOfferCodeStr = "//button[contains(@value,'%s') and contains(@ontap,'ChgMb')]" % grpUserId #传入集团编码并通过Xpath定位 loc_chgMebOfferCode = (By.XPATH, chgMebOfferCodeStr) self.isElementDisplay(loc_chgMebOfferCode, 'click') RuleCheckBefore(self.driver).checkRule() return self.driver
def accept_CrtMb(self, groupId, serialNum, offerCode, grpUserId, planType, itemId, elementAttrBizList=[], scene='CrtMb'): ''' 成员商品受理-订购集团成员产品 :param groupId: 集团编码 :param serialNum: 成员服务号码 :param grpUserId: 集团用户标识 :param AttrBizList: 成员属性列表,需要页面设置 :param elementList: 成员资费和服务 :param planType: 成员付费关系 :param itemId: 成员付费科目 :return: ''' title = '成员商品受理测试记录%s' % serialNum self.add_dochead(title) LoginPage(self.driver).login() # 登录 MainPage(self.driver).open_CataMenu( 'crm8000', 'crm8200', 'crm8206', menuPath='page/order.page.pc.enterprise.operenterprisemember' ) # 进入成员商品受理 self.screen_step("进入成员商品受理菜单") self.GroupQryPart(groupId) #按集团编码查询集团客户 time.sleep(1) DealMebElements(self.driver).QryMebInfo(serialNum) #查询成员用户信息 time.sleep(2) self.selectGroupOffer() # 选择集团商品按钮 self.screen_step("选择集团商品") time.sleep(3) self.SubMebOffer(grpUserId) #成员商品订购按钮 RuleCheckBefore(self.driver).checkRule(scene) DealElements(self.driver).initOfferAttrInfo() #点击商品待设置或者点击商品特征设置 DealElements(self.driver).setOfferAttrNew( elementAttrBizList) #传入需要设置属性列表并设置商品属性 self.screen_step("设置成员商品规格特征") DealMebElements(self.driver).submitMebOfferAttr(offerCode) DealElements(self.driver).initGroupOffer() #点击新增子商品 DealElements(self.driver).selectElements( elementAttrBizList) #选择要订购的资费和服务以及属性 DealElements(self.driver).setPriceOfferCha( elementAttrBizList) # 在受理主页面再设置一次资费服务属性 self.screen_step("选择子商品成员资费和服务") if offerCode == '2222': DealMebElements(self.driver).setGrpMebPayRela( planType, itemId) #桌面电话,只有集团付费,设置集团付费关系 else: DealMebElements(self.driver).selMebPayPlan( planType, itemId) #【可以选择个人付费或集团付费的处理】设置成员付费关系 DealMebElements(self.driver).OpenSubmitGrpMebOffer() #点击提交 submitMsg = PageAssert(self.driver).assert_Submit() logger.info('业务受理信息:{}'.format(submitMsg)) orderId = getDigitFromStr(submitMsg) time.sleep(2) orderTrace = DataCheck().retOrderTrace(orderId) logger.info(orderTrace) self.screen_step('点击提交,受理信息:{}'.format(submitMsg)) self.save_docreport(title)