def test_02_login_normal(self): '''正确用户名,正确密码登录''' log.info("验证正确用户名、正确密码登录") tel = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'pwd_1_right') lp = LoginPage(self.driver) lp.login_opera(tel, pwd) time.sleep(2) # 判断是否登录成功 result = False udp = UpdatePopup(self.driver) if lp.new_is_exist_element("立即更新"): result = True udp.cancel_opera() # 判断是否存在通知弹窗 if lp.is_exist_element(udp.cancel_el): udp.cancel_opera() if lp.new_is_exist_element("我知道了"): Iknow(self.driver).click_iknow_btn() elif lp.is_exist_element(udp.cancel_el): udp.cancel_opera() if lp.new_is_exist_element("我知道了"): Iknow(self.driver).click_iknow_btn() elif lp.new_is_exist_element("我知道了"): result = True Iknow(self.driver).click_iknow_btn() else: if lp.new_is_exist_element("首页"): result = True self.assertTrue(result) time.sleep(1)
def init_to_home(self): '''滑动引导页进入登录页面,登录进入首页''' try: mobile = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'pwd_1_right') StartPage(self.driver).swipe_start() lp = LoginPage(self.driver) lp.login_opera(mobile, pwd) time.sleep(1) # 判断是否登录成功 if lp.is_exist_element(self.update_ele): log.info("登录成功,进入首页...") self.update_cancel_opera() # 判断是否存在通知弹窗 if lp.is_exist_element(self.cancel_el): self.notice_cancel_opera() # 判断是否存在"知道了" if lp.is_exist_element(self.iknow_ele): self.iknow_click_opera() else: pass elif lp.is_exist_element(self.cancel_el): log.info("登录成功,进入首页...") self.notice_cancel_opera() elif lp.is_exist_element(self.iknow_ele): log.info("登录成功,进入首页...") self.iknow_click_opera() elif lp.is_exist_element(self.home_ele): log.info("登录成功,进入首页...") pass else: log.error("初始化登录失败,终止自动化程序!!!") sys.exit(0) except Exception as e: log.error("进入首页失败:{}".format(e))
def test_02_modify_pwd(self): '''验证修改后的密码能否登录''' log.info("验证修改后的密码能否登录") tel = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'new_pwd_s') lp = LoginPage(self.driver) lp.login_opera_again(tel, pwd) log.info("登录操作") time.sleep(2) # 断言是否登录成功 result = False if lp.new_is_exist_element("立即更新"): result = True # 有则点击取消 UpdatePopup(self.driver).cancel_opera() elif lp.new_is_exist_element("首页"): result = True self.assertTrue(result) time.sleep(2) # 为不影响后面的测试,需将密码还原成旧密码 ms = MySet(self.driver) ms.enter_to_my() ms.enter_to_set() # 修改密码操作 old_pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'new_pwd_s') new_pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'old_pwd_s') ms.change_pwd(old_pwd, new_pwd) time.sleep(2)
def test_01_login_abnormal(self): '''正确用户名,错误密码登录''' log.info("验证正确用户名、错误密码登录") tel = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'pwd_1_wrong') lp = LoginPage(self.driver) lp.login_opera(tel, pwd) # time.sleep(2) result = lp.is_toast_exist("账号或密码错误") self.assertTrue(result) time.sleep(2)
def test_02_login_normal(self): '''正确用户名,正确密码登录''' log.info("验证正确用户名、正确密码登录") tel = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'pwd_1_right') lp = LoginPage(self.driver) lp.login_opera(tel, pwd) time.sleep(2) # 断言是否登录成功 pgi = PageInit(self.driver) result = pgi.is_login_success() self.assertTrue(result) time.sleep(3)
def test_01_modify_pwd(self): '''验证能否修改密码''' log.info("验证能否修改密码") # ->我的->设置 ms = MySet(self.driver) ms.enter_to_my() ms.enter_to_set() # 修改密码操作 old_pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'old_pwd_s') new_pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'new_pwd_s') ms.change_pwd(old_pwd, new_pwd) # 判断是否修改成功 result = False if ms.is_toast_exist("修改成功"): result = True elif ms.new_is_exist_element("验证码登录"): result = True self.assertTrue(result) time.sleep(2)
def test_month_revenue(self): '''验证首页-当月收益导出功能''' log.info("验证首页-当月收益导出功能") # 进入当月收益页面,点击导出 hp = HomePage(self.driver) hp.enter_to_month_revenue() email = get_yaml_value(TEST_ACCOUNT_PATH, 'email') hp.export_opera(email) # 断言导出是否成功 result = hp.is_toast_exist(hp.export_success_toast) self.assertTrue(result)
def test_report_export(self): '''验证报表页流水导出功能''' log.info("验证报表页导出功能") # 进入报表页-流水,进行导出操作 rfp = ReportFormPage(self.driver) rfp.enter_to_report() email = get_yaml_value(TEST_ACCOUNT_PATH, 'email') rfp.report_export_opera(email) # 断言导出是否成功 result = rfp.is_toast_exist(rfp.export_success_toast) self.assertTrue(result)
def init_to_home(self): '''滑动引导页进入登录页面,登录进入首页''' try: mobile = get_yaml_value(TEST_ACCOUNT_PATH, 'account_1') pwd = get_yaml_value(TEST_ACCOUNT_PATH, 'pwd_1_right') StartPage(self.driver).swipe_start() lp = LoginPage(self.driver) lp.login_opera(mobile, pwd) time.sleep(2) # 判断是否登录成功,不成功则再进行一次判定操作 result = self.is_login_success() if result: log.info("登录成功,进入首页...") else: time.sleep(2) result_2 = self.is_login_success() if result_2: log.info("登录成功,进入首页...") else: log.error("初始化登录失败,终止自动化程序!!!") # sys.exit(0) except Exception as e: log.error("进入首页失败:{},终止用例执行!!!".format(e)) sys.exit(0)
def test_today_revenue(self): '''验证首页-今日收益导出功能''' log.info("验证首页-今日收益导出功能") # 进入今日收益页面,点击导出 hp = HomePage(self.driver) # 判断今日收益展示是否为零,为零则不执行导出操作 today_revenue_text = hp.today_revenue().text if today_revenue_text == "0.00": log.info("今日收益:%s" % today_revenue_text) return else: hp.enter_to_today_revenue() email = get_yaml_value(TEST_ACCOUNT_PATH, 'email') hp.export_opera(email) # 断言导出是否成功 result = hp.is_toast_exist(hp.export_success_toast) self.assertTrue(result)