def test_erlangshen_tiaozhuan(self): """跳转二郎神 :return: """ mylogger = Logger(logger='跳转二郎神').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") n = rp.erlangshen() print(n) mylogger.info("点击二郎神") try: self.assertEqual(n, 'http://www.elangshen.com/', msg='跳转二郎神失败') except: Get_Screenshot(self.driver, '跳转二郎神失败') raise
def test_yunxiezuo_tiaozhuan(self): """跳转云协作 :return: """ mylogger = Logger(logger='跳转云协作').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") n = rp.yunxiezuo() mylogger.info("点击云协作") try: self.assertEqual(n, 'http://cloud.rongdasoft.com/web/main', msg='跳转云协作失败') except: Get_Screenshot(self.driver, '跳转云协作失败') raise
def test_wangjimimima_tiaozhuan(self): """跳转忘记密码 :return: """ mylogger = Logger(logger='跳转忘记密码').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") n = rp.wangjimima() print(n) mylogger.info("点击忘记密码") try: self.assertEqual(n, 'http://elangshen.com/toUpdateUserPwdOne', msg='跳转忘记密码失败') except: Get_Screenshot(self.driver, '跳转云协作失败') raise
def test_zhuce_tiaozhuan(self): """跳转用户注册 :return: """ mylogger = Logger(logger='跳转用户注册').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") n = rp.yonghuzhuce() print(n) mylogger.info("点击用户注册") try: self.assertEqual( n, 'http://elangshen.com/toUserRegisterOne?channel=hcb_web', msg='跳转用户注册失败') except: Get_Screenshot(self.driver, '跳转用户注册失败') raise
def test_tuichu(self): """测试意见反馈页退出按钮 :return: """ mylogger = Logger(logger='测试不修改内容点保存').getlog() mylogger.info("登录'*****@*****.**','a123456'") test_Register_Page(self.driver).login('*****@*****.**', 'a123456') mylogger.info("点修改用户信息") yijianss_tests(self.driver).user_jinglai() mylogger.info("点退出按钮") # print(user_tests(self.driver).nicheng_shuru_neirong(2)) yijianss_tests(self.driver).dian_fanhui() sleep(2) try: self.assertEqual(yijianss_tests(self.driver).tuichuyanzheng(), '智能核查', msg='用户信息修改页不能退出首页') mylogger.info("退出成功") except: Get_Screenshot(self.driver, '用户信息修改页不能退出首页') mylogger.info("用例执行失败已截图") raise
def text_panduanzh(self): """测试账号输入框是否存在内容 :return: """ mylogger = Logger(logger='测试账号输入框是否存在内容').getlog() mylogger.info("登录'*****@*****.**','a123456'") test_Register_Page(self.driver).login('*****@*****.**', 'a123456') mylogger.info("进入积分充值") zhifu_tests(self.driver).jinruf() mylogger.info("查看账号内是否有值") try: self.assertEqual(zhifu_tests(self.driver).zhanghao_huoquf(), '有', msg='账号框里无内容') except: Get_Screenshot(self.driver, '账号框里无内容') mylogger.info("用例执行失败已截图") raise
def test_zhanhaocuowu_tishi(self): """错误账号登录 :return: """ mylogger = Logger(logger='错误账号登录').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") rp.input_username('*****@*****.**') mylogger.info("输入账号") sleep(1) rp.input_password("a123456") mylogger.info("输入密码") sleep(2) jieguo = rp.click_login_bth() mylogger.info("点击登录") try: self.assertEqual(rp.click_shangcuan_bth(), '帐号不存在', msg='不提示账号不存在') except: Get_Screenshot(self.driver, '不提示账号不存在') raise
def test_normal_login(self): """正常登录 :return: """ mylogger = Logger(logger='正常登录').getlog() rp = test_Register_Page(self.driver) rp.open() #打开 mylogger.info("打开浏览器") rp.input_username('*****@*****.**') mylogger.info("输入账号") sleep(1) rp.input_password("a123456") mylogger.info("输入密码") sleep(2) rp.click_login_bth() mylogger.info("点击登录") try: self.assertEqual(rp.tishi(), '登录成功', msg='登录失败') except: Get_Screenshot(self.driver, '登录失败') raise
def txst_baocun(self): """测试不修改内容点保存 :return: """ mylogger = Logger(logger='测试不修改内容点保存').getlog() mylogger.info("登录'*****@*****.**','a123456'") test_Register_Page(self.driver).login('*****@*****.**', 'a123456') mylogger.info("点修改用户信息") user_tests(self.driver).user_jinglai() mylogger.info("点保存") # print(user_tests(self.driver).nicheng_shuru_neirong(2)) user_tests(self.driver).baocun() sleep(2) try: self.assertEqual(user_tests(self.driver).tishi(), '个人资料修改成功', msg='不提示修改成功') except: Get_Screenshot(self.driver, '不提示修改成功') mylogger.info("用例执行失败已截图") raise
def test_zhanghaoweikong_tishi(self): """空账号登录 :return: """ mylogger = Logger(logger='空账号登录').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") rp.input_username('') mylogger.info("输入账号") sleep(1) rp.input_password("a123456123123") mylogger.info("输入密码") sleep(2) rp.click_login_bth() mylogger.info("点击登录") try: self.assertEqual(rp.click_shangcuan_bth(), '账号不能为空', msg='不提示账号不能为空') except: Get_Screenshot(self.driver, '不提示账号不能为空') raise
def test_mimaweikong_tishi(self): """密码空登录 :return: """ mylogger = Logger(logger='密码空登录').getlog() rp = test_Register_Page(self.driver) rp.open() mylogger.info("打开浏览器") rp.input_username('*****@*****.**') mylogger.info("输入账号") sleep(1) rp.input_password('') mylogger.info("输入密码") sleep(2) rp.click_login_bth() mylogger.info("点击登录") try: self.assertEqual(rp.click_shangcuan_bth(), '密码不能为空', msg='不提示密码不能为空') except: Get_Screenshot(self.driver, '不提示密码不能为空') raise
def test_weishuxianzhi(self, name, zhanghao, mima, name1, name2, name3, name4, name5, yuqi, shibai, shuju, shurkuang, zhanghaoleix): """%s :return: """ % name mylogger = Logger(logger=name).getlog() mylogger.info(name1) test_Register_Page(self.driver).login(zhanghao, mima) mylogger.info(name2) yijianss_tests(self.driver).user_jinglai() mylogger.info(name3) yijianss_tests(self.driver).panduanweizhi( weishu_shengchenqi(int(shuju)), shurkuang, '输入', zhanghaoleix) mylogger.info(name4) print( len( yijianss_tests(self.driver).panduanweizhi( int(shuju), shurkuang, '获取', zhanghaoleix)), yijianss_tests(self.driver).tishi()) try: self.assertEqual(yijianss_tests(self.driver).tishi(), yuqi, msg='不提示位数限制') mylogger.info('提示验证成功') mylogger.info(name5) try: self.assertEqual(len( yijianss_tests(self.driver).panduanweizhi( int(shuju), shurkuang, '获取', zhanghaoleix)), (int(shuju) - 1), msg='数据验证失败') mylogger.info('数据验证成功') except: shibai = '数据保存失败' raise except: mylogger.info(shibai) Get_Screenshot(self.driver, yuqi) mylogger.info("用例执行失败已截图") raise
def txst_zhiwei(self, name, zhanghao, mimai, neirong, names1, names2, names3, names4, names5, yuji, wenti): """%s :return: """ % name print(name, neirong) mylogger = Logger(logger=name).getlog() # '0-6' mylogger.info(names1) test_Register_Page(self.driver).login(zhanghao, mimai) mylogger.info(names2) user_tests(self.driver).user_jinglai() mylogger.info(names3) user_tests(self.driver).zhiweis(neirong) # user_tests(self.driver).gongsiname(neirong) if names4 == '保存': mylogger.info(names4) user_tests(self.driver).baocun() try: print( user_tests(self.driver).nicheng_shuru_neirong(6), neirong) mylogger.info(names5) self.assertEqual(user_tests(self.driver).tishi(), yuji, msg=wenti) mylogger.info('保存交互正常') try: self.assertEqual(user_tests( self.driver).nicheng_shuru_neirong(6), neirong, msg='不提示修改成功') mylogger.info('保存数据正常') # sleep(3) except: wenti = '数据保存失败' raise except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise else: mylogger.info(names4) try: mylogger.info(names5) self.assertEqual(user_tests( self.driver).nicheng_shuru_neirong(6), neirong, msg=wenti) mylogger.info('正常') # sleep(3) except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise
def txst_weishuxianzhia(self, name, zhanghao, mimai, weizhisssa, names1, names2, names3, names4, names5, yuji, wenti): """%s :return: """ % name # print(name, neirong) mylogger = Logger(logger=name).getlog() mylogger.info(names1) test_Register_Page(self.driver).login(zhanghao, mimai) mylogger.info(names2) user_tests(self.driver).user_jinglai() mylogger.info(names3) user_tests(self.driver).weishu(int(weizhisssa), weishu_shengchenqi(int(yuji))) mylogger.info(names4) try: self.assertEqual(len( user_tests(self.driver).nicheng_shuru_neirong( int(weizhisssa))), int(yuji) - 1, msg=wenti) mylogger.info(names5) except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise
def txst_nicheng(self, name, zhanghao, mimai, neirong, names1, names2, names3, names4, names5, yuji, wenti): """%s :return: """ % name mylogger = Logger(logger=name).getlog() # '0-6' mylogger.info(names1) test_Register_Page(self.driver).login(zhanghao, mimai) mylogger.info(names2) user_tests(self.driver).user_jinglai() mylogger.info(names3) if neirong == '': user_tests(self.driver).shurujong() else: user_tests(self.driver).xiugai_name(neirong) if names4 == '点保存': mylogger.info(names4) user_tests(self.driver).baocun() try: # print(user_tests(self.driver).nicheng_shuru_neirong()) mylogger.info(names5) self.assertEqual(user_tests(self.driver).tishi(), yuji, msg=wenti) mylogger.info('保存交互正常') try: self.assertEqual(user_tests( self.driver).nicheng_shuru_neirong(0), neirong, msg='不提示修改成功') mylogger.info('保存数据正常') except: wenti = '数据保存失败' raise except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise else: try: # print(user_tests(self.driver).nicheng_shuru_neirong()) mylogger.info(names5) self.assertEqual(user_tests(self.driver).huoqu_nicheng_tishi(), yuji, msg=wenti) mylogger.info('正常') except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise
def test_weishu_dian_queding(self): """测试提示未输入充值积分 :return: """ mylogger = Logger(logger='测试账号输入框是否存在内容').getlog() mylogger.info("登录'*****@*****.**','a123456'") test_Register_Page(self.driver).login('*****@*****.**', 'a123456') mylogger.info("进入积分充值") zhifu_tests(self.driver).jinruf() mylogger.info("点确定") sleep(1) zhifu_tests(self.driver).dian_queding() mylogger.info("判断提示") try: self.assertEqual(zhifu_tests(self.driver).tishi(), '您还未输入充值积分1', msg='未提示未输入充值积分') mylogger.info("成功") except: # mylogger.info("用例执行失败已截图") Get_Screenshot(self.driver, '未提示未输入充值积分') mylogger.info("用例执行失败已截图") raise
def zhineng(self, name_url, name_shizi): mylogger = Logger(logger='智能上传').getlog() time.sleep(1) mylogger.info("信息填写") # 如果资料填写失败,认为存在未上传文件,进行全选删除 try: self.zhinengchuanshuju(name_shizi[0], name_shizi[1], name_shizi[2]) except: self.driver.find_element(*self.wenjian_quanxuan_kuang).click() self.driver.find_element(*self.wenjian_shanchu_click).click() for i in name_url: print(i) time.sleep(2) # try: # resultsss = len(self.driver.find_element(*self.hecha_shuliang_loc).text.split(' 上传成功\n')[0].split('上传成功'))-1#获取上传列表个数 # except: # resultsss = 0 # print(resultsss) # time.sleep(5) mylogger.info("点击上传") self.driver.find_element(*self.shangchuan_loc).click() # print(a[0].split('上传成功\\n')) time.sleep(0.5) mylogger.info("上传文件%s" % i) os.system(r'D:\2.1\shangchuan.exe %s' % i) mylogger.info("判断上传进度") while True: try: result = self.driver.find_element( *self.shangchuan_jindu_loc).text print(result) if result == '100%': mylogger.info("100%成功") # print('完成')“” a = ''.format() self.shangchuan_cisshu += 1 break except: print('-----------------') resultss = len( self.driver.find_element(*self.hecha_shuliang_loc). text.split(' 上传成功\n')[0].split('上传成功')) - 1 if self.shangchuan_cisshu + 1 == resultss: # print('成功') self.shangchuan_cisshu += 1 mylogger.info("100%成功") break else: mylogger.info("上传失败") # print('失败') self.driver.find_element(*self.hecha_click_loc).click()
def test_bitianxiangtishi(self, name, zhanghao, mima, name1, name2, name3, name4, yanzheng, shuru, yuqi, cuowu, shurkuang, zhanghaoleix): """%s :return: """ % name mylogger = Logger(logger=name).getlog() mylogger.info(name1) test_Register_Page(self.driver).login(zhanghao, mima) mylogger.info(name2) yijianss_tests(self.driver).user_jinglai() mylogger.info(name3) yijianss_tests(self.driver).panduanweizhi(shuru, shurkuang, '输入', zhanghaoleix) mylogger.info(name4) yijianss_tests(self.driver).dian_querding() mylogger.info(yanzheng) try: self.assertEqual(yijianss_tests(self.driver).tishi(), yuqi, msg=cuowu) mylogger.info('提示验证成功') except: mylogger.info(cuowu) Get_Screenshot(self.driver, cuowu) mylogger.info("用例执行失败已截图") raise
def test_jifen_jine(self, name, zhanghao, mimai, names1, names2, name21, names3, names4, names5, neirong, yuji, wenti, erji, weizhi, kuang): """%s :return: """ % name mylogger = Logger(logger='name').getlog() mylogger.info(names1) test_Register_Page(self.driver).login(zhanghao, mimai) mylogger.info(names2) zhifu_tests(self.driver).jinruf() mylogger.info(name21) sleep(1) zhifu_tests(self.driver).dian_weizhi('积分充值', '请输入充值积分', '1') mylogger.info(names3) sleep(1) zhifu_tests(self.driver).dian_weizhi(erji, weizhi, weishu_shengchenqi(int(neirong))) mylogger.info(names4) try: print( zhifu_tests(self.driver).huoqu_dian_weizhi(erji, kuang), (int(yuji))) self.assertEqual(len( zhifu_tests(self.driver).huoqu_dian_weizhi(erji, kuang)), (int(yuji)), msg=wenti) mylogger.info(names5) except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise
def test_bitianxiangtishi(self, name, zhanghao, mima, name1, name2, name3, name4, name5, name6, name7, yuqi, cuowu, shuju, leix, zhanghaolx): """%s :return: """ % name print(zhanghaolx) mylogger = Logger(logger=name).getlog() mylogger.info(name1) test_Register_Page(self.driver).login(zhanghao, mima) mylogger.info(name2) yijianss_tests(self.driver).user_jinglai() mylogger.info(name3) yijianss_tests(self.driver).panduanweizhi(weishu_shengchenqi(4), '机构名称', '输入', zhanghaolx) yijianss_tests(self.driver).panduanweizhi(weishu_shengchenqi(4), '联系人', '输入', zhanghaolx) mylogger.info(name4) yijianss_tests(self.driver).panduanweizhi(shuju, leix, '无', '无') sleep(5) mylogger.info(name5) yijianss_tests(self.driver).dian_querding() try: mylogger.info(name6) self.assertEqual(yijianss_tests(self.driver).tishi2(), yuqi, msg='不提示提交成功') mylogger.info('提示验证成功') try: mylogger.info(name7) print(huoqu(leix, shuju), shuju) self.assertEqual(huoqu(leix, shuju), shuju, msg='数据核实失败') mylogger.info('数据验证成功') except: cuowu = '数据保存失败' raise except: mylogger.info(cuowu) Get_Screenshot(self.driver, cuowu) mylogger.info("用例执行失败已截图") raise
def test_zhanghaohuixian(self, name, zhanghao, mima, name1, name2, name3, yuqi, cuowu, shuju, shurkuang, zhanghaoleix): """%s :return: """ % name mylogger = Logger(logger=name).getlog() mylogger.info(name1) test_Register_Page(self.driver).login(zhanghao, mima) mylogger.info(name2) yijianss_tests(self.driver).user_jinglai() mylogger.info(name3) try: self.assertEqual(yijianss_tests(self.driver).panduanweizhi( shuju, shurkuang, '获取', zhanghaoleix), zhanghao, msg=cuowu) mylogger.info('回显成功') except: mylogger.info(cuowu) Get_Screenshot(self.driver, cuowu) mylogger.info("用例执行失败已截图") raise
def test_xingbie(self, name, zhanghao, mimai, xingbie, names1, names2, names3, names4, names5, wenti): """%s :return: """ % name mylogger = Logger(logger=name).getlog() mylogger.info(names1) test_Register_Page(self.driver).login(zhanghao, mimai) mylogger.info(names2) user_tests(self.driver).user_jinglai() mylogger.info(names3) user_tests(self.driver).xuanze_xb(xingbie) # print(user_tests(self.driver).nicheng_shuru_neirong(int(caoz)), xingbie) mylogger.info(names4) user_tests(self.driver).baocun() try: mylogger.info(names5) self.assertEqual(user_tests(self.driver).tishi(), '个人资料修改成功', msg=wenti) mylogger.info('保存交互正常') print(user_tests(self.driver).nicheng_shuru_neirong(2), xingbie) try: self.assertEqual(user_tests( self.driver).nicheng_shuru_neirong(2), xingbie, msg='数据没有回显成功') mylogger.info('保存数据正常') except: wenti = '数据保存失败' raise except: mylogger.info(wenti) Get_Screenshot(self.driver, wenti) mylogger.info("用例执行失败已截图") raise