class TestCase70CustManageCustSearch(unittest.TestCase): def setUp(self): self.driver = AutomateDriverServer(choose='chrome') self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage( self.driver, self.base_url) self.cust_manage_cust_list_page = CustManageCustListPage( self.driver, self.base_url) self.cust_manage_my_dev_page = CustManageMyDevPage( self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def test_cust_manage_add_cust_search(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.cancel_add_account() self.cust_manage_basic_info_and_add_cust_page.add_acc() # 添加客户名称、账号,点击保存 self.cust_manage_basic_info_and_add_cust_page.add_account_name("虚拟账号") self.cust_manage_basic_info_and_add_cust_page.add_account( "xnzh_dzl022") self.cust_manage_basic_info_and_add_cust_page.acc_add_save() connect = self.connect_sql.connect_tuqiang_sql() cursor = connect.cursor() get_account_sql = "select account from user_info where account = 'xnzh_dzl022';" cursor.execute(get_account_sql) user = cursor.fetchall() print(user) print(len(user)) self.assertEqual(0, len(user), "添加普通账号时,可成功添加虚拟账户") def tearDown(self): self.driver.quit_browser()
class TestCase63CustManageCustSearch(unittest.TestCase): def setUp(self): self.driver = AutomateDriverServer(choose='chrome') self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(self.driver, self.base_url) self.cust_manage_cust_list_page = CustManageCustListPage(self.driver, self.base_url) self.cust_manage_my_dev_page = CustManageMyDevPage(self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.assert_text = AssertText() 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_cust_manage_add_cust_search(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.cancel_add_account() self.cust_manage_basic_info_and_add_cust_page.add_acc() # 循环点击五次 for n in range(4): self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.driver.click_element('x,//*[@id="treeDemo2_%s_span"]' % str(n + 2)) sleep(2) text = self.driver.get_text('x,//*[@id="treeDemo2_%s_span"]' % str(n + 2)) account_name = text.split('(')[0] value = self.driver.get_element('x,//*[@id="topUser"]').get_attribute('value') self.assertEqual(account_name, value) self.driver.default_frame() # 搜索 # 1 搜索无数据的内容 self.cust_manage_basic_info_and_add_cust_page.search_cust('无数据') get_text = self.cust_manage_basic_info_and_add_cust_page.get_search_no_data_text() self.assertIn(self.assert_text.account_center_page_no_data_text(), get_text)
class TestCase58CustManageAddAcc(unittest.TestCase): def setUp(self): self.driver = AutomateDriverServer() self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage( self.driver, self.base_url) self.cust_manage_cust_list_page = CustManageCustListPage( self.driver, self.base_url) self.cust_manage_my_dev_page = CustManageMyDevPage( self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.assert_text2 = AssertText2() self.search_sql = SearchSql() self.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() 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_cust_manage_add_acc(self): '''测试客户管理-新增用户''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.close_add_account() csv_file = self.cust_manage_page_read_csv.read_csv('acc_add.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_info = { "keyword": row[0], "acc_type": row[1], "acc_name": row[2], "account": row[3], "passwd": row[4], "phone": row[5], "email": row[6], "conn": row[7], "com": row[8], "search_user": row[9] } # 左侧客户列表搜索并选中唯一客户 self.cust_manage_cust_list_page.acc_exact_search( add_info["keyword"]) # 点击新增用户 self.cust_manage_basic_info_and_add_cust_page.add_acc() sleep(2) # 验证所选中的上级用户类型来显示可创建的下级类型 user_list = add_info["search_user"].split("/") for type in user_list: self.cust_manage_basic_info_and_add_cust_page.acc_search(type) type_list = self.cust_manage_basic_info_and_add_cust_page.get_acc_user_type_list( ) sql_data = self.search_sql.search_current_account_data(type) user_type = self.assert_text.log_in_page_account_type( sql_data[2]) print(user_type) if user_type == "销售": self.assertEqual(3, type_list["length"]) self.assertIn( self.assert_text.log_in_page_account_type(11), type_list["sale"]) self.assertIn(self.assert_text.log_in_page_account_type(8), type_list["distributor"]) self.assertIn(self.assert_text.log_in_page_account_type(9), type_list["user"]) elif user_type == "代理商": self.assertEqual(2, type_list["length"]) self.assertIn(self.assert_text.log_in_page_account_type(8), type_list["distributor"]) self.assertIn(self.assert_text.log_in_page_account_type(9), type_list["user"]) elif user_type == "用户": self.assertNotEqual(1, type_list["length"]) #self.assertIn(self.assert_text.log_in_page_account_type(9),type_list["user"]) sleep(1) #添加用户类型获取提示 self.cust_manage_basic_info_and_add_cust_page.acc_search( "yonghu222") sleep(2) self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() # status = self.cust_manage_lower_account_page.edit_info_save_status() self.driver.default_frame() # self.assertEqual(self.assert_text2.cust_manage_add_user_type_prompt(), status, "提示显示不一致") # 右侧搜索栏中搜索并选中作为上级用户 self.cust_manage_basic_info_and_add_cust_page.acc_search( add_info["keyword"]) # 选择客户类型 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.acc_type_choose( add_info["acc_type"]) # 编辑用户输入框信息 self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit( add_info["acc_name"], add_info["account"], add_info["passwd"], add_info["phone"], add_info["email"], add_info["conn"], add_info["com"]) # 修改用户登录权限 self.cust_manage_basic_info_and_add_cust_page.acc_login_limit_modi( ) self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.acc_add_save() # 获取保存操作状态 status = self.cust_manage_basic_info_and_add_cust_page.acc_info_save_status( ) # 验证是否操作成功 self.assertIn( self.assert_text.account_center_page_operation_done(), status, "操作失败") # 搜索新增客户 sleep(4) self.cust_manage_lower_account_page.input_search_info( add_info["account"]) # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 删除该新增客户 self.cust_manage_lower_account_page.delete_acc() # 确定删除 self.cust_manage_lower_account_page.delete_acc_ensure() # 获取删除操作状态 del_status = self.cust_manage_lower_account_page.get_del_status() # 验证是否操作成功 self.assertIn( self.assert_text.account_center_page_operation_done(), del_status, "操作失败") csv_file.close()
class TestCase405CustomerManagementAddUserCommandLimit(unittest.TestCase): # 测试客户管理-新增用户-验证指令权限 def setUp(self): self.driver = AutomateDriverServer() self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage(self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url) self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.assert_text = AssertText() self.assert_text2 = AssertText2() self.driver.set_window_max() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.close_window() self.driver.quit_browser() def test_add_user_command_limit_verify(self): '''测试客户管理-指令权限验证''' self.base_page.open_page() csv_file = self.cust_manage_page_read_csv.read_csv('add_user_command_limit_data.csv') csv_data = csv.reader(csv_file) for row in csv_data: info = { "keyword": row[0], "type": row[1], "name": row[2], "account": row[3], "passwd": row[4], "phone": row[5], "email": row[6], "conn": row[7], "com": row[8], "command": row[9], "working_mode": row[10] } # 登录 self.log_in_base.log_in() # 进入客户管理页面 current_handle = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() sleep(1) self.base_page.change_windows_handle(current_handle) self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.close_add_account() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit(info["name"], info["account"], info["passwd"], info["phone"], info["email"], info["conn"], info["com"]) # 是或否批量下发指令 和批量下发工作模式 command_status = self.cust_manage_basic_info_and_add_cust_page.setting_command_permissions(info["command"]) working_mode_status = self.cust_manage_basic_info_and_add_cust_page.setting_working_mode_permissions( info["working_mode"]) self.assertEqual(info["command"], str(command_status), "勾选状态与期望不一致") self.assertEqual(info["working_mode"], str(working_mode_status), "勾选状态与期望不一致") self.driver.default_frame() sleep(2) self.cust_manage_basic_info_and_add_cust_page.acc_add_save() sleep(1) # 退出登录 self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in_with_csv(info["account"], info["passwd"]) hello_usr = self.account_center_page_navi_bar.usr_info_account() self.assertIn(info["account"], hello_usr, "登录成功后招呼栏账户名显示错误") sleep(1) # 进入设备管理/指令管理页面,获取功能按钮 current_handle_02 = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.click_dev_management_button() self.base_page.change_windows_handle(current_handle_02) facility_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button() sleep(3) # command_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_command_page_module() # 获取中文,依次是:选中发送指令、本次查询全部发送指令、选中设置工作模式、本次查询全部设置工作模式 # 工作模式模板管理, 下发工作模式任务管理, 下发工作模式管理, 下发指令任务管理, 下发指令管理 send_command = self.assert_text2.dev_manage_select_send_command() all_send_command = self.assert_text2.dev_manage_select_all_send_command() working_mode = self.assert_text2.dev_manage_setting_working_mode() all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode() template_manage = self.assert_text.command_manager_page_work_type_template_management() working_mode_task_manage = self.assert_text2.comm_manage_send_working_mode_task_manage() working_mode_manage = self.assert_text2.comm_manage_send_working_mode_manage() task_manage = self.assert_text2.comm_manage_command_task_manage() comm_manager = self.assert_text.command_manager_page_issued_command_manager() command_list = [] working_mode_list = [] # 循环设备管理页面的数据 for b in facility_manage_data: # 选中发送指令 和 本次查询全部发送指令 if send_command in b or all_send_command in b: command_list.append(b) # 选中设置工作模式 和 本次查询全部设置工作模式 elif working_mode in b or all_working_mode in b: working_mode_list.append(b) # 循环指令管理页面的数据 '''for c in command_manage_data: # 下发指令任务管理 和 下发指令管理 if task_manage in c or comm_manager in c: command_list.append(c) # 工作模式模板管理, 下发工作模式任务管理, 下发工作模式管理 elif template_manage in c or working_mode_task_manage in c or working_mode_manage in c: working_mode_list.append(c)''' print("指令", command_list) print("工作模式", working_mode_list) # 验证设备、指令管理页面功能按钮 if command_status == True and working_mode_status == True: # 指令(设备页+指令管理页) self.assertEqual(send_command, command_list[0]) self.assertEqual(all_send_command, command_list[1]) self.assertEqual(task_manage, command_list[2]) self.assertEqual(comm_manager, command_list[3]) # 工作模式(设备页+指令管理页) self.assertEqual(working_mode, working_mode_list[0]) self.assertEqual(all_working_mode, working_mode_list[1]) self.assertEqual(template_manage, working_mode_list[2]) self.assertEqual(working_mode_task_manage, working_mode_list[3]) self.assertEqual(working_mode_manage, working_mode_list[4]) elif command_status == False and working_mode_status == False: # self.assertEqual(comm_manager, command_list[0]) self.assertEqual(0, len(working_mode_list)) elif command_status == True and working_mode_status == False: self.assertEqual(send_command, command_list[0]) self.assertEqual(all_send_command, command_list[1]) self.assertEqual(task_manage, command_list[2]) self.assertEqual(comm_manager, command_list[3]) self.assertEqual(0, len(working_mode_list)) elif command_status == False and working_mode_status == True: self.assertEqual(comm_manager, command_list[0]) self.assertEqual(working_mode, working_mode_list[0]) self.assertEqual(all_working_mode, working_mode_list[1]) self.assertEqual(template_manage, working_mode_list[2]) self.assertEqual(working_mode_task_manage, working_mode_list[3]) self.assertEqual(working_mode_manage, working_mode_list[4]) sleep(1) self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in() current_handle_01 = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.base_page.change_windows_handle(current_handle_01) # 搜索新增客户 self.cust_manage_lower_account_page.input_search_info(info["account"]) # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 删除该新增客户 self.cust_manage_lower_account_page.delete_acc() self.cust_manage_lower_account_page.delete_acc_ensure() # 获取删除操作状态 del_status = self.cust_manage_lower_account_page.get_del_status() self.assertIn(self.assert_text.account_center_page_operation_done(), del_status, "操作失败") # 退出登录 sleep(1) self.account_center_page_navi_bar.usr_logout() csv_file.close()
class TestCase1101CustManageCustExpection(unittest.TestCase): def setUp(self): self.driver = AutomateDriverServer(choose='chrome') self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage( self.driver, self.base_url) self.cust_manage_cust_list_page = CustManageCustListPage( self.driver, self.base_url) self.cust_manage_my_dev_page = CustManageMyDevPage( self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.assert_text = AssertText() 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_cust_manage_add_cust_exception(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.cancel_add_account() self.cust_manage_basic_info_and_add_cust_page.add_acc() # 验证上级客户input的属性是否为readonly readonly_value = self.cust_manage_basic_info_and_add_cust_page.get_up_account_value( ) self.assertEqual('true', readonly_value) # 验证新增客户的名称 # 1 为空 self.cust_manage_basic_info_and_add_cust_page.add_account_name('') self.cust_manage_basic_info_and_add_cust_page.click_ensure() text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text( ) self.assertEqual(self.assert_text.cust_page_user_name_not_null(), text) # 2 长度小于三位 self.cust_manage_basic_info_and_add_cust_page.add_account_name('1') self.cust_manage_basic_info_and_add_cust_page.click_ensure() text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_name_exception_text( ) self.assertEqual(self.assert_text.cust_page_user_name_more_than_3(), text) # 3 验证最大长度 max_len = self.cust_manage_basic_info_and_add_cust_page.get_account_name_max_len( ) self.assertEqual('50', max_len) # 验证新增客户账号 # 1 为空 self.cust_manage_basic_info_and_add_cust_page.add_account('') self.cust_manage_basic_info_and_add_cust_page.click_ensure() text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_exception_text( ) self.assertEqual(self.assert_text.cust_page_user_account_not_null(), text) # 2 长度小于3位 self.cust_manage_basic_info_and_add_cust_page.add_account('1') self.cust_manage_basic_info_and_add_cust_page.click_ensure() text = self.cust_manage_basic_info_and_add_cust_page.get_add_account_exception_text( ) self.assertEqual(self.assert_text.cust_page_user_account_len(), text) # 3 验证最大长度 account_max_len = self.cust_manage_basic_info_and_add_cust_page.get_account_max_len( ) self.assertEqual('30', account_max_len) # 验证密码 # 1 为空 self.cust_manage_basic_info_and_add_cust_page.add_password_first('') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password( ) self.assertEqual(self.assert_text.cust_page_user_password_not_null(), get_password_first_text) # 2 小于6位 self.cust_manage_basic_info_and_add_cust_page.add_password_first('12e') self.cust_manage_basic_info_and_add_cust_page.add_password_second( '12e') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password( ) self.assertEqual(self.assert_text.cust_page_user_password_len(), get_password_first_text) # 3 全字母 self.cust_manage_basic_info_and_add_cust_page.add_password_first( 'abcdefg') self.cust_manage_basic_info_and_add_cust_page.add_password_second( 'abcdefg') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password( ) self.assertEqual(self.assert_text.cust_page_user_password_formate(), get_password_first_text) # 4 全数字 self.cust_manage_basic_info_and_add_cust_page.add_password_first( '123456') self.cust_manage_basic_info_and_add_cust_page.add_password_second( '123456') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_first_password( ) self.assertEqual(self.assert_text.cust_page_user_password_formate(), get_password_first_text) # 5 只输入确认密码 self.cust_manage_basic_info_and_add_cust_page.add_password_first('') self.cust_manage_basic_info_and_add_cust_page.add_password_second( 'a123456') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_second_password( ) self.assertEqual(self.assert_text.cust_page_password_unlike(), get_password_first_text) # 6两次密码不一致 self.cust_manage_basic_info_and_add_cust_page.add_password_first( '123456ee') self.cust_manage_basic_info_and_add_cust_page.add_password_second( '123456ff') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_password_first_text = self.cust_manage_basic_info_and_add_cust_page.get_text_second_password( ) self.assertEqual(self.assert_text.cust_page_password_unlike(), get_password_first_text) # 验证电话、邮箱、联系人、公司名的最大长度 phone_max_len = self.cust_manage_basic_info_and_add_cust_page.get_phone_max_len( ) self.assertEqual('20', phone_max_len) email_max_len = self.cust_manage_basic_info_and_add_cust_page.get_email_max_len( ) self.assertEqual('50', email_max_len) # 验证邮箱格式 self.cust_manage_basic_info_and_add_cust_page.add_email_format( '123123') self.cust_manage_basic_info_and_add_cust_page.click_ensure() get_text_email = self.cust_manage_basic_info_and_add_cust_page.get_text_email_text( ) self.assertEqual(self.assert_text.cust_page_user_email_formate_error(), get_text_email) connect_max_len = self.cust_manage_basic_info_and_add_cust_page.get_connect_max_len( ) self.assertEqual('50', connect_max_len) comp_max_len = self.cust_manage_basic_info_and_add_cust_page.get_comp_max_len( ) self.assertEqual('50', comp_max_len)
class TestCase404CustomerManagementAddAUserWebLimit(unittest.TestCase): # 测试客户管理-新增用户-验证web登陆权限 def setUp(self): self.driver = AutomateDriverServer() self.base_url = self.driver.base_url self.base_page = BasePageServer(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.cust_manage_basic_info_and_add_cust_page = CustManageBasicInfoAndAddCustPage( self.driver, self.base_url) self.cust_manage_lower_account_page = CustManageLowerAccountPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.assert_text = AssertText() self.assert_text2 = AssertText2() self.driver.set_window_max() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.close_window() self.driver.quit_browser() def test_add_user_web_limit_verify(self): '''测试客户管理-web权限验证''' self.base_page.open_page() csv_file = self.cust_manage_page_read_csv.read_csv( 'add_user_web_limit_data.csv') csv_data = csv.reader(csv_file) for row in csv_data: info = { "keyword": row[0], "type": row[1], "name": row[2], "account": row[3], "passwd": row[4], "phone": row[5], "email": row[6], "conn": row[7], "com": row[8], "web_setting": row[9], "app_setting": row[10] } # 登录 self.log_in_base.log_in() # 进入客户管理页面 current_handle = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.base_page.change_windows_handle(current_handle) self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.close_add_account() self.cust_manage_basic_info_and_add_cust_page.add_acc() self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.add_acc_input_info_edit( info["name"], info["account"], info["passwd"], info["phone"], info["email"], info["conn"], info["com"]) # 是或否勾选web和app登录权限 web_status = self.cust_manage_basic_info_and_add_cust_page.setting_web_login_permissions( info["web_setting"]) app_status = self.cust_manage_basic_info_and_add_cust_page.setting_app_login_permissions( info["app_setting"]) self.assertEqual(info["web_setting"], str(web_status), "勾选状态与期望不一致") self.assertEqual(info["app_setting"], str(app_status), "勾选状态与期望不一致") self.driver.default_frame() sleep(2) self.cust_manage_basic_info_and_add_cust_page.acc_add_save() sleep(1) self.account_center_page_navi_bar.usr_logout() # 没有web登录权限验证 if web_status == False: self.log_in_base.log_in_with_csv(info["account"], info["passwd"]) self.assertEqual(self.assert_text2.login_no_permissions(), self.login_page.get_exception_text(), "没有获取到没有权限登录的提示") # 有web登录权限验证 elif web_status == True: self.log_in_base.log_in_with_csv(info["account"], info["passwd"]) sleep(2) hello_usr = self.account_center_page_navi_bar.usr_info_account( ) self.assertIn(info["account"], hello_usr, "登录成功后招呼栏账户名显示错误") sleep(1) self.log_in_base.click_account_center_button() self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in() current_handle_01 = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() self.base_page.change_windows_handle(current_handle_01) # 搜索新增客户 self.cust_manage_lower_account_page.input_search_info( info["account"]) # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 删除该新增客户 self.cust_manage_lower_account_page.delete_acc() self.cust_manage_lower_account_page.delete_acc_ensure() # 获取删除操作状态 del_status = self.cust_manage_lower_account_page.get_del_status() self.assertIn( self.assert_text.account_center_page_operation_done(), del_status, "操作失败") # 退出登录 sleep(1) self.account_center_page_navi_bar.usr_logout() csv_file.close()