class TestCase57CustManageCheckAccount(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.connect_sql = ConnectSql() self.cust_manage_page_read_csv = CustManagePageReadCsv() 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_check_account(self): '''测试客户管理-新增用户''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() csv_file = self.cust_manage_page_read_csv.read_csv( 'check_account_data.csv') csv_data = csv.reader(csv_file) for row in csv_data: data = {'account': row[0]} self.cust_manage_basic_info_and_add_cust_page.add_data_to_search_account( data) connect = self.connect_sql.connect_tuqiang_sql() cursor = connect.cursor() get_account_sql = "SELECT o.type,o.phone,o.nickName from user_info o WHERE o.account = '" + data[ 'account'] + "';" cursor.execute(get_account_sql) get_account_user_info = cursor.fetchall() current_user_info = [] for range1 in get_account_user_info: for range2 in range1: current_user_info.append(range2) print(current_user_info) type = self.assert_text.log_in_page_account_type( current_user_info[0]) # 断言客户类型 account_type = self.cust_manage_basic_info_and_add_cust_page.get_account_type( ) self.assertEqual(type, account_type) # 断言账号 account = self.cust_manage_basic_info_and_add_cust_page.get_account( ) self.assertEqual(data['account'], account) # 断言电话 account_phone = self.cust_manage_basic_info_and_add_cust_page.get_account_phone( ) if current_user_info[1] == None: self.assertEqual("", account_phone, "手机号不一致") else: self.assertEqual(current_user_info[1], account_phone) # 断言昵称 account_name = self.cust_manage_basic_info_and_add_cust_page.get_account_name( ) if current_user_info[2] == None: self.assertEqual("", account_name, "昵称不一致") else: self.assertEqual(current_user_info[2], account_name) # 点击监控用户 current_window = self.driver.get_current_window_handle() self.cust_manage_basic_info_and_add_cust_page.click_monitoring_account_button( ) all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != current_window: self.driver.switch_to_window(handle) expect_url = self.base_url + '/index' self.assertEqual(expect_url, self.driver.get_current_url()) self.driver.close_current_page() sleep(2) self.driver.switch_to_window(current_window) # 点击编辑用户 style_value = self.cust_manage_basic_info_and_add_cust_page.edit_button_style_value( ) if style_value == 'display: inline;': self.cust_manage_basic_info_and_add_cust_page.click_edit_account_button( ) # 点击关闭 self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button( ) # 点击编辑 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_button( ) # 查询用户上一级信息 connect_02 = self.connect_sql.connect_tuqiang_sql() cursor_02 = connect_02.cursor() get_id_sql = "SELECT o.parentId from user_info o WHERE o.account = '" + account + "';" cursor_02.execute(get_id_sql) get_id_info = cursor_02.fetchall() current_user = [] for range1 in get_id_info: for range2 in range1: current_user.append(range2) print(current_user) get_up_account_info_sql = "SELECT o.nickName FROM user_info o WHERE o.userId = '" + current_user[ 0] + "';" cursor_02.execute(get_up_account_info_sql) get_up_user_info = cursor_02.fetchall() up_user_info = [] for range1 in get_up_user_info: for range2 in range1: up_user_info.append(range2) account_name = up_user_info[0] get_web_account_name = self.cust_manage_basic_info_and_add_cust_page.get_account_name_after_click_edit( ) self.assertEqual(account_name, get_web_account_name, '用户上级显示错误!') self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button( ) # 断言账号类型 cursor_02.close() connect_02.close() cursor.close() connect.close() csv_file.close()
class TestCase730816CustManageEditUserCommandLimit(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.quit_browser() def test_edit_account_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 = { "passwd": row[4], "command": row[9], "working_mode": row[10], "wdit_account": row[11] } # 登录 self.log_in_base.log_in() # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() # 搜索账号 self.cust_manage_lower_account_page.input_search_info(info["wdit_account"]) # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑用户 self.cust_manage_basic_info_and_add_cust_page.click_edit_customer() self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() self.cust_manage_basic_info_and_add_cust_page.click_edit_customer() self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() # 是或否批量下发指令 和批量下发工作模式 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.log_in_base.click_account_center_button() sleep(2) self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in_with_csv(info["wdit_account"], info["passwd"]) sleep(1) hello_usr = self.account_center_page_navi_bar.hello_user_account() self.assertIn(info["wdit_account"], hello_usr, "登录成功后招呼栏账户名显示错误") sleep(1) # 进入设备管理/指令管理页面,获取功能按钮 facility_manage_data = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button() sleep(2) 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.log_in_base.click_account_center_button() sleep(2) self.account_center_page_navi_bar.usr_logout() break csv_file.close()
class TestCase402CustomerManagementLowerUserSearch(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.account_center_page_details = AccountCenterDetailsPage( 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.search_sql = SearchSql() self.connect_sql = ConnectSql() 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_customer_management_lower_user_search(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() # 点击账户中心 # self.account_center_page_navi_bar.click_account_center_button() # current_account = self.log_in_base.get_log_in_account() # 进入客户管理页面 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) csv_file = self.cust_manage_page_read_csv.read_csv('acc_search.csv') csv_data = csv.reader(csv_file) is_header = True for row in csv_data: if is_header: is_header = False continue search_data = { 'account': row[0], "account_type": row[1], "info": row[2] } print(search_data) sleep(1) self.cust_manage_lower_account_page.add_data_to_search_account( search_data) connect = self.connect_sql.connect_tuqiang_sql() # 创建数据库游标 cur = connect.cursor() # 执行sql脚本查询当前登录账号的userId,fullParent get_id_sql = "select o.account,o.userId,o.fullParentId from user_info o where o.account = '" + search_data[ 'account'] + "' ;" cur.execute(get_id_sql) # 读取数据 user_relation = cur.fetchall() # 遍历数据 for row in user_relation: user_relation_id = { "account": row[0], "userId": row[1], "fullParent": row[2] } # 执行sql脚本,根据当前登录账号的userId,fullParent查询出当前账户的所有下级账户 get_lower_account_sql = "select userId from user_info where fullParentId = " + \ "'" + user_relation_id["fullParent"] + user_relation_id[ "userId"] + ",'" + ";" cur.execute(get_lower_account_sql) # 读取数据 lower_account = cur.fetchall() print(lower_account) lower_account_list = [] for range1 in lower_account: for range2 in range1: lower_account_list.append(range2) lower_account_tuple = tuple(lower_account_list) print(lower_account_tuple) get_total_sql = self.search_sql.search_account_sql( lower_account_tuple, search_data) print(get_total_sql) cur.execute(get_total_sql) # 读取数据 total_data = cur.fetchall() # 从数据tuple中获取最终查询记录统计条数 total_list = [] for range1 in total_data: for range2 in range1: total_list.append(range2) total = len(total_list) print('本次查询数据库的条数为:%s' % total) web_total = self.cust_manage_lower_account_page.get_account_number( ) print('本次查询页面的条数是:%s' % web_total) self.assertEqual(total, web_total) cur.close() connect.close() csv_file.close()
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 TestCase407CustomerManagementOperationEditUser(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_user_operation_edit_user(self): self.base_page.open_page() 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) csv_file = self.cust_manage_page_read_csv.read_csv( 'edit_user_data.csv') csv_data = csv.reader(csv_file) for row in csv_data: info = { "user_name": row[0], "phone": row[1], "email": row[2], "conn": row[3], "com": row[4] } # 搜索一个客户 self.cust_manage_lower_account_page.input_search_info('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 获取搜索出来的客户信息 user_account = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page( ) user_type = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page( ) user_name = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page( ) user_phone = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page( ) user_contact = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page( ) # 点击编辑 - 取消 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) # 点击取消 self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() # 点击编辑 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user( info) # 点击取消 self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() user_account_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page( ) user_type_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page( ) user_name_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page( ) user_phone_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page( ) user_contact_01 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page( ) self.assertEqual(user_account, user_account_01) self.assertEqual(user_type, user_type_01) self.assertEqual(user_name, user_name_01) self.assertEqual(user_phone, user_phone_01) self.assertEqual(user_contact, user_contact_01) # 点击编辑 - 取消 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) # 点击取消 self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() # 点击编辑 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user( info) # 点击关闭 self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_close_edit_accunt_button( ) user_account_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page( ) user_type_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page( ) user_name_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page( ) user_phone_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page( ) user_contact_02 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page( ) self.assertEqual(user_account, user_account_02) self.assertEqual(user_type, user_type_02) self.assertEqual(user_name, user_name_02) self.assertEqual(user_phone, user_phone_02) self.assertEqual(user_contact, user_contact_02) # 点击编辑 - 取消 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) # 点击取消 self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() # 点击编辑 self.cust_manage_basic_info_and_add_cust_page.click_edit_account_buttons( ) self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.add_data_to_edit_user( info) # 点击关闭 self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_ensure() user_account_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_account_in_customer_page( ) user_type_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_type_in_customer_page( ) user_name_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_name_in_customer_page( ) user_phone_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_phone_in_customer_page( ) user_contact_03 = self.cust_manage_basic_info_and_add_cust_page.get_user_contact_in_customer_page( ) self.assertEqual(user_account, user_account_03) self.assertEqual(user_type, user_type_03) self.assertEqual(info['user_name'], user_name_03) self.assertEqual(info['phone'], user_phone_03) self.assertEqual(info['conn'], user_contact_03) csv_file.close()
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()
class TestCase60CustManageLowerAccountEdit(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.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_cust_manage_lower_account_edit(self): '''客户管理-下级客户-单个客户编辑''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() self.driver.wait(1) # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() csv_file = self.cust_manage_page_read_csv.read_csv('lower_acc_edit.csv') csv_data = csv.reader(csv_file) for row in csv_data: edit_info = { "acc_type": row[0], "acc_name": row[1], "phone": row[2], "email": row[3], "conn": row[4], "com": row[5] } sleep(2) # 取消 self.cust_manage_lower_account_page.edit_info_cancel() # 点击单个用户的编辑 self.cust_manage_lower_account_page.click_acc_edit() # 选择客户类型 sleep(3) self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_lower_account_page.acc_type_choose(edit_info["acc_type"]) # 编辑信息 self.cust_manage_lower_account_page.edit_acc_input_info_edit(edit_info["acc_name"], edit_info["phone"], edit_info["email"], edit_info["conn"], edit_info["com"]) # 保存 self.driver.default_frame() self.cust_manage_lower_account_page.edit_info_save() # 获取操作状态 status = self.cust_manage_lower_account_page.edit_info_save_status() # 验证是否操作成功 self.assertIn(self.assert_text.account_center_page_operation_done(), status, "操作失败")