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 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 notice_cancel_opera(self): '''判断是否有通知弹窗,有则点击关闭''' # result = self.is_exist_element(self.cancel_el) # if result: # UpdatePopup(self.driver).cancel_opera() # else: # pass UpdatePopup(self.driver).cancel_opera()
def update_cancel_opera(self): '''判断登录后是否存在非强制更新弹窗,存在则点击取消按钮''' # result = self.is_exist_element(self.update_ele) # # print(result) # if result: # UpdatePopup(self.driver).cancel_opera() # else: # pass UpdatePopup(self.driver).cancel_opera()