def setup_class(self): """ 点击我的 :return: """ self.obj_page = Login_Page( get_driver('com.tpshop.malls', '.SPMainActivity')) self.obj_page.click_my_btn_page()
def setup_class(self): # 实例化登陆对象 logger.info("调起同桌100") os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') # os.system('adb shell am broadcast -a com.baidu.duer.query -e q "退出"') os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') self.LP_obj = Login_Page(get_driver())
def get_login_page_obj(self): """返回登录页面对象""" return Login_Page(self.driver)
def get_login_page(self): # 返回登陆页面对象 return Login_Page(self.driver)
def return_login(self): # 登录页对象 return Login_Page(self.driver)
class Test_Log(object): def setup_class(self): """ 点击我的 :return: """ self.obj_page = Login_Page( get_driver('com.tpshop.malls', '.SPMainActivity')) self.obj_page.click_my_btn_page() def teardown_class(self): """ 关闭应用 :return: """ self.obj_page.driver.quit() @pytest.mark.parametrize('phone,pwd,toast_mess,expect_mess,tag', get_data()) def test_login(self, phone, pwd, toast_mess, expect_mess, tag): """ :param phone: 输入账号 :param pwd:输入密码 :param toast_mess:获取toast传参 :param expect_mess:登录后期望toast :param tag:标记执行成功测试用例 :return: """ #点击登录/注册按钮 self.obj_page.click_login_resi_page() #进入到输入手机号和密码的登录页面 #输入手机号,#输入密码 self.obj_page.input_user_pwd_page(phone, pwd) if tag: try: #获取登录成功toast消息 suc_mess = self.obj_page.get_toast(toast_mess) #获取登录成功我的订单状态 order_state = self.obj_page.if_order_page() #点击退出登录 self.obj_page.logout_page() assert suc_mess == expect_mess and order_state except Exception as e: #如果获取获取不到以上信息,就关闭登录信息输入页面 print(e) self.obj_page.person_input_close_page() else: try: #获取登录失败toast消息 fail_mess = self.obj_page.get_toast(toast_mess) if fail_mess: assert fail_mess == expect_mess else: return False finally: self.obj_page.person_input_close_page()
def get_login_page_obj(self): return Login_Page(self.driver)
def get_login_page_obj(self): # 返回登录页面实例化对象 return Login_Page(self.driver)
def setup_class(self): self.TP_driver = Login_Page(get_server_settings("com.tpshop.malls",".SPMainActivity")) #点击我的按钮 self.TP_driver.click_my_btn()
class Test_TP(): def setup_class(self): self.TP_driver = Login_Page(get_server_settings("com.tpshop.malls",".SPMainActivity")) #点击我的按钮 self.TP_driver.click_my_btn() def teardown_class(self): self.TP_driver.driver.quit() @pytest.mark.parametrize("num,phone,password,get_mess,xpect_message,tag",put_data()) def test_login(self,num,phone,password,get_mess,xpect_message,tag): #点击登录注册按钮 self.TP_driver.click_login_sign_btn() #登录操作 self.TP_driver.login_input_page(phone,password) if tag: try: #获取登录成功toast toast_mes = self.TP_driver.get_toast(get_mess) #获取登录后状态 status = self.TP_driver.if_my_order_status() #退出登录 self.TP_driver.logout_page() assert toast_mes == xpect_message and status except Exception as e: #退出登录信息输入页面 self.TP_driver.login_close_page() assert False else: try: #获取登录失败toast toast_fail_toast = self.TP_driver.get_toast(get_mess) if toast_fail_toast: assert toast_fail_toast == xpect_message else: assert False finally: self.TP_driver.login_close_page()
def setup_class(self): self.obj = Login_Page(get_driver()) # 点击我的 self.obj.click_btn()
class Test_login: def setup_class(self): self.obj = Login_Page(get_driver()) # 点击我的 self.obj.click_btn() def teardown_class(self): self.obj.driver.quit() @pytest.mark.parametrize('test_login_num,username,passwd,get_mess,expect_message,tag', get_data()) def test_login(self, test_login_num, username, passwd, get_mess, expect_message, tag): # 点击登录注册 self.obj.click_login_sign_btn() self.obj.input_phone(username, passwd) # 分两种去情况 我的订单 和登录失败 # 输入手机号 密码 点击登录 # 输入正确的手机号和密码 if tag: try: # 断言是否登录成功和是否有 我的订单内容 login_toast = self.obj.get_toast(get_mess) login_status = self.obj.if_my_order_status() #点击设置 self.obj.click_setting_btn() # 退出登录 点击安全退出 self.obj.safe_logout() assert login_toast==expect_message and login_status except Exception as e: assert False finally: # 点击 登录页面的关闭按钮 self.obj.quit_login_page() else: try: mess = self.obj.get_toast(get_mess) if mess: assert mess == expect_message else: assert False finally: self.obj.quit_login_page()
class Test_Login: def setup_class(self): # 实例化登陆对象 logger.info("调起同桌100") os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') # os.system('adb shell am broadcast -a com.baidu.duer.query -e q "退出"') os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') os.system( 'adb shell am broadcast -a com.baidu.duer.query -e q "打开同桌100"') self.LP_obj = Login_Page(get_driver()) # 点击个人中心 # sleep(5) # self.LP_obj.click_sy_login_btn() def teardown_class(self): self.LP_obj.driver.quit() @pytest.mark.parametrize( "case_num, username, passwd,get_mess,expect_message, tag", get_data()) def test_login_page(self, case_num, username, passwd, get_mess, expect_message, tag): """ :param username: 用户名 :param passwd: 密码 :param get_mess: toast传参 :param expect_message: 预期toast消息 :param tag: 1 标记登陆成功用例 2 标记账号不存在 3标记登录失败 :return: """ # 点击登陆注册 # logger.info("点击登录/注册") # self.LP_obj.click_sy_login_btn() # 登陆操作 logger.info("登录相关操作") self.LP_obj.click_sy_login_btn() self.LP_obj.login_input_page(username, passwd) if tag == 1: try: # 获取登陆成功toast logger.info("正向登录用例") suc_msg = self.LP_obj.get_toast(get_mess) logger.debug("获取登录成功toast:{}".format(suc_msg)) # 退出登录 self.LP_obj.logout_page() assert suc_msg == expect_message logger.success("断言成功{}=={}".format(suc_msg, expect_message)) except Exception as e: # 捕获异常信息+截图 self.LP_obj.error_dispose(e) # 关闭登录信息输入页面 self.LP_obj.login_back_page() assert False elif tag == 2: try: logger.debug("登录不存在的账号用例") # 获取登陆成功toast suc_msg = self.LP_obj.get_toast(get_mess) logger.debug("获取账号不存在toast:{}".format(suc_msg)) # 退出登录 self.LP_obj.login_close_page() assert suc_msg == expect_message logger.success("断言成功{}=={}".format(suc_msg, expect_message)) except Exception as e: # 捕获异常信息+截图 self.LP_obj.error_dispose(e) assert False elif tag == 3: logger.debug("账号或密码错误用例") try: # 获取登陆失败toast消息 fail_msg = self.LP_obj.get_toast(get_mess) logger.debug("登录失败toast:{}".format(fail_msg)) if fail_msg: assert fail_msg == expect_message logger.success("断言成功:{}=={}".format( fail_msg, expect_message)) else: assert False self.LP_obj.login_back_page() except Exception as e: # 捕获异常信息+截图 self.LP_obj.error_dispose(e) sleep(3) assert False
def get_login_page(self): """返回 登录 类""" return Login_Page(self.driver)