def setup_module(): # 必须使用@classmethod 装饰器,所有test运行前运行一次 global operation, driver # 调用get_driver base_driver = BaseDriver() driver = base_driver.android_driver() # 实例化Operation operation = Operation(driver) print('[MyLog]--------OPERATION is inited NOW')
def setup_module(): # 必须使用@classmethod 装饰器,所有test运行前运行一次 global operation, driver, read # 调用get_driver read = ReadIni(conftest.userinfo_dir) base_driver = BaseDriver() driver = base_driver.android_driver() # 实例化Operation operation = Operation(driver) print('[MyLog]--------OPERATION is inited NOW')
class TestMyWallet(unittest.TestCase): ''' 验证我的钱包:收支明细页筛选,提现记录 ''' @classmethod def setUpClass(cls) -> None: pass def setUp(self) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:消息中心-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home() def test_income_out_screen(self): '''验证我的钱包-收支明细页筛选并验证''' log.info("验证我的钱包-收支明细页筛选并验证") # 进入我的钱包页 mw = MyWallet(self.driver) mw.enter_to_my() mw.enter_to_myWallet() # 进入收支明细页进行筛选操作 mw.screen_opera() # 判断筛选是否有结果 if mw.is_exist_element(mw.no_result): pass else: # 选择第一条筛选结果进入详情页 mw.enter_to_result_detail() # 断言详情页与筛选条件是否一致 r_1 = mw.new_is_exist_element(mw.order_detail_name) self.assertTrue(r_1) r_2 = mw.new_is_exist_element(mw.order_detail_store) self.assertTrue(r_2) # @unittest.skip("调试,跳过") def test_withdraw_recode(self): '''验证我的钱包-体现记录页展示是否正常''' log.info("验证我的钱包-体现记录页展示是否正常") # 进入我的钱包-体现记录页-第一条记录详情 mw = MyWallet(self.driver) mw.enter_to_my() mw.enter_to_myWallet() mw.enter_to_withdraw_record() # 断言展示是否正常 result = mw.is_exist_element(mw.record_detail_text) self.assertFalse(result) def tearDown(self) -> None: self.driver.quit() @classmethod def tearDownClass(cls) -> None: pass
def setUpClass(cls): # 必须使用@classmethod 装饰器,所有test运行前运行一次 global operation, driver, read # 调用get_driver read = ReadIni(conftest.userinfo_dir) server = Server() server.main('android') base_driver = BaseDriver() driver = base_driver.android_driver() # 实例化Operation operation = Operation(driver)
class TestMyMessage(unittest.TestCase): ''' 我的-消息中心 ''' @classmethod def setUpClass(cls) -> None: pass def setUp(self) -> None: '''初始化,登录进入首页页面''' log.info("-----开始执行用例:消息中心-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home() def test_01_my_message(self): '''验证消息中心-消息设置-设备告警开关是否正常(默认开启状态)''' log.info("验证消息中心-消息设置-设备告警开关是否正常(默认开启状态)") # ->我的->消息中心->消息设置(开关页) mm = MyMessage(self.driver) mm.enter_to_my() mm.enter_to_message() mm.enter_to_message_switch() # 点击关闭投放器液位预警开关,断言开关状态 mm.switch_opera() r_1 = mm.new_is_exist_element("OFF") self.assertTrue(r_1) # 再次点击开启投放器液位预警开关 mm.switch_opera() r_2 = mm.new_is_exist_element("OFF") self.assertFalse(r_2) def tearDown(self) -> None: self.driver.quit() @classmethod def tearDownClass(cls) -> None: pass
def setUpClass(cls) -> None: '''初始化,进入登录页面''' log.info("-----开始执行用例:登录-----") cls.driver = BaseDriver().android_driver() StartPage(cls.driver).swipe_start() return cls.driver
def common_driver(): driver = BaseDriver().base_driver() yield driver driver.close_app() driver.quit()
def common_toast_driver(): driver = BaseDriver().base_driver(automationName="UIAutomator2") yield driver driver.close_app() driver.quit()
def setUpClass(cls) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:充值通用小票、会员充值记录、小票回收-----") cls.driver = BaseDriver().android_driver() PageInit(cls.driver).init_to_home()
# result = self.is_exist_element(self.update_ele) # # print(result) # if result: # UpdatePopup(self.driver).cancel_opera() # else: # pass UpdatePopup(self.driver).cancel_opera() 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 iknow_click_opera(self): '''登录后判断是否存在【我知道了】按钮,存在则点击''' # result = self.is_exist_element(self.iknow_ele) # # print(result) # if result: # Iknow(self.driver).click_iknow_btn() # else: # pass Iknow(self.driver).click_iknow_btn() if __name__ == '__main__': driver = BaseDriver().android_driver() pi = PageInit(driver).init_to_home()
class TestHome(unittest.TestCase): ''' 首页,今日收益,当月收益,总收益 ''' @classmethod def setUpClass(cls) -> None: pass def setUp(self) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:首页-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home() # 判断今日收益展示是否为零 # today_revenue_text = HomePage(self.driver).today_revenue().text # global today_revenue_text # @unittest.skipIf(today_revenue_text=="0.00", "今日收益为零则跳过不执行该用例") @unittest.skip("调试跳过") 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) @unittest.skip("调试跳过") 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_total_revenue(self): '''验证首页-总收益导出功能''' log.info("验证首页-总收益导出功能") # 进入总收益页面,进入第一条收益记录,点击导出 hp = HomePage(self.driver) hp.enter_to_total_revenue() hp.total_to_month() 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 tearDown(self) -> None: self.driver.quit() @classmethod def tearDownClass(cls) -> None: pass
class TestReportForm(unittest.TestCase): ''' 报告页,水流导出,流水筛选,订单筛选 ''' @classmethod def setUpClass(cls) -> None: pass def setUp(self) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:报告页-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home() def tearDown(self) -> None: self.driver.quit() @classmethod def tearDownClass(cls) -> None: pass # @unittest.skip("调试跳过") 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) @unittest.skip("调试跳过,测试账号建好后需完善脚本") def test_report_screen(self): '''验证报表页流水筛选功能''' log.info("验证报表页流水筛选功能") # 进入报表页-流水,进行筛选操作 rfp = ReportFormPage(self.driver) rfp.enter_to_report() rfp.report_screen_opera() # 断言筛选结果是否正确 result = rfp.new_is_exist_element(rfp.store_text) self.assertTrue(result) def test_report_order(self): '''验证报表页订单筛选功能''' log.info("验证报表页订单筛选功能") # 进入报表页-订单,选择店铺 rfp = ReportFormPage(self.driver) rfp.enter_to_report() rfp.report_order_opera() # 断言结果是否正确 r_1 = rfp.new_is_exist_element(rfp.title_text) r_2 = rfp.new_is_exist_element(rfp.order_store_text) self.assertTrue(r_1) self.assertTrue(r_2)
class TestHelp(unittest.TestCase): ''' 验证联系客服、合作热线、帮助中心 ''' @classmethod def setUpClass(cls) -> None: pass def setUp(self) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:联系客服,合作热线,帮助中心-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home() # @unittest.skip("脚本调试,跳过") def test_01_contract_kefu(self): '''验证联系客服,咨询提现到账时间''' log.info("验证联系客服,咨询提现到账时间") # ->我的->联系客服 mh = MyHelp(self.driver) mh.enter_to_my() mh.enter_to_contract() # 点击问题验证 mh.contract_opera() result = mh.new_is_exist_element(mh.answer_text) self.assertTrue(result) # @unittest.skip("跳过") def test_02_hotline(self): '''验证合作热线页面展示''' log.info("验证合作热线页面展示") # ->我的->合作热线 mh = MyHelp(self.driver) mh.enter_to_my() mh.enter_to_hotline() # 断言页面是否有"服务热线:"字样 result = mh.new_is_exist_element("服务热线:") self.assertTrue(result) # @unittest.skip("脚本调试,跳过") def test_03_help_center(self): '''验证帮助中心,查看模块指示灯识别办法''' log.info("验证帮助中心,查看模块指示灯识别办法") # ->我的->帮助中心 mh = MyHelp(self.driver) mh.enter_to_my() mh.enter_to_help() # 点击问题验证 mh.help_opera() result = mh.new_is_exist_element("黄色灯:为信号指示灯") self.assertTrue(result) def tearDown(self) -> None: self.driver.quit() @classmethod def tearDownClass(cls) -> None: pass
def setUpClass(cls): cls.driver = webdriver.Chrome() cls.base_driver = BaseDriver(cls.driver) cls.demo_page = DemoPage(cls.driver)
def setUp(self) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:首页-----") self.driver = BaseDriver().android_driver() PageInit(self.driver).init_to_home()
def setUpClass(cls) -> None: '''初始化,登录进入首页''' log.info("-----开始执行用例:新增、编辑、删除VIP-----") cls.driver = BaseDriver().android_driver() PageInit(cls.driver).init_to_home()
def setUpClass(cls) -> None: '''初始化进入App首页''' log.info("---开始执行用例:提交商品品牌信息---") cls.driver = BaseDriver().android_driver() PageInit(cls.driver).init_to_home()