class TestCase114UserSearchUserRelation(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_user_relation(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_user_search_buttons() user_name = self.global_dev_search_page.get_user_name_in_user_search() user_type = self.global_dev_search_page.get_user_type_in_user_search() user_account = self.global_dev_search_page.get_user_account_in_user_search( ) self.global_dev_search_page.click_detail_in_user_search() # 验证用户信息 self.global_dev_search_page.swith_to_search_frame() user_name_in_user_detail = self.global_account_search_page.get_user_name_in_user_detail( ) self.assertEqual(user_name, user_name_in_user_detail) user_type_in_user_detail = self.global_account_search_page.get_user_type_in_user_detail( ) self.assertEqual(user_type, " " + user_type_in_user_detail) user_account_in_user_detail = self.global_account_search_page.get_user_account_in_user_detail( ) self.assertEqual(user_account, user_account_in_user_detail) dev_number_in_user_detail = self.global_account_search_page.get_dev_number_in_user_detail( ) # 分别点击控制台、重置密码、查看 # 点击查看 current_handle = self.driver.get_current_window_handle() self.global_account_search_page.click_look_button_in_user_detail() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != current_handle: self.driver.switch_to_window(handle) expect_url = self.driver.base_url + '/device/toDeviceManage' self.assertEqual(self.driver.get_current_url(), expect_url) get_total_dev_number = self.global_account_search_page.get_dev_total_number_in_dev_manage_page( ) self.assertEqual(dev_number_in_user_detail, str(get_total_dev_number)) self.driver.close_current_page() self.driver.switch_to_window(current_handle) # 点控制台 current_handle = self.driver.get_current_window_handle() self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_console_button_in_user_detail() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != current_handle: self.driver.switch_to_window(handle) expect_url = self.driver.base_url + '/console' self.assertEqual(self.driver.get_current_url(), expect_url) self.driver.close_current_page() self.driver.switch_to_window(current_handle) # 点击重置密码 self.global_dev_search_page.swith_to_search_frame() self.global_account_search_page.click_reset_password_button_in_user_detail( ) # 点击关闭 self.global_account_search_page.click_close_button() # 点击重置密码 self.global_account_search_page.click_reset_password_button_in_user_detail( ) # 点击取消 self.global_account_search_page.click_cancel_button() # 点击重置密码 self.global_account_search_page.click_reset_password_button_in_user_detail( ) # 点击确定 self.global_account_search_page.click_ensuer_button() sleep(4) self.driver.default_frame() self.global_account_search_page.click_close_button()
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()