class TestCase118UserSearchModifyBatchIssuedWorkTypeAuthority(unittest.TestCase): 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.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_modify_batch_issued_work_type_authority(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_search() self.global_dev_search_page.click_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_user_info_in_user_detail() # 获取用户信息页面登录账号名字 current_account = self.global_account_search_page.get_current_account_in_user_detail() self.assertEqual(get_second_user_account, current_account) # 获取各个权限input的select属性 web_login_authority = self.global_account_search_page.get_web_login_authority_input_select_in_user_detail() app_login_authority = self.global_account_search_page.get_app_login_authorith_input_select_in_user_detail() batch_issued_command_authority = self.global_account_search_page.batch_issued_command_authority_in_user_detail() batch_issued_work_type_authority = self.global_account_search_page.batch_issued_work_type_authority_in_user_detail() web_modify_authority = self.global_account_search_page.get_web_modify_authority_in_user_detail() app_modify_authority = self.global_account_search_page.get_app_modify_authority_in_user_detail() if batch_issued_work_type_authority == True: ## 点击批量下发工作模式 self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail() # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail() # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() total_number = self.global_account_search_page.get_total_button_in_dev_manage() operation_all = [] for n in range(total_number): get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n) operation_all.append(get_per_operation) select_issued_work_type = self.assert_text.select_issued_work_type_text() self.assertNotIn(select_issued_work_type, operation_all) all_issued_work_type = self.assert_text.all_issued_work_type_text() self.assertNotIn(all_issued_work_type, operation_all) # 退出登录的账号 self.global_account_search_page.click_account_manage_page() self.global_account_search_page.logout() # 登录web_autotest 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_search() self.global_dev_search_page.click_search_buttons() # 点击详情 self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_user_detail_button() # 点击用户信息 self.global_account_search_page.click_user_info_in_user_detail() ## 点击批量下发工作模式 self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail() # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail() # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() total_number = self.global_account_search_page.get_total_button_in_dev_manage() operation_all = [] for n in range(total_number): get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n) operation_all.append(get_per_operation) select_issued_work_type = self.assert_text.select_issued_work_type_text() self.assertIn(select_issued_work_type, operation_all) all_issued_work_type = self.assert_text.all_issued_work_type_text() self.assertIn(all_issued_work_type, operation_all) if batch_issued_work_type_authority == False: ## 点击批量下发工作模式 self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail() # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail() # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() total_number = self.global_account_search_page.get_total_button_in_dev_manage() operation_all = [] for n in range(total_number): get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n) operation_all.append(get_per_operation) select_issued_work_type = self.assert_text.select_issued_work_type_text() self.assertIn(select_issued_work_type, operation_all) all_issued_work_type = self.assert_text.all_issued_work_type_text() self.assertIn(all_issued_work_type, operation_all) # 退出登录的账号 self.global_account_search_page.click_account_manage_page() self.global_account_search_page.logout() # 登录web_autotest 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_search() self.global_dev_search_page.click_search_buttons() # 点击详情 self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_user_detail_button() # 点击用户信息 self.global_account_search_page.click_user_info_in_user_detail() ## 点击批量下发工作模式 self.global_account_search_page.click_modify_batch_issued_work_type_authority_in_user_detail() # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail() # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user(get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() total_number = self.global_account_search_page.get_total_button_in_dev_manage() operation_all = [] for n in range(total_number): get_per_operation = self.global_account_search_page.get_per_operation_in_dev_manage(n) operation_all.append(get_per_operation) select_issued_work_type = self.assert_text.select_issued_work_type_text() self.assertNotIn(select_issued_work_type, operation_all) all_issued_work_type = self.assert_text.all_issued_work_type_text() self.assertNotIn(all_issued_work_type, operation_all)
class TestCase121UserSearchSaleDev(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_sale_dev(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击设备管理 获取imei号 self.global_account_search_page.click_dev_manage_page() first_imei = self.global_account_search_page.get_frist_imei_in_dev_manage_page( ) second_imei = self.global_account_search_page.get_second_imei_in_dev_manage_page( ) third_imei = self.global_account_search_page.get_third_imei_in_dev_manage_page( ) fourth_imei = self.global_account_search_page.get_fourth_imei_in_dev_manage_page( ) fifth_imei = self.global_account_search_page.get_fifth_imei_in_dev_manage_page( ) # 点击账号中心 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.clcik_sale_dev_button_in_user_detail_button( ) # 设备列表为空,点击销售 self.global_account_search_page.click_sale_button_in_user_search() text = self.global_account_search_page.get_text_after_click_sale_button_with_no_dev( ) self.assertEqual(self.assert_text.glob_search_please_add_dev_text(), text) # 设备列表不为空,点击重置 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( fifth_imei) self.global_account_search_page.select_user_expire_time_in_user_detail( ) # 点击重置 self.global_account_search_page.click_reset_button_in_user_detail() total_dev_number = self.global_account_search_page.get_total_dev_number_after_add_in_sale_dev( ) self.assertEqual(0, total_dev_number) count_dev_number = self.global_account_search_page.count_dev_number_in_sale_dev_page( ) self.assertEqual('0', count_dev_number) user_expire_text = self.global_account_search_page.get_user_expire_text_in_sale_dev( ) self.assertEqual(self.assert_text.please_select_text(), user_expire_text)
class TestCase120UserSearchSaleDev(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_sale_dev(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() # 点击设备管理 获取imei号 self.global_account_search_page.click_dev_manage_page() first_imei = self.global_account_search_page.get_frist_imei_in_dev_manage_page( ) second_imei = self.global_account_search_page.get_second_imei_in_dev_manage_page( ) third_imei = self.global_account_search_page.get_third_imei_in_dev_manage_page( ) fourth_imei = self.global_account_search_page.get_fourth_imei_in_dev_manage_page( ) fifth_imei = self.global_account_search_page.get_fifth_imei_in_dev_manage_page( ) # 点击账号中心 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_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.clcik_sale_dev_button_in_user_detail_button( ) # 输入不存在的imei进行添加 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( first_imei + '123456') # 获取失败的状态 failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_fail_text(), failure_statues) failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_inexistence_text(), failure_reason) # 关闭失败的弹窗 self.global_account_search_page.close_failure_windows() # 输入与 IMEI 列表中相同、存在的IMEI,点击添加 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( first_imei) self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( first_imei) # 获取失败的状态 failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_fail_text(), failure_statues) failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_repetition_text(), failure_reason) # 关闭失败的弹窗 self.global_account_search_page.close_failure_windows() # 输入与 IMEI 列表中不相同、存在的IMEI,点击添加 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( second_imei) get_imei_after_add = self.global_account_search_page.get_imei_after_add_in_user_detail( ) self.assertEqual(second_imei, get_imei_after_add) # 输入多个设备的IMEI,其中部分不存在,其中部分与列表中IMEI重复 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( second_imei + ',' + first_imei + '123456' + ',' + third_imei) # 获取失败的状态 failure_statues = self.global_account_search_page.get_failure_statue_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_fail_text(), failure_statues) failure_reason = self.global_account_search_page.get_failure_reason_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_repetition_text(), failure_reason) second_failure_statues = self.global_account_search_page.get_second_failure_statue_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_fail_text(), second_failure_statues) second_failure_reason = self.global_account_search_page.get_second_failure_reason_text_in_user_detail( ) self.assertEqual(self.assert_text.dev_page_inexistence_text(), second_failure_reason) # 关闭失败的弹窗 self.global_account_search_page.close_failure_windows() # 输入多个设备的IMEI,与列表中IMEI不重复,点击添加 self.global_account_search_page.add_imei_to_sale_dev_in_user_detail( fourth_imei + ',' + fifth_imei) total_dev_number = self.global_account_search_page.get_total_dev_number_after_add_in_sale_dev( ) self.assertEqual(5, total_dev_number)
class TestCase116UserSearchModifyWebDevEditAuthority(unittest.TestCase): 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.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_modify_web_dev_edit_authority(self): # 打开途强在线首页-登录页 self.base_page.open_page() self.log_in_base.log_in() self.log_in_base.click_account_center_button() sleep(4) 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_search() self.global_dev_search_page.click_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_user_info_in_user_detail() # 获取用户信息页面登录账号名字 current_account = self.global_account_search_page.get_current_account_in_user_detail( ) self.assertEqual(get_second_user_account, current_account) # 获取各个权限input的select属性 web_login_authority = self.global_account_search_page.get_web_login_authority_input_select_in_user_detail( ) app_login_authority = self.global_account_search_page.get_app_login_authorith_input_select_in_user_detail( ) batch_issued_command_authority = self.global_account_search_page.batch_issued_command_authority_in_user_detail( ) batch_issued_work_type_authority = self.global_account_search_page.batch_issued_work_type_authority_in_user_detail( ) web_modify_authority = self.global_account_search_page.get_web_modify_authority_in_user_detail( ) app_modify_authority = self.global_account_search_page.get_app_modify_authority_in_user_detail( ) if web_modify_authority == True: # 点击web修改设备的权限 self.global_account_search_page.click_web_modify_dev_authority_in_user_detail( ) # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail( ) # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user( get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() sleep(2) # 点击编辑设备 self.global_account_search_page.click_edit_dev_in_dev_manage_page() # 点击保存 self.global_account_search_page.click_ensuer_button() # 获取提示语 text = self.global_account_search_page.get_no_authority_text() # self.assertIn(self.assert_text.no_authority_text(), text) # 关闭设备编辑页面 self.global_account_search_page.close_dev_edit() # 退出登录的账号 self.global_account_search_page.click_account_manage_page() self.global_account_search_page.logout() # 登录web_autotest 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_search() self.global_dev_search_page.click_search_buttons() # 点击详情 self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_user_detail_button() # 点击用户信息 self.global_account_search_page.click_user_info_in_user_detail() self.global_account_search_page.click_web_modify_dev_authority_in_user_detail( ) # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail( ) # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user( get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() # 点击编辑设备 self.global_account_search_page.click_edit_dev_in_dev_manage_page() # 点击保存 self.global_account_search_page.click_ensuer_button() # 获取提示语 text = self.global_account_search_page.get_authority_text() self.assertIn( self.assert_text.account_center_page_operation_done(), text) elif web_modify_authority == False: # 点击web修改设备的权限 self.global_account_search_page.click_web_modify_dev_authority_in_user_detail( ) # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail( ) # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user( get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() # 点击编辑设备 self.global_account_search_page.click_edit_dev_in_dev_manage_page() # 点击保存 self.global_account_search_page.click_ensuer_button() # 获取提示语 text = self.global_account_search_page.get_authority_text() self.assertIn( self.assert_text.account_center_page_operation_done(), text) # 关闭设备编辑页面 self.global_account_search_page.close_dev_edit() # 退出登录的账号 self.global_account_search_page.click_account_manage_page() sleep(2) self.global_account_search_page.logout() # 登录web_autotest 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_search() self.global_dev_search_page.click_search_buttons() # 点击详情 self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_user_detail_button() # 点击用户信息 self.global_account_search_page.click_user_info_in_user_detail() self.global_account_search_page.click_web_modify_dev_authority_in_user_detail( ) # 点击保存 self.global_account_search_page.click_ensuer_button_in_user_detail( ) # 点击关闭 self.driver.default_frame() self.global_account_search_page.click_close_button() # 退出登录 self.global_account_search_page.logout() # 登录刚刚修改过的账号 self.global_account_search_page.log_in_user( get_second_user_account, 'jimi123') # 进入设备管理页面 self.global_account_search_page.click_dev_manage_page() # 点击编辑设备 self.global_account_search_page.click_edit_dev_in_dev_manage_page() # 点击保存 self.global_account_search_page.click_ensuer_button() # 获取提示语 text = self.global_account_search_page.get_no_authority_text()