def test_HuanKuan1(self,exist = False): u"""还款--默认首期""" print("*************执行 还款-默认首期 用例**************") params = Params() try: self.driver.find_element_by_id("rl_repayment").click() #点击首页中的去还款 time.sleep(2) self.driver.find_element_by_id("tv_state").click() #选择第一条数据 time.sleep(2) self.driver.find_element_by_id("tv_repayment").click() #默认首期,直接点击还款 time.sleep(2) self.driver.find_element_by_id("rl_top").click() #跳转到银行卡管理页,选择第一个 time.sleep(8) inputText(self,params['applyPWD']) #输入支付密码 time.sleep(8) exist=is_resultActivity(self) #判断是否成功跳转到了还款成功页 except: exist = False #获取当前方法名作为截图名 pic_name = get_current_function_name() #调用截图方法 getScreen(self,pic_name) #写入日志 logger=Logger(logname='log.txt',loglevel="INFO",logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, True)
def test_reset_pwd(self): u'''忘记密码''' print("*************执行忘记密码用例**************") params = Params() try: self.driver.find_element_by_id("iv_head").click() #点击头像到个人中心页 time.sleep(2) self.driver.find_element_by_id("rl_top").click() #点击个人中心页中的登录,跳转到登录页 time.sleep(2) self.driver.find_element_by_id('tv_forgetpwd').click() #跳转到登录页,点击忘记密码 time.sleep(2) #异常情况 self.driver.find_element_by_id('et_phonenum').send_keys(params['phone']) #输入手机号,其他不输入 self.driver.find_element_by_id('tv_queren_reset').click() #点击确认重置 time.sleep(2) self.driver.find_element_by_id('et_phonenum').send_keys(params['phone']) #输入手机号 self.driver.find_element_by_id('tv_getAuthCode').click() #获取短信验证码 sms_yanzhengma = input("请输入短信验证码:") #手动输入 time.sleep(8) self.driver.find_element_by_id('et_authcode').send_keys(sms_yanzhengma) #脚本自动输入短信验证码 time.sleep(2) self.driver.find_element_by_id('et_pwd').send_keys(params['loginPWD']) #输入密码 time.sleep(2) self.driver.find_element_by_id('et_queren_pwd').send_keys("111111") #再次输入密码不一致 self.driver.find_element_by_id('tv_queren_reset').click() #点击确认重置 #正确情况 self.driver.find_element_by_id('et_phonenum').send_keys(params['phone']) #输入手机号 self.driver.find_element_by_id('tv_getAuthCode').click() #获取短信验证码 sms_yanzhengma = input("请输入短信验证码:") #手动输入 time.sleep(8) self.driver.find_element_by_id('et_authcode').send_keys(sms_yanzhengma) #脚本自动输入短信验证码 time.sleep(2) self.driver.find_element_by_id('et_pwd').send_keys(params['loginPWD']) #输入密码 time.sleep(2) self.driver.find_element_by_id('et_queren_pwd').send_keys(params['loginPWD']) #再次输入密码 self.driver.find_element_by_id('tv_queren_reset').click() #点击确认重置 exist = False try: self.driver.find_element_by_id('tv_queren_reset').click() #判断是否还存在确认按钮,确认是否成功修改 print("输入密码有误") exist = True except Exception as e: pass except: exist = True pic_name = get_current_function_name() #获取当前用例名 getScreen(self,pic_name) #调用截图方法 logger=Logger(logname='log.txt',loglevel="INFO",logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, False) #修改失败,确认按钮存在
def test_credit_addCard(self): u'''授信''' print("*****************执行授信用例****************") params = Params() self.driver.find_element_by_id("tv_apply").click() #点击马上申请 try: self.driver.find_element_by_id("tv_id_verify").click() #点击实名认证 time.sleep(2) self.driver.find_element_by_id("et_cardusername").send_keys( params['username']) #输入持卡人姓名 self.driver.find_element_by_id("et_idnum").send_keys( params['ID']) #输入身份证号 time.sleep(2) exist = False while exist == False: self.driver.find_element_by_id( "et_bankcardnum").click() #输入银行卡号,4位一个空格 input_text.inputText(self, params['cardNumber']) #调用了延时方法输入 self.driver.find_element_by_id("et_phone").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id("tv_next").click() #点击下一步 time.sleep(2) try: self.driver.find_element_by_id( "et_idnum").click() #输入银行卡信息有误 print("输入银行卡信息有误") self.driver.find_element_by_id("iv_delete_idcard").click() time.sleep(2) except: exist = True sms_yanzhengma = input("请输入短信验证码:") #输入手机验证码 time.sleep(8) self.driver.find_element_by_id("et_authcode").send_keys( sms_yanzhengma) self.driver.find_element_by_id('tv_next').click() #点击下一步 time.sleep(15) try: self.driver.find_element_by_id("tv_complete").click() #点击跳过按钮 exist = False except: print("短信验证码有误") except: print("授信失败") pic_name = get_current_function_name() #获取当前方法名作为截图名 get_screen.getScreen(self, pic_name) #调用截图方法 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) #写入日志 self.assertEqual(exist, False)
def test_JieKuan12(self): u"""借款-12期""" params = Params() #点击马上申请 self.driver.find_element_by_id('tv_apply').click() time.sleep(3) try: slideApplyBar(self) #滑动借款条到500 self.driver.find_element_by_id( 'rl_borrow_sence').click() #选择借款场景:家用电器 self.driver.find_element_by_id('tv_sence').click() self.driver.find_element_by_id('rl_num_periods').click() #借款周期 self.driver.find_element_by_xpath( '//android.widget.ListView/android.widget.LinearLayout[3]/android.widget.TextView' ).click() #选了分12期的 time.sleep(8) edu = self.driver.find_element_by_id( 'com.ibeesaas.tianbaodai:id/tv_borrow_num').text #获取额度 num_edu = int(edu) if num_edu >= 500: self.driver.find_element_by_id( 'tv_borrow_immedia').click() #点击马上借 time.sleep(3) inputText(self, params['applyPwd']) #加了延时输入 time.sleep(8) exist = is_resultActivity(self) #判断是否成功跳转到借款成功页 else: exist = False self.driver.find_element_by_id( 'tv_borrow_immedia').click() #点击马上借 print(u"额度小于500,无法借款") except: exist = False #获取方法名作为截图名 pic_name = get_current_function_name() #调用截图方法 getScreen(self, pic_name) #写入日志 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, True)
def test_UpdateLogin(self): u"""修改登录密码""" print("*************执行修改登录密码用例**************") params = Params() self.driver.find_element_by_id("iv_head").click() #点击进入个人中心页 self.driver.find_element_by_id("rl_pwd_manage").click() #点击密码管理 try: self.driver.find_element_by_id("rl_reset_loginpwd").click() #点击修改登录密码 #异常情况 self.driver.find_element_by_id("tv_confimchange").click() #不输入,点击确认修改 time.sleep(2) self.driver.find_element_by_id("et_originpwd").send_keys(params['loginPWD']) # #输入原密码 self.driver.find_element_by_id("et_pwd").send_keys(params['loginPWD']) #输入新密码 self.driver.find_element_by_id("et_queren_pwd").send_keys("111111") #再次输入 不一致新密码 self.driver.find_element_by_id("tv_confimchange").click() #点击确认修改 time.sleep(2) #正常情况 self.driver.find_element_by_id("et_originpwd").send_keys(params['loginPWD']) # #输入原密码 time.sleep(2) self.driver.find_element_by_id("et_pwd").send_keys(params['loginPWD']) #输入新密码 time.sleep(2) self.driver.find_element_by_id("et_queren_pwd").send_keys(params['loginPWD']) #再次输入新密码 self.driver.find_element_by_id("tv_confimchange").click() #点击确认修改 time.sleep(2) exist = False try: self.driver.find_element_by_id("tv_confimchange").click() #点击确认修改 exist = True except: pass except: exist = True pic_name = get_current_function_name() #调用截图方法 getScreen(self,pic_name) #写入日志 logger=Logger(logname='log.txt',loglevel="INFO",logger=pic_name).getlog() logger.info("*************执行修改登录密码用例**************") logger.error(traceback.format_exc()) self.assertEqual(exist,False) #已跳转,不在修改页
def test_JieKuan3(self): u"""借款-3期""" params = Params() print("*************执行借款用例**************") self.driver.find_element_by_id('tv_apply').click() #点击马上申请 time.sleep(3) try: slideApplyBar(self) #滑动借款条到500 self.driver.find_element_by_id('rl_borrow_sence').click() #选择借款场景 self.driver.find_element_by_id('tv_sence').click() #家用电器 self.driver.find_element_by_id('rl_num_periods').click() #借款周期 self.driver.find_element_by_id('tv_sence').click() #选了分3期的 time.sleep(8) edu = self.driver.find_element_by_id('tv_borrow_num').text #获取借款额度 num_edu = int(edu) if num_edu >= 500: self.driver.find_element_by_id( 'tv_borrow_immedia').click() #点击马上借 time.sleep(3) inputText(self, params['applyPwd']) #输入支付密码,加了延时输入 time.sleep(8) exist = is_resultActivity(self) #判断是否成功跳转到借款成功页 else: exist = False self.driver.find_element_by_id( 'tv_borrow_immedia').click() #点击马上借 print(u"额度小于500,无法借款") except: exist = False #获取当前方法名作为截图名 pic_name = get_current_function_name() #调用截图方法 getScreen(self, pic_name) #写入日志 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, True)
def test_UpdatePay(self): u"""修改支付密码""" print("*************执行修改支付密码用例**************") params = Params() self.driver.find_element_by_id("iv_head").click() self.driver.find_element_by_id("rl_pwd_manage").click() #点击密码管理 try: self.driver.find_element_by_id('tv_changeTranPwd').click() #点击修改支付密码 self.driver.find_element_by_id('tv_getAuthCode').click() #点击获取支付密码 zf_pwd = input("请输入短信验证码:") #需要手动输入 time.sleep(8) self.driver.find_element_by_id('et_authcode').send_keys(zf_pwd) self.driver.find_element_by_id('tv_next').click() #点击下一步 time.sleep(2) try: #输入支付密码 inputText(self,params['applyPWD']) #延时输入 time.sleep(2) inputText(self,params['applyPWD']) #再次确认输入 time.sleep(2) except: pass exist = False try: self.driver.find_element_by_id("inputView").click() #输入框是否隐藏 exist = True except: print("两次输入不一致") pass except: exist = True pic_name = get_current_function_name() #获取方法名 getScreen(self,pic_name) #调用截图方法 #写入日志 logger=Logger(logname='log.txt',loglevel="INFO",logger=pic_name).getlog() logger.info("*************执行修改支付密码用例**************") logger.error(traceback.format_exc()) self.assertEqual(exist,False) #已跳转,不在修改页
def test_HuanKuan2(self,exist = False): u"""还款--多期(全部还款)""" params = Params() print("*************执行 还款-多期全部还款 用例**************") try: self.driver.find_element_by_id("rl_repayment").click() #点击首页中的去还款 time.sleep(2) self.driver.find_element_by_id("tv_state").click() #选择第一条数据 self.driver.find_element_by_id('ll_zoom').click() #选择多期 swipeUp(self,1200) #往上拉页面 eles = self.driver.find_elements_by_xpath('//android.widget.ListView/android.widget.LinearLayout') #获取所有期数 if len(eles) == 12: #12期 print("12期") self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.LinearLayout[12]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView').click() elif len(eles) ==6: #6期 print("6期") ele = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.LinearLayout[6]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView').click() else: #3期 print("3期") ele = self.driver.find_element_by_xpath('//android.widget.ListView/android.widget.LinearLayout[3]/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]/android.widget.ImageView').click() swipeUp(self,1000) #往上滑动页面,定位还款按钮 self.driver.find_element_by_id("tv_repayment").click() # 点击还款 time.sleep(2) self.driver.find_element_by_id("rl_top").click() #跳转到银行卡管理页,选择第一个 time.sleep(8) inputText(self,params['applyPWD']) #输入支付密码 time.sleep(8) exist = is_resultActivity(self) #判断是否成功 except: exist = False #获取当前方法名作为截图名 pic_name = get_current_function_name() #调用截图方法 getScreen(self,pic_name) #写入日志 logger=Logger(logname='log.txt',loglevel="INFO",logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, True)
def test_Register(self): u"""注册""" print("*************执行注册用例**************") params = Params() self.driver.find_element_by_id("iv_head").click() #点击头像到个人中心页 time.sleep(2) self.driver.find_element_by_id("rl_top").click() #点击个人中心页中的登录,跳转到登录页 time.sleep(2) try: self.driver.find_element_by_id("tv_regist").click() #点击注册按钮,跳转到注册页 time.sleep(2) self.driver.find_element_by_id( "tv_regist_login").click() #点击注册页中的立即登录,跳转到登录 time.sleep(2) self.driver.find_element_by_id("tv_regist").click() #再点击注册 time.sleep(2) #异常情况 self.driver.find_element_by_id( "tv_getAuthCode").click() #不输入手机号,点击获取短信验证码 time.sleep(2) self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) #输入手机号,其他不输入 self.driver.find_element_by_id("tv_regist").click() #点击注册 time.sleep(2) self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id( "tv_getAuthCode").click() #点击获取短信验证码 self.driver.find_element_by_id("et_authcode").send_keys( params['sms_yzm']) #输入通用短信验证码 self.driver.find_element_by_id("tv_regist").click() #点击注册 time.sleep(2) self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id( "tv_getAuthCode").click() #点击获取短信验证码 time.sleep(2) self.driver.find_element_by_id("et_authcode").send_keys( params['sms_yzm']) #输入通用短信验证码 time.sleep(2) self.driver.find_element_by_id("et_imgpwd").send_keys( "123123") #输入错误图形验证码 time.sleep(2) self.driver.find_element_by_id("et_pwd").send_keys( params['loginPWD']) #输入密码 self.driver.find_element_by_id("tv_regist").click() #点击注册 time.sleep(2) self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id( "tv_getAuthCode").click() #点击获取短信验证码 time.sleep(2) self.driver.find_element_by_id("et_authcode").send_keys( "123") #输入错误短信验证码 time.sleep(2) self.driver.find_element_by_id("et_imgpwd").send_keys( params['image_yzm']) #输入错误图形验证码 time.sleep(2) self.driver.find_element_by_id("et_pwd").send_keys( params['loginPWD']) #输入密码 self.driver.find_element_by_id("tv_regist").click() #点击注册 time.sleep(2) #输入正确注册信息 self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id( "tv_getAuthCode").click() #点击获取短信验证码 time.sleep(2) self.driver.find_element_by_id("et_authcode").send_keys( params['sms_yzm']) #输入通用短信验证码 time.sleep(2) self.driver.find_element_by_id("et_imgpwd").send_keys( params['image_yzm']) #输入通用短信验证码 time.sleep(2) self.driver.find_element_by_id("et_pwd").send_keys( params['loginPWD']) #输入密码 self.driver.find_element_by_id("tv_regist").click() #点击注册按钮 time.sleep(5) exist = False #判断是否存在注册按钮,以此推断是否登录成功 #例如有已注册手机号 try: self.driver.find_element_by_id("tv_regist").click() #再次点击注册 print("手机号已注册") time.sleep(2) exist = True except: pass except: exist = True pic_name = get_current_function_name() #获取当前用例名 getScreen(self, pic_name) #调用截图方法 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) #写入日志 self.assertEqual(exist, False) #注册失败
def test_addCard(self): u"""添加银行卡""" print("*************执行添加银行卡用例**************") params = Params() self.driver.find_element_by_id("iv_head").click() #点击头像进入个人中心页 self.driver.find_element_by_id("rl_card_manage").click() #点击银行卡管理 time.sleep(2) try: self.driver.find_element_by_id( "tv_addBankCard").click() #点击添加银行卡按钮 time.sleep(2) self.driver.find_element_by_id("et_cardusername").send_keys( params['username']) #输入持卡人姓名 self.driver.find_element_by_id("et_idnum").send_keys( params['ID']) #输入身份证号 time.sleep(2) self.driver.find_element_by_id( "et_bankcardnum").click() #输入银行卡号,4位一个空格 input_text.inputText(self, params['cardNumber']) #调用了延时方法输入 self.driver.find_element_by_id("et_phone").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id("tv_next").click() #点击下一步 time.sleep(2) exist = False while exist == False: self.driver.find_element_by_id( "et_bankcardnum").click() #输入银行卡号,4位一个空格 input_text.inputText(self, params['cardNumber']) #调用了延时方法输入 self.driver.find_element_by_id("et_phone").send_keys( params['phone']) #输入手机号 self.driver.find_element_by_id("tv_next").click() #点击下一步 time.sleep(2) try: self.driver.find_element_by_id( "et_idnum").click() #输入银行卡信息有误 print("输入银行卡信息有误") self.driver.find_element_by_id("iv_delete_idcard").click() time.sleep(2) except: exist = True sms_yanzhengma = input("请输入短信验证码:") #输入手机验证码 time.sleep(8) self.driver.find_element_by_id("et_authcode").send_keys( sms_yanzhengma) self.driver.find_element_by_id('tv_next').click() #点击下一步 time.sleep(15) try: self.driver.find_element_by_id("tv_next").click() #短信验证码有误 print("短信验证码有误") except: exist = False except: print("绑卡失败") #获取当前方法名作为截图名 pic_name = get_current_function_name() #调用截图方法 getScreen(self, pic_name) #写入日志 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, False)
def test_Login(self): u"""登录""" print("*************执行登录用例**************") self.driver.find_element_by_id("iv_head").click() #点击头像到个人中心页 time.sleep(2) try: self.driver.find_element_by_id( "rl_top").click() #点击个人中心页中的登录,跳转到登录页 time.sleep(2) self.driver.find_element_by_id("tv_forgetpwd").click() #点击忘记密码 time.sleep(2) self.driver.find_element_by_id("iv_back").click() #点击返回 time.sleep(3) self.driver.find_element_by_id("tv_regist").click() #点击注册 time.sleep(2) self.driver.find_element_by_id( "tv_regist_login").click() #点击立即登录,返回到登录页 time.sleep(2) self.driver.find_element_by_id("et_phonenum").send_keys( "18310141768") #输入手机号,不输入密码 self.driver.find_element_by_id("tv_login").click() #点击登录 time.sleep(2) #输入任意手机号,任意密码 self.driver.find_element_by_id("et_phonenum").send_keys( "18310141760") #输入任意手机号,任意密码 self.driver.find_element_by_id("et_pwd").send_keys("121212") self.driver.find_element_by_id("tv_login").click() #点击登录 time.sleep(5) self.driver.find_element_by_id("et_phonenum").send_keys( "18310141768") #输入正确手机号,错误密码 self.driver.find_element_by_id("iv_pwd_delete").click() #清空一下 self.driver.find_element_by_id("et_pwd").send_keys("121212") self.driver.find_element_by_id("tv_login").click() #点击登录 time.sleep(5) #输入正确登录数据 params = Params() self.driver.find_element_by_id("et_phonenum").send_keys( params['phone']) self.driver.find_element_by_id("iv_pwd_delete").click() #清空一下 self.driver.find_element_by_id("et_pwd").send_keys( params['loginPWD']) try: self.driver.find_element_by_id("et_imgpwd").send_keys( params['image_yzm']) #输入图形验证码 except: pass self.driver.find_element_by_id("tv_login").click() #点击登录 time.sleep(5) self.driver.find_element_by_name('退出登录').click() #点击个人中心页中退出按钮 time.sleep(2) exist = True except: exist = False pic_name = get_current_function_name() #调用截图方法 getScreen(self, pic_name) #写入日志 logger = Logger(logname='log.txt', loglevel="INFO", logger=pic_name).getlog() logger.error(traceback.format_exc()) self.assertEqual(exist, True) #登录失败