def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage( self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.statistical_form_page3 = StatisticFormPage3( self.driver, self.base_url) self.connect_sql = ConnectSql() self.seasrch_sql = SearchSql(self.driver, self.base_url) self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击设置 self.statistical_form_page.click_control_after_click_statistical_form_page( ) sleep(3)
def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage( self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.connect_sql = ConnectSql() self.search_sql = SearchSql(self.driver, self.base_url) self.obd_form_page = ObdFormPage(self.driver, self.base_url) # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.driver.clear_cookies() self.log_in_base.log_in_jimitest() self.assert_text = AssertText() current_handle = self.driver.get_current_window_handle() self.statistical_form_page.click_control_after_click_statistical_form_page( ) sleep(3) self.base_page.change_windows_handle(current_handle)
class TestCase04LoginWithTester(unittest.TestCase): # 测试体验账号登录 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_user_login_exception(self): '''测试体验账号登录''' # 打开风控首页-登录页 self.base_page.open_page() # 点击“我要体验” self.login_page.taste() # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() self.assertEqual('小明', username, '登录成功后招呼栏的用户名错误') # 成功退出系统 sleep(2) self.user_center.logout()
class TestCase310SetUpIssuedCommandTaskManagementOperation(unittest.TestCase): # 测试 设置 - 指令管理 - 下发工作指令任务的操作 driver = None base_url = None base_page = None log_in_page = None command_management_page = None base_paging_function = None def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver(choose='firefox') self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.command_management_page = CommandManagementPage(self.driver, self.base_url) self.base_paging_function = BasePagingFunction(self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.driver.clear_cookies() self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击指令管理 self.command_management_page.click_control_after_click_command_management() sleep(3) def tearDown(self): self.driver.quit_browser() def test_case_set_up_issued_command_task_management_operation(self): # 断言url expect_url_after_click_command_management = self.base_url + '/custom/toTemplate' self.assertEqual(expect_url_after_click_command_management, self.command_management_page.actual_url_click_command_management()) # 断言左侧列表的title文本 expect_title_text_after_click_command_management = self.assert_text.command_manager_page_command_type() self.assertEqual(expect_title_text_after_click_command_management, self.command_management_page.actual_title_text_after_click_command_management()) # 点击下发任务指令管理 self.command_management_page.click_lift_list('issued_command_task_management') # 断言 expect_title_text_after_click_issued_command_task_management = \ self.assert_text.command_manager_page_issued_command_task() self.assertEqual(expect_title_text_after_click_issued_command_task_management, self.command_management_page.actual_text_after_click_issued_command_task()) # 点击查看设备 self.command_management_page.click_look_equipment_in_issued_command_task() # 断言 expect_text_after_click_look_equipment = self.assert_text.command_manager_page_issued_command_manager() self.assertEqual(expect_text_after_click_look_equipment, self.command_management_page.actual_text_after_click_look_equipment())
def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver(choose='firefox') self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.command_management_page = CommandManagementPage(self.driver, self.base_url) self.base_paging_function = BasePagingFunction(self.driver, self.base_url) self.command_management_page_read_csv = CommandManagementPageReadCsv() self.connect_sql = ConnectSql() self.log_in_base = LogInBase(self.driver, self.base_url) self.search_sql = SearchSql() self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.driver.clear_cookies() self.log_in_base.log_in() self.log_in_base.click_account_center_button() self.current_account = self.log_in_base.get_log_in_account() # 登录之后点击控制台,然后点击指令管理 self.command_management_page.click_control_after_click_command_management() sleep(3)
class TestCase164SportStatisticalAccFormOperation(unittest.TestCase): def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage( self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击设置 self.statistical_form_page.click_control_after_click_statistical_form_page( ) sleep(3) def tearDown(self): # 退出浏览器 self.driver.quit_browser() def test_case_sport_statistical_acc_form_operation(self): # 断言url expect_url_after_click_statistical_form = self.base_url + '/deviceReport/statisticalReport' self.assertEqual( expect_url_after_click_statistical_form, self.statistical_form_page.actual_url_after_statistical_form()) # 点击停留报表 self.statistical_form_page.click_acc_form_button() for n in range(5): self.statistical_form_page.click_customer_in_acc_form(n) # 点击搜索设备按钮 self.statistical_form_page.click_search_dev_button_in_acc_form() # 获取有多少组 number = self.statistical_form_page.get_group_number_in_acc_form() if number == 0: pass else: for m in range(number): # 收起默认组 self.statistical_form_page.click_defalut_group_in_acc_form( ) # 获取每个组设备的数量 dev_number = self.statistical_form_page.get_dev_number_in_acc_form( m) # 点开每一个分组 self.statistical_form_page.click_per_group_in_acc_form(m) dev_number_list = self.statistical_form_page.get_dev_number_list_in_acc_form( m) self.assertEqual(str(dev_number_list), dev_number)
class TestCase122UserSearchTransferUser(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.global_dev_search_page = GlobalDevSearchPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPages( self.driver, self.base_url) self.driver.set_window_max() self.global_account_search_page = GlobalAccountSearchPage( self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.global_search_page_read_csv = GlobleSearchPageReadCsv() self.search_sql = SearchSql() self.driver.wait(1) self.connect_sql = ConnectSql() self.assert_text = AssertText() self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_user_search_transfer_user(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击账号中心 self.log_in_base.click_account_center_button() self.global_dev_search_page.click_easy_search() # 关闭 self.global_dev_search_page.close_search() sleep(2) self.global_dev_search_page.click_easy_search() # 选择用户搜索 self.global_dev_search_page.click_user_search_buttons() # 获取列表中第二个用户的账号 self.global_dev_search_page.swith_to_search_frame() get_second_user_account = self.global_account_search_page.get_second_user_account_after_search_user( ) # 点击详情 self.global_account_search_page.click_user_detail_button() # 点击销售设备 self.global_account_search_page.click_transfer_user_button_in_user_detail_button( ) # 选择的用户是该用户(用户详情所属的用户)或其下级用户,提示“选择的用户不能作为上级用户” self.global_account_search_page.search_user_to_transfer_user_in_user_detail( get_second_user_account) get_text = self.global_account_search_page.get_text_after_click_transfer_user( ) self.assertEqual( self.assert_text.the_selected_user_cannot_be_the_superior(), get_text)
class TestCase152GuideManchineReportSearchUser(unittest.TestCase): ''' 导游播报统计搜索用户 author :zhangAo ''' def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage( self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.connect_sql = ConnectSql() self.search_sql = SearchSql(self.driver, self.base_url) # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.driver.clear_cookies() self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击设置 self.statistical_form_page.click_control_after_click_statistical_form_page( ) sleep(3) def tearDown(self): # 退出浏览器 self.driver.quit_browser() def test_case_guide_manchine_report_search_user(self): # 断言url expect_url_after_click_statistical_form = self.base_url + '/deviceReport/statisticalReport' self.assertEqual( expect_url_after_click_statistical_form, self.statistical_form_page.actual_url_after_statistical_form()) # 点击停留报表 self.statistical_form_page.click_guide_manchine_report_button() # 循环点击用户 self.statistical_form_page.switch_to_guide_manchine_report_frame() for n in range(5): self.statistical_form_page.click_search_user_button_in_guide_manchine_report( ) get_user_name = self.statistical_form_page.get_user_name_in_guide_manchine_report( n + 1) self.statistical_form_page.click_per_user_in_guide_manchine_report( n + 1) user_name = self.statistical_form_page.user_name_in_guide_manchine_report( ) self.assertEqual(get_user_name, user_name) self.driver.default_frame()
class TestCase02LoginException(unittest.TestCase): # 测试登录异常情况 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_user_login_exception(self): '''测试用户账户登录异常''' # 打开风控首页-登录页 self.base_page.open_page() # 第一种,密码和账号都为空 self.login_page.account_input('') self.login_page.password_input('') self.login_page.login_button_click() self.driver.wait() self.assertEqual('登录账号不能为空', self.login_page.get_exception_text()) # 第二种,密码和账号其中一个不为空 self.login_page.account_input('syntest') self.login_page.password_input('') self.login_page.login_button_click() self.driver.wait() self.assertEqual('登陆密码不能为空', self.login_page.get_exception_text()) self.login_page.account_input('') self.login_page.password_input('jimi123') self.login_page.login_button_click() self.driver.wait() self.assertEqual('登录账号不能为空', self.login_page.get_exception_text()) # 第三种,账号不存在 self.login_page.account_input('abdwerewf') self.login_page.password_input('123') self.login_page.login_button_click() self.driver.wait() self.assertEqual('账号不存在或者已经停用', self.login_page.get_exception_text()) # 第四种,密码错误 self.login_page.account_input('syntest') self.login_page.password_input('jimi') self.login_page.login_button_click() self.driver.wait() self.assertEqual('登录密码验证错误', self.login_page.get_exception_text())
class TestCase95DevManageBatchSaleByNoDev(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.driver.wait(1) self.driver.clear_cookies() self.assert_text = AssertText() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_batch_sale_by_no_dev(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 点击批量 self.dev_manage_page.click_batch_sale_button() self.dev_manage_page.click_close_batch_sale_button() self.dev_manage_page.click_batch_sale_button() # 验证界面 get_sale_title = self.dev_manage_page.get_sale_title_text_in_sale_dev() self.assertEqual(self.assert_text.batch_sale_text(), get_sale_title) # 搜索框输入多个设备IMEI,点击添加(设备之间用enter键、逗号隔开) self.dev_manage_page.add_imei_in_sale_dev_page( '121201234567889,867597011453591') get_dev_in_list_number = self.dev_manage_page.get_dev_in_list_number() self.assertEqual(2, get_dev_in_list_number) # 搜索框输入多个设备IMEI,点击添加(设备之间不用enter键、逗号隔开,而用空格隔开) self.dev_manage_page.add_imei_in_sale_dev_page( '121201234567889867597011453591') add_dev_state = self.dev_manage_page.add_dev_after_fail_state() self.assertEqual(self.assert_text.dev_page_fail_text(), add_dev_state) add_dev_reason = self.dev_manage_page.add_dev_after_fail_reason() self.assertEqual(self.assert_text.dev_page_inexistence_text(), add_dev_reason) self.dev_manage_page.click_close_fails() # 不选择销售对象进行销售 self.dev_manage_page.click_sale_button() # text = self.dev_manage_page.get_error_text_after_ensure() # self.assertEqual(self.assert_text.glob_search_please_add_account_text(), text) # 点击重置的按钮 self.dev_manage_page.click_clear_button_in_dev_sale() get_dev_in_list_number = self.dev_manage_page.get_dev_in_list_number() self.assertEqual(0, get_dev_in_list_number)
class TestCase127DevSearchIssuedCommand(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.global_dev_search_page = GlobalDevSearchPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPages( self.driver, self.base_url) self.driver.set_window_max() self.global_account_search_page = GlobalAccountSearchPage( self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.global_search_page_read_csv = GlobleSearchPageReadCsv() self.search_sql = SearchSql() self.driver.wait(1) self.connect_sql = ConnectSql() self.assert_text = AssertText() self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_search_issued_command(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() self.log_in_base.click_account_center_button() self.global_dev_search_page.click_easy_search() # 关闭 self.global_dev_search_page.close_search() sleep(2) self.global_dev_search_page.click_easy_search() self.global_dev_search_page.click_dev_searchs() # 选择设备搜索 sleep(5) self.global_dev_search_page.swith_to_search_frame() sleep(5) # 点击详情 self.global_dev_search_page.click_dev_detail_after_search_dev() get_imei = self.global_dev_search_page.get_imei_in_dev_detail() get_dev_name = self.global_dev_search_page.get_dev_types_in_dev_detail( ) # 点击设备指令 self.global_dev_search_page.clcik_dev_command_button() get_imei_in_command_page = self.global_dev_search_page.get_dev_imei_in_command_page( ) get_dev_name_in_command_page = self.global_dev_search_page.get_dev_name_in_command_page( ) self.assertEqual(get_imei, get_imei_in_command_page) self.assertEqual(get_dev_name, get_dev_name_in_command_page)
class TestCase04UserCenterModifyPassword(unittest.TestCase): # 测试个人中心修改密码 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_user_center_modify_password(self): # 通过csv测试修改密码功能 # 点击打开修改密码框 self.user_center.click_edit_password() csv_file = self.user_center_read_csv.read_csv( "modify_password_exception.csv") csv_data = csv.reader(csv_file) for row in csv_data: data = { "old_password": row[0], "new_password": row[1], "new_password2": row[2], "pwd_prompt": row[3], } text = self.user_center.get_modify_pwd_exception_prompt( data['old_password'], data['new_password'], data['new_password2']) self.assertIn(data["pwd_prompt"], text, "修改密码,错误提示语显示不一致") csv_file.close() # 关闭修改密码框 self.user_center.click_edit_password_close() # 退出登录 self.user_center.logout()
class TestCase86DevManageAllSetUpWorkCommand(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_all_set_up_work_command(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 点击本次查询全部设置工作模式 # self.dev_manage_page.click_all_set_up_work_command() # 点击关闭 # self.dev_manage_page.click_close_all_set_up_work_command() # 点击本次查询全部设置工作模式 # self.dev_manage_page.click_all_set_up_work_command() # 点击取消 # self.dev_manage_page.click_cancel_all_set_up_work_command() # 点击本次查询全部设置工作模式 self.dev_manage_page.click_all_set_up_work_command() try: # 检查数量 get_list_number = self.dev_manage_page.get_list_number() get_count_number = self.dev_manage_page.get_count_number() self.assertEqual(str(get_list_number), get_count_number) # 循环点击删除 for n in range(get_list_number): self.dev_manage_page.delete_dev() # 点击发送指令 self.dev_manage_page.click_issued_command_button() except: # 获取提示语 text = self.dev_manage_page.get_text_after_click_all_issued_command( ) self.assertEqual(self.assert_text.dev_type_is_different(), text)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
class TestCase102DevManageDevDetailDevMileage(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_dev_detail_dev_mileage(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() self.dev_manage_page.click_edit_button() self.dev_manage_page.click_close_edit_button() self.dev_manage_page.click_edit_button() # 点击客户信息 self.dev_manage_page.click_cust_info_button() # 获取总里程的最大长度 dev_total_mileage_max_len = self.dev_manage_page.get_dev_total_mileage_max_len( ) self.assertEqual('10', dev_total_mileage_max_len) # 输入非数字 self.dev_manage_page.input_dev_total_mileage_in_dev_detail('1we23') # 获取异常的文字 text = self.assert_text.dev_total_mileage_text1() self.dev_manage_page.click_ensure() web_text = self.dev_manage_page.get_text_after_input_dev_total_mileage( ) self.assertEqual(text, web_text) # 输入大于999999 self.dev_manage_page.input_dev_total_mileage_in_dev_detail( '1000000000') # 获取异常的文字 text = self.assert_text.dev_total_mileage_text2() self.dev_manage_page.click_ensure() web_text = self.dev_manage_page.get_text_after_input_dev_total_mileage( ) self.assertEqual(text, web_text)
class TestCase165StatisticalFormAlarmOverview(unittest.TestCase): def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.alarm_info_page = AlarmInfoPage(self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage(self.driver, self.base_url) self.connect_sql = ConnectSql() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击指令管理 self.statistical_form_page.click_control_after_click_statistical_form_page() time.sleep(3) def tearDown(self): self.driver.quit_browser() def test_case_statistical_form_alarm_overview(self): # 断言url expect_url = self.base_url + '/deviceReport/statisticalReport' self.assertEqual(expect_url, self.alarm_info_page.actual_url_click_alarm()) # 点击告警总览 self.alarm_info_page.click_alarm_overview_list() for n in range(5): self.statistical_form_page.click_customer_in_alarm_overview(n) # 点击搜索设备按钮 self.statistical_form_page.click_search_dev_button_alarm_form() # 获取有多少组 number = self.statistical_form_page.get_group_number_in_alarm_overview_form() if number == 0: pass else: for m in range(number): # 收起默认组 self.statistical_form_page.click_defalut_group_in_alarm_overview_form() # 获取每个组设备的数量 dev_number = self.statistical_form_page.get_dev_number_in_alarm_overview_form(m) # 点开每一个分组 self.statistical_form_page.click_per_group_in_alarm_overview_form(m) dev_number_list = self.statistical_form_page.get_dev_number_list_in_alarm_overview_form(m) self.assertEqual(str(dev_number_list), dev_number)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage(self.driver, self.base_url) self.statistical_form_page2 = StatisticalFormPage2(self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5)
class TestCase98DevManagePagingFunction(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_dev_manager_paging_function(self): '''测试设备管理-设备搜索-by imei''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in_jimitest() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 全部设备_分页默认显示每页20条 # get_paging_text = self.dev_manage_page.get_paging_text() # self.assertEqual(self.assert_text.per_20_page(), get_paging_text) # 获取总共有多少页 total_page_number = self.dev_manage_page.get_total_page_number_in_dev_manager() if total_page_number == 1: get_up_page_state = self.dev_manage_page.get_up_page_state() self.assertEqual('active', get_up_page_state) get_next_page_state = self.dev_manage_page.get_next_page_state() self.assertEqual('active', get_next_page_state) elif total_page_number == 0: text = self.dev_manage_page.get_search_no_dev_name_text() self.assertIn(self.assert_text.account_center_page_no_data_text(), text) else: for n in range(total_page_number): self.dev_manage_page.click_per_page(n + 1) if total_page_number != 0: self.dev_manage_page.click_per_number()
class TestCase97DevManageEditAccount(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.connect_sql = ConnectSql() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_edit_account(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 点击下级用户 self.dev_manage_page.click_next_user_in_dev_page() # 点击编辑用户 self.dev_manage_page.click_edit_account_button() self.dev_manage_page.click_close_edit_button() self.dev_manage_page.click_edit_account_button() self.dev_manage_page.switch_to_dev_edit_frame() # 搜索用户 self.dev_manage_page.search_account_in_edit_user() get_user_name_after_search = self.dev_manage_page.get_user_name_after_search_in_edit_user( ) up_user = self.dev_manage_page.get_up_user_edit_user_in_dev_page() self.assertIn(up_user, get_user_name_after_search) # 循环点击 for n in range(5): self.dev_manage_page.click_user_to_search_up_user_in_edit_user(n) up_user = self.dev_manage_page.get_up_user_edit_user_in_dev_page() get_user_name_after_search = self.dev_manage_page.get_user_name_after_search_in_edit_user( ) self.assertIn(up_user, get_user_name_after_search) self.driver.default_frame()
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPages(self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.connect_sql = ConnectSql() self.search_sql = SearchSql() self.assert_text = AssertText() self.driver.set_window_max() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.statistics_report = StatisticsReport(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.statistics_report_read_csv = StatisticsReportReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.global_dev_search_page = GlobalDevSearchPage(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPages(self.driver, self.base_url) self.driver.set_window_max() self.global_account_search_page = GlobalAccountSearchPage(self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.global_search_page_read_csv = GlobleSearchPageReadCsv() self.search_sql = SearchSql() self.driver.wait(1) self.connect_sql = ConnectSql() self.driver.clear_cookies() self.driver.wait(1)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.operation_log = OperationLog(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.operation_log_read_csv = OperationLogReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1)
class TestCase172StatusStatistical(unittest.TestCase): def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.statistical_form_page = StatisticalFormPage( self.driver, self.base_url) self.statistical_form_page_read_csv = StatisticalFormPageReadCsv() self.log_in_base = LogInBase(self.driver, self.base_url) self.connect_sql = ConnectSql() self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击设置 self.statistical_form_page.click_control_after_click_statistical_form_page( ) sleep(3) def tearDown(self): # 退出浏览器 self.driver.quit_browser() def test_case_172_status_statistical(self): # 断言url expect_url_after_click_statistical_form = self.base_url + '/deviceReport/statisticalReport' self.assertEqual( expect_url_after_click_statistical_form, self.statistical_form_page.actual_url_after_statistical_form()) # 点击离线统计 self.statistical_form_page.click_status_statistical_form_button() # 切换到状态统计的frame里面 self.statistical_form_page.switch_to_status_statistical_frame() # 点击选择所有状态 self.statistical_form_page.select_all_status_in_status_statistical_form( ) # 点击搜索 self.statistical_form_page.click_search_button_in_status_statistical_form( ) self.driver.default_frame()
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in()
class TestCase80DevManageSearchCustomer(unittest.TestCase): def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.dev_manage_page = DevManagePages(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBase(self.driver, self.base_url) self.dev_manage_page_read_csv = DevManagePageReadCsv() self.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_dev_manage_search_customer(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击进入设备管理 self.dev_manage_page.enter_dev_manage() # 循环点击5次 for n in range(5): self.driver.click_element( 'x,//*[@id="treeDemo_deviceManage_%s_span"]' % str(n + 2)) sleep(2) # 判断数量 get_account_dev_number = self.driver.get_text( 'x,//*[@id="treeDemo_deviceManage_%s_span"]' % str(n + 2)) number = get_account_dev_number.split('(')[1].split('/')[0] dev_number = self.dev_manage_page.get_dev_number() self.assertEqual(number, str(dev_number)) # 搜索无数据 self.dev_manage_page.search_customer('无数据') get_text = self.dev_manage_page.get_search_customer_no_data_text() self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text)
def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login()
def setUp(self): # 前置条件 # 实例化对象 self.driver = AutomateDriver(choose='firefox') self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.command_management_page = CommandManagementPage(self.driver, self.base_url) self.log_in_base = LogInBase(self.driver, self.base_url) self.assert_text = AssertText() # 打开页面,填写用户名、密码、点击登录 self.base_page.open_page() self.driver.set_window_max() self.driver.implicitly_wait(5) self.driver.clear_cookies() self.log_in_base.log_in_jimitest() # 登录之后点击控制台,然后点击指令管理 self.command_management_page.click_control_after_click_command_management() sleep(3)