class TestCase10AccountCenterOverviewStock(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.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url) self.driver.set_window_max() self.connect_sql = ConnectSql() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.account_center_change_page = AccountCenterChangePage(self.driver, self.base_page) 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_account_center_overview_stock(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() account = self.log_in_base.get_log_in_account() self.account_center_page_navi_bar.click_account_center_button() # 拖拽页面到库存显示的 self.account_center_change_page.switch_kucun_dev_enable() self.account_center_change_page.switch_to_kucun_dev_frame() kucun_account = self.account_center_change_page.get_account_in_kuncun_frame() self.driver.default_frame()
class TestCase18AccountCenterOverviewSetUpLandmark(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.account_center_page_details = AccountCenterDetailsPage(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.driver.set_window_max() 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_account_center_overview_set_up_landmark(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击库存 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('地标设置') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/safearea/geozonemap?flag=1' self.assertEqual(expect_url, actual_url, '点击地标设置后,实际的url和期望的不一样!') sleep(2) actual_text = self.account_center_page_details.get_actual_text_after_click_set_up_landmark() self.assertEqual(self.assert_text.account_center_page_mark_point_text(), actual_text, '点击地标设置后,页面没有跳转到地标设置页面上') self.assertEqual('active', self.driver.get_element('x,//*[@id="safemenu"]/li[2]').get_attribute('class')) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console() # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button() self.assertEqual(self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase14AccountCenterOverviewAlarm(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.account_center_page_details = AccountCenterDetailsPage(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.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_alarm(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击围栏 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('围栏') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/safearea/geozonemap?flag=0' self.assertEqual(expect_url, actual_url, '点击围栏后,实际的url和期望的不一样!') actual_text = self.account_center_page_details.get_actual_text_after_click_alarm() self.assertEqual(self.assert_text.account_center_page_area_alarm_text(), actual_text, '点击围栏后,页面没有跳转到围栏设置页面') # 验证区域预警有没有被选中 value = self.account_center_page_details.click_safearea_get_vaule() self.assertEqual('active', value) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console() # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button() self.assertEqual(self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase68CustManageCustBatchTransferCustSearch(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_batch_transfer_cust_search(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() sleep(1) # 进入客户管理页面 self.cust_manage_basic_info_and_add_cust_page.enter_cust_manage() sleep(2) self.cust_manage_basic_info_and_add_cust_page.click_first_account() # 点击编辑用户 self.cust_manage_basic_info_and_add_cust_page.click_batch_transfer_customer() self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() self.cust_manage_basic_info_and_add_cust_page.click_batch_transfer_customer() # 循环点击五次 for n in range(5): self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.driver.click_element('x,//*[@id="treeDemo2_%s_span"]' % str(n + 3)) sleep(2) 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 TestCase16AccountCenterOverviewEquipmentManager(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.account_center_page_details = AccountCenterDetailsPage( 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.assert_text = AssertText() self.assert_text2 = AssertText2() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_equipment_manager(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() # self.account_center_page_details.account_center_iframe() current_account = self.log_in_base.get_log_in_account() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击库存 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('设备管理') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/device/toDeviceManage' self.assertEqual(expect_url, actual_url, '点击设备管理后,实际的url和期望的不一样!') # 验证文本 # text = self.account_center_page_details.click_dev_manage_get_text() text = self.account_center_page_details.click_dev_manage_get_text( ) print(text) self.assertEqual( " " + self.assert_text2. account_center_page_contains_lower_dev_text(), text) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase410CustomerManagementEditUserWebLoginLimit(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_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_text2 = AssertText2() 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_edit_user_web_login_limit(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) # 搜索一个客户 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( ) # 点击编辑 - 取消 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( ) # 获取web登录权限的 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() web_login_status = self.cust_manage_basic_info_and_add_cust_page.get_web_login_status( ) self.driver.default_frame() if web_login_status == True: # 点击 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins( ) self.driver.default_frame() # 确定 self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') self.assertEqual(self.assert_text2.login_no_permissions(), self.login_page.get_exception_text()) # 登录 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('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑 - 取消 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.click_web_login_status_ins( ) self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') hello_usr = self.account_center_page_navi_bar.usr_info_account() self.assertIn(user_account, hello_usr) elif web_login_status == False: # 点击 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.click_web_login_status_ins( ) self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') hello_usr = self.account_center_page_navi_bar.usr_info_account() self.assertIn(user_account, hello_usr) # 退出登录 self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in() current_handle_02 = 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_02) # 搜索一个客户 self.cust_manage_lower_account_page.input_search_info('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑 - 取消 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.click_web_login_status_ins( ) self.driver.default_frame() # 确定 self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') self.assertEqual(self.assert_text2.login_no_permissions(), self.login_page.get_exception_text()) self.log_in_base.log_in() current_handle_03 = 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_03) # 搜索一个客户 self.cust_manage_lower_account_page.input_search_info('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑 - 取消 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.click_web_login_status_ins( ) self.driver.default_frame() # 确定 self.cust_manage_basic_info_and_add_cust_page.click_ensure()
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 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 TestCase206UserCenterDevLog(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.help_page = HelpPage(self.driver, self.base_url) self.account_center_page_operation_log = AccountCenterOperationLogPage( self.driver, self.base_url) self.help_page_sql = HelpPageSql() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.connect_sql = ConnectSql() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.user_center_page = UserCenterPage(self.driver, self.base_url) 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_user_center_dev_log(self): self.base_page.open_page() self.log_in_base.log_in() user_account = self.log_in_base.get_log_in_account() # 点击设备管理 current_handle = self.driver.get_current_window_handle() self.user_center_page.click_dev_management_button() sleep(3) self.base_page.change_windows_handle(current_handle) # 获取列表第一个imei号 sleep(3) imei = self.user_center_page.get_dev_list_first_imei() # 点击编辑 self.user_center_page.click_edit_dev_button() # 点击确定 self.user_center_page.click_ensure_button() # 销售 self.user_center_page.click_sale_button() # 进入帮助 - 业务日志页面 current_handle_01 = self.driver.get_current_window_handle() self.user_center_page.click_user_center_button() self.base_page.change_windows_handle(current_handle_01) # 点击帮助 self.user_center_page.click_help_button() # 切换到业务日志的frame里面 self.user_center_page.switch_to_business_frame() self.user_center_page.click_search_button_in_business_log() # 获取第一条数据的操作人、目标账号、操作平台、描述 sleep(3) operation = self.user_center_page.get_operation_in_business_log() target_account = self.user_center_page.get_target_account_in_business_log( ) operation_platform = self.user_center_page.get_operation_platform_in_business_log( ) desc = self.user_center_page.get_desc_in_business_log() self.assertEqual(' ' + user_account, operation) self.assertEqual(target_account, user_account) self.assertEqual('网页端', operation_platform) web_desc = "%s修改设备%s" % (user_account, imei) self.assertEqual(web_desc, desc) # 选择设备分配搜索 self.user_center_page.search_dev_sale_in_business_log() # 点击搜索 self.user_center_page.click_search_button_in_business_log() operation_01 = self.user_center_page.get_operation_in_business_log() target_account_01 = self.user_center_page.get_target_account_in_business_log( ) operation_platform_01 = self.user_center_page.get_operation_platform_in_business_log( ) desc_01 = self.user_center_page.get_desc_in_business_log() self.assertEqual(' ' + user_account, operation_01) self.assertEqual(target_account_01, user_account) self.assertEqual('网页端', operation_platform_01) web_desc_01 = "%s将设备%s从%s分配给%s" % (user_account, imei, user_account, user_account) self.assertEqual(web_desc_01, desc_01) self.driver.default_frame()
class TestCase25AccountCenterDefaultHomePageSetting(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.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url) self.account_center_page_home_page_setting = AccountCenterSettingHomePage(self.driver, self.base_url) self.assert_text2 = AssertText2() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.assert_text = AssertText() self.base_page.open_page() 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_setting_default_home_page_success(self): '''默认设置首页成功''' self.log_in_base.log_in_with_csv("dzltest", "jimi123") self.account_center_page_navi_bar.click_account_center_button() # 点击默认首页设置 self.account_center_page_home_page_setting.click_home_page_setting() # 取列表数据 all_state = self.account_center_page_home_page_setting.get_home_page_list_all_state() self.driver.default_frame() for i in range(len(all_state)): # 点击账户中心 self.account_center_page_navi_bar.click_account_center_button() self.account_center_page_navi_bar.click_account_center_button() # 点击默认首页设置 self.account_center_page_home_page_setting.click_home_page_setting() # 已默认 is_default = self.assert_text2.account_center_home_page_setting_state() text = self.account_center_page_home_page_setting.get_default_setting_text(i + 1) if text["state"] == is_default: self.driver.default_frame() continue else: # 点击设置默认页面、获取状态 prompt = self.account_center_page_home_page_setting.click_setting_default(i + 1) self.assertEqual(self.assert_text2.account_center_home_page_setting_prompt(), prompt, "预期设置默认后的提示语与实际提示语不一致") print(prompt) self.driver.wait() setting_text = self.account_center_page_home_page_setting.get_default_setting_text(i + 1) self.assertEqual(is_default, setting_text["state"], "设置默认后,状态未改变") default_list = [] for a in all_state: if a == is_default: default_list.append(a) self.assertEqual(1, len(default_list), "列表设置默认中存在多个已默认") del (default_list[:]) print("删除后:", default_list) self.driver.default_frame() # 退出 sleep(2) self.account_center_page_navi_bar.usr_logout() # 登录 self.log_in_base.log_in_with_csv("dzltest", "jimi123") actual_url = self.driver.get_current_url() # 获取默认设置的首页地址 expect_url = self.account_center_page_home_page_setting.get_expect_url(setting_text["page_name"]) self.assertEqual(expect_url, actual_url, "登录后,默认主页显示错误") sleep(2) break sleep(2)
class TestCase17AccountCenterOverviewCommand(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.account_center_page_details = AccountCenterDetailsPage( self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_command(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击库存 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('指令管理') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/custom/toTemplate?viewFlag=2' self.assertEqual(expect_url, actual_url, '点击指令管理后,实际的url和期望的不一样!') sleep(3) actual_text = self.account_center_page_details.get_actual_text_after_click_command( ) self.assertEqual( self.assert_text. account_center_page_issued_command_manager(), actual_text, '点击指令管理后,页面没有跳转到下发指令管理上') # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase15AccountCenterOverviewNextGuest(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.account_center_page_details = AccountCenterDetailsPage( 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.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_account_center_overview_next_guest(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() # self.account_center_page_details.account_center_iframe() current_account = self.log_in_base.get_log_in_account() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击下级客户管理 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('下级客户管理') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() # 创建数据库游标 connect = self.connect_sql.connect_tuqiang_sql() cur = connect.cursor() # 执行sql脚本查询当前登录账号的userId,fullParent get_id_sql = "select userId from user_info where account = '" + current_account + "';" cur.execute(get_id_sql) # 读取数据 user_relation = cur.fetchall() user_id = user_relation[0][0] cur.close() connect.close() # actual_url = self.base_url + '/customer/toSearch?userId=%s&viewFlag=4' % user_id actual_url = self.base_url + '/customer/toSearch?viewFlag=4' self.assertEqual(expect_url, actual_url, '点击下级客户管理后,实际的url和期望的不一样!') sleep(3) expect_next = self.account_center_page_details.get_current_account_next( ) actual_next = self.account_center_page_details.get_actual_current_account_next( ) self.assertEqual(expect_next, actual_next, '左侧列表的下级总数和右侧不一致!') # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase63CustManageAddCycleClickUser(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 TestCase016AccountCenterFastSaleReset(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.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.account_center_page_details = AccountCenterDetailsPage( self.driver, self.base_url) self.assert_text2 = AssertText2() self.driver.set_window_max() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.account_center_change_page = AccountCenterChangePage( self.driver, self.base_page) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_fast_sale_reset(self): '''通过csv测试账户详情-快捷销售-删除设备、重置功能''' csv_file = self.account_center_page_read_csv.read_csv( 'fast_sale_exact_find_and_sale.csv') csv_data = csv.reader(csv_file) # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 # self.log_in_base.log_in() self.log_in_base.log_in_with_csv("dzltest", "jimi123") self.driver.wait(1) self.account_center_page_navi_bar.click_account_center_button() for row in csv_data: search_account = { "account": row[0], "device_imei": row[1], "imei_count": row[2], "selected_dev": row[2] } # 进入快捷销售页面 sleep(1) # self.account_center_page_details.account_center_iframe() # self.account_center_page_details.fast_sales() self.account_center_change_page.switch_fast_sale_enable() self.account_center_change_page.switch_to_fast_sale_frame() # 查找账户 self.account_center_page_details.fast_sales_find_account( search_account["account"]) #点取消 self.account_center_page_details.fast_sales_find_and_dis_add_device( "123123123") # 输入设备imei精确查找设备并添加 self.account_center_page_details.fast_sales_find_and_add_device( search_account["device_imei"]) self.driver.default_frame() self.driver.wait() #验证消息中的失败个数 failure_count = self.account_center_page_details.get_device_prompt_failure_count( ) list_failure_count = self.account_center_page_details.get_device_list_failure_count( ) self.assertEqual(failure_count, list_failure_count, "显示的失败个数与列表中的失败数不一致") #验证消息中的成功个数 all_data = self.account_center_page_details.get_prompt_list_data() succeed_count = self.account_center_page_details.get_device_prompt_succeed_count( ) self.account_center_page_details.click_prompt_close() self.account_center_change_page.switch_to_fast_sale_frame() list_count = self.account_center_page_details.get_list_succeed_count( ) self.assertEqual(succeed_count, list_count, "成功添加的设备数不一致") #断言失败提示中的信息 for s in range(list_failure_count): self.assertIsNotNone(all_data["imei"][s], "sim卡号为空") self.assertEqual("失败", all_data["state"][s], "存在不是失败的数据") self.assertIsNotNone(all_data["cause"][s], "失败原因中存在空数据") # 验证已选设备计数是否准确 dev_num = self.account_center_page_details.get_selected_device_num( ) self.assertEqual(list_count, dev_num, "已选设备个数不准确") # 删除列表中的设备 self.account_center_page_details.delete_list_device() self.assertEqual( 0, self.account_center_page_details.get_selected_device_num(), "删除设备后,已选设备数不是0") # 重置验证 self.account_center_page_details.fast_sales_find_and_add_device( search_account["device_imei"]) self.driver.default_frame() self.account_center_page_details.click_prompt_close() self.account_center_change_page.switch_to_fast_sale_frame() self.account_center_page_details.choose_account_expired_time("三个月") self.driver.wait(1) self.account_center_page_details.reset_device() self.assertEqual( 0, self.account_center_page_details.get_list_succeed_count(), "重置后,列表中已添加的设备的数不是0") self.assertEqual( 0, self.account_center_page_details.get_selected_device_num(), "重置后,已选设备数不是0") self.assertEqual( self.assert_text2.account_center_please_select(), self.account_center_page_details.get_account_expired_time_text( ), "重置后,用户到期时间不是请选择") self.driver.default_frame() csv_file.close()
class TestCase208UserCenterSafeAreaLog(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.help_page = HelpPage(self.driver, self.base_url) self.account_center_page_operation_log = AccountCenterOperationLogPage(self.driver, self.base_url) self.help_page_sql = HelpPageSql() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.connect_sql = ConnectSql() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.user_center_page = UserCenterPage(self.driver, self.base_url) 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_user_center_safe_area_log(self): self.base_page.open_page() self.log_in_base.log_in() user_account = self.log_in_base.get_log_in_account() # 点击安全区域 current_handle = self.driver.get_current_window_handle() self.user_center_page.click_safe_area_button() self.base_page.change_windows_handle(current_handle) # 搜索平台围栏 self.user_center_page.search_platform_fence() # 获取第一个围栏的名称 fence_name = self.user_center_page.get_first_fence_name() # 点击编辑 self.user_center_page.click_edit_fence_button() # 点击保存 self.user_center_page.click_ensure_button() # 点击关联 self.user_center_page.click_relevance_fence_button() # 选择设备进行关联 imei_01 = self.user_center_page.click_dev_relevance_fence() # 点击保存 self.user_center_page.click_ensure_button() # 取消关联 self.user_center_page.click_relevance_fence_button() # 选择设备进行关联 imei_02 = self.user_center_page.click_dev_relevance_fence() # 点击保存 self.user_center_page.click_ensure_button() # 进入帮助 - 业务日志页面 self.user_center_page.click_user_center_button() # 点击帮助 self.user_center_page.click_help_button() # 切换到业务日志的frame里面 self.user_center_page.switch_to_business_frame() # 选择安全区域查询 - 新增、编辑 self.user_center_page.select_safe_area_search() self.user_center_page.select_edit_safe_area_search() sleep(5) operation_01 = self.user_center_page.get_operation_in_business_log() target_account_01 = self.user_center_page.get_target_account_in_business_log() operation_platform_01 = self.user_center_page.get_operation_platform_in_business_log() desc_01 = self.user_center_page.get_desc_in_business_log() self.assertEqual(operation_01, ' ' + user_account) self.assertEqual(target_account_01, user_account) self.assertEqual('网页端', operation_platform_01) web_desc_01 = "用户修改了(%s)围栏信息" % (fence_name) self.assertEqual(desc_01, web_desc_01) # 选择关联设备 self.user_center_page.select_relevant_safe_area_search() sleep(5) operation_02 = self.user_center_page.get_operation_in_business_log_02() target_account_02 = self.user_center_page.get_target_account_in_business_log_02() operation_platform_02 = self.user_center_page.get_operation_platform_in_business_log_02() desc_02 = self.user_center_page.get_desc_in_business_log_02() self.assertEqual(operation_02, ' ' + user_account) self.assertEqual(target_account_02, user_account) self.assertEqual('网页端', operation_platform_02) web_desc_02 = "%s关联设备%s与区域信息%s" % (user_account, imei_01, fence_name) self.assertEqual(desc_02, web_desc_02) self.driver.default_frame()
class TestCase51AccountCenterManageAndTelephoneAlarm(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.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.account_center_page_details = AccountCenterDetailsPage( self.driver, self.base_url) self.account_center_page_refill_card = AccountCenterRefillCardPage( self.driver, self.base_url) self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.account_center_page = AccountCenterPage(self.driver, self.base_url) self.search_sql = SearchSql() self.assert_text = AssertText() self.assert_text2 = AssertText2() self.driver.set_window_max() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_case_account_center_manage_and_telephone_alarm(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in_jimitest() self.account_center_page_navi_bar.click_account_center_button() account = self.log_in_base.get_log_in_account() # 点击订单管理 self.account_center_page.clcik_massage_and_telephone_alarm_button_in_account_info_page( ) ## 进入账号详情的frame self.account_center_page.switch_to_massage_and_telephone_alarm_frame() csv_file = self.account_center_page_read_csv.read_csv( 'massage_and_telephone_alarm.csv') csv_data = csv.reader(csv_file) is_header = True for row in csv_data: if is_header: is_header = False continue search_data = {'alarm_name': row[0], 'alarm_type': row[1]} self.account_center_page.add_data_to_search_massage_and_telephone_alarm_in_set_page( search_data) ## 获取数据库查询的条数 sql_number = self.account_center_page.get_sql_number_after_click_massage_and_telephone_alarm_set_search_button( account, search_data) # 获取页面上的条数 web_number = self.account_center_page.get_web_number_after_click_massage_and_telephone_alarm_search_button( ) self.assertEqual(sql_number, web_number) csv_file.close() self.driver.default_frame()
class TestCase12AccountCenterOverviewControl(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.account_center_page_details = AccountCenterDetailsPage( 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.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_control(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击控制台 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('控制台') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/console' self.assertEqual(expect_url, actual_url, '点击控制台后,实际的url和期望的不一样!') # 获取菜单栏中控制台的class属性 get_console_class = self.account_center_page_navi_bar.get_console_class_value( ) # self.assertEqual('active', get_console_class) self.assertIn('active', get_console_class) # 获取全部的li里面的class属性 all_dev_class_value = self.account_center_page_navi_bar.get_all_dev_button_value( ) self.assertEqual('active', all_dev_class_value) #self.assertIn('active', all_dev_class_value) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase24AccountCenterOverviewAttention(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.account_center_page_details = AccountCenterDetailsPage( 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.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_account_center_overview_attention(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() sleep(2) account_center_handle = self.driver.get_current_window_handle() self.account_center_page_details.account_center_iframe() actual_total_attention = self.account_center_page_details.get_actual_total_attention( ) # 点击库存 self.account_center_page_details.account_overview('重点关注车辆') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() connect = self.connect_sql.connect_tuqiang_sql() # 创建数据库游标 cur = connect.cursor() # 执行sql脚本查询当前登录账号的userId,fullParent get_id_sql = "select userId from user_info where account = '" + current_account + "' ;" cur.execute(get_id_sql) # 读取数据 user_relation = cur.fetchall() print(user_relation) user_id = user_relation[0][0] # actual_url = self.base_url + '/console?userId=%s&viewFlag=4' % user_id actual_url = self.base_url + '/console?viewFlag=4' cur.close() connect.close() self.assertEqual(expect_url, actual_url, '点击重点关注车辆后,实际的url和期望的不一样!') sleep(2) # 断言已关注被选中 self.assertEqual( 'active', self.driver.get_element( 'x,//*[@id="FOLLOW"]').get_attribute('class')) expect_total_inactive = self.account_center_page_details.get_total_all_attention_equipment( ) self.assertEqual(actual_total_attention, expect_total_inactive, '账号重点关注车辆数量错误') # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase412CustomerManagementEditUserSendWorkTemplateLimit( 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.driver.set_window_max() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.cust_manage_page_read_csv = CustManagePageReadCsv() self.assert_text2 = AssertText2() 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_edit_user_send_work_template_limit(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) # 搜索一个客户 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( ) # 点击编辑 - 取消 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() web_login_status = self.cust_manage_basic_info_and_add_cust_page.get_send_work_template_status( ) self.driver.default_frame() if web_login_status == True: # 点击 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins( ) self.driver.default_frame() # 确定 self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') # 进入设备管理 获取设备管理页面操的文本 current_handle_01 = 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_01) dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button( ) working_mode = self.assert_text2.dev_manage_setting_working_mode() all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode( ) self.assertNotIn(working_mode, dev_operation_text) self.assertNotIn(all_working_mode, dev_operation_text) # 登录 self.log_in_base.log_in() current_handle_02 = 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_02) # 搜索一个客户 self.cust_manage_lower_account_page.input_search_info('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑 - 取消 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.click_send_work_template_status_ins( ) self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') hello_usr = self.account_center_page_navi_bar.usr_info_account() self.assertIn(user_account, hello_usr) # 进入设备管理 获取设备管理页面操的文本 current_handle_03 = 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_03) dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button( ) working_mode = self.assert_text2.dev_manage_setting_working_mode() all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode( ) self.assertIn(working_mode, dev_operation_text) self.assertIn(all_working_mode, dev_operation_text) elif web_login_status == False: # 点击 self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.cust_manage_basic_info_and_add_cust_page.click_send_work_template_status_ins( ) self.driver.default_frame() self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') hello_usr = self.account_center_page_navi_bar.usr_info_account() self.assertIn(user_account, hello_usr) # 进入设备管理 获取设备管理页面操的文本 current_handle_04 = 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_04) dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button( ) working_mode = self.assert_text2.dev_manage_setting_working_mode() all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode( ) self.assertIn(working_mode, dev_operation_text) self.assertIn(all_working_mode, dev_operation_text) # 退出登录 self.account_center_page_navi_bar.usr_logout() self.log_in_base.log_in() current_handle_05 = 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_05) # 搜索一个客户 self.cust_manage_lower_account_page.input_search_info('abc12344') # 搜索 self.cust_manage_lower_account_page.click_search_btn() # 点击编辑 - 取消 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.click_send_work_template_status_ins( ) self.driver.default_frame() # 确定 self.cust_manage_basic_info_and_add_cust_page.click_ensure() # 退出登录 self.account_center_page_navi_bar.usr_logout() # 登录刚刚的账号 self.log_in_base.log_in_with_csv(user_account, 'jimi123') # 进入设备管理 获取设备管理页面操的文本 current_handle_06 = 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_06) dev_operation_text = self.cust_manage_basic_info_and_add_cust_page.get_facility_manage_page_function_button( ) working_mode = self.assert_text2.dev_manage_setting_working_mode() all_working_mode = self.assert_text2.dev_manage_setting_all_working_mode( ) self.assertNotIn(working_mode, dev_operation_text) self.assertNotIn(all_working_mode, dev_operation_text)
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 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 TestCase06AccountCenterMsgSetRead(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.account_center_page_msg_center = AccountCenterMsgCenterPage( 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.assert_text = AssertText() 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_account_center_msg_set_read(self): '''通过csv测试消息中心-设置消息为已读功能''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() # 进入消息中心 self.account_center_page_msg_center.enter_msg_center() self.driver.wait(8) # 进入iframe # self.account_center_page_msg_center.message_center_iframe() # 获取消息中心title msg_center_title = self.account_center_page_msg_center.get_msg_center_title( ) # 验证消息中心title是否正确显示 self.assertIn( self.assert_text.account_center_page_message_center_text(), msg_center_title, "消息中心title有误!") # 退出iframe # self.driver.default_frame() # 获取左侧栏目-消息中心-x条未读 unread_msg_num = int( self.account_center_page_msg_center.get_unread_msg_num()) if unread_msg_num > 0: self.account_center_page_msg_center.message_center_iframe() # 设置搜索条件-消息状态为“未读”,搜索出结果,统计当前未读消息总数 self.account_center_page_msg_center.set_search_status_unread() self.driver.wait(4) # 判断消息中心左侧栏目的未读消息与搜索结果的未读消息数量是否一致 count_unread_msg_num = self.account_center_page_msg_center.get_total_unread_logs_num( ) self.assertEqual(unread_msg_num, count_unread_msg_num, "消息中心左侧栏目的未读消息与搜索结果的未读消息数量不一致") # 根据未读消息总数,将所有未读消息设为已读 if 0 < count_unread_msg_num <= 10: # 当前页全选 self.account_center_page_msg_center.select_current_page_all_msg( ) # 获取当前页所有消息的复选框 select_msg_list = self.account_center_page_msg_center.get_current_page_all_msg_checkbox( ) print(select_msg_list) msg_list_len = len(select_msg_list) print(msg_list_len) # 将选中的标为已读 self.account_center_page_msg_center.set_current_page_status_read( ) # 验证操作状态是否成功 self.driver.wait() status_text = self.account_center_page_msg_center.get_status_text( ) self.assertIn( self.assert_text.account_center_page_operation_done(), status_text, "操作失败") self.driver.wait() # 设置搜索条件-消息状态为“未读”,判断未读消息列表是否为空 self.account_center_page_msg_center.set_search_status_unread() no_msg_text = self.account_center_page_msg_center.get_no_msg_text( ) self.driver.wait() self.assertIn( self.assert_text.account_center_page_no_data_text(), no_msg_text, "未读消息列表未清空") else: # 将所有消息全部标为已读 self.account_center_page_msg_center.set_all_msg_status_read() # 验证操作状态是否成功 self.driver.wait(1) status_text = self.account_center_page_msg_center.get_status_text( ) self.assertIn( self.assert_text.account_center_page_operation_done(), status_text, "操作失败") # 设置搜索条件-消息状态为“未读”,判断未读消息列表是否为空 self.account_center_page_msg_center.set_search_status_unread() no_msg_text = self.account_center_page_msg_center.get_no_msg_text( ) self.assertIn( self.assert_text.account_center_page_no_data_text(), no_msg_text, "未读消息列表未清空") # 退出登录 self.account_center_page_navi_bar.usr_logout() else: print("当前未读消息共:" + str(unread_msg_num) + "条!") self.driver.default_frame()
class TestCase11AccountCenterOverviewTotal(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.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url) self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.connect_sql = ConnectSql() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_total(self): self.base_page.open_page() self.log_in_base.log_in() # self.log_in_base.log_in_with_csv("kankan111","jimi123") self.account_center_page_navi_bar.click_account_center_button() self.account_center_page_details.account_center_iframe() # 获取登录账号的用户名 # current_account = self.log_in_base.get_log_in_account() sleep(2) account_center_handle = self.driver.get_current_window_handle() expect_total = self.account_center_page_details.get_current_account_total_equipment() # 点击库存 self.account_center_page_details.account_overview('总进货数') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() # 执行sql脚本查询当前登录账号的userId,fullParent actual_url = self.base_url + '/device/toDeviceManage?lowerDevFlag=1' self.assertEqual(expect_url, actual_url, '点击总进货数后,实际的url和期望的不一样!') # 断言包涵下级是否被勾选上 self.assertEqual(True, self.driver.get_element('x,//*[@id="lowerFlag"]/div/input').is_selected()) sleep(3) dev_count = self.account_center_page_details.get_total_dev_number_after_ckick_all_dev_number() self.assertEqual(expect_total, str(dev_count), '当前总进货数和实际数据库不一致!') # 验证清空按钮 self.account_center_page_details.click_clear_all_button() lower_user_input_value = self.account_center_page_details.get_lower_input_value() self.assertEqual(False, lower_user_input_value) # 点搜索 self.account_center_page_details.click_search_button() lower_user_input_value_again = self.account_center_page_details.get_lower_input_value() self.assertEqual(False, lower_user_input_value_again) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console() # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button() self.assertEqual(self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase23AccountCenterOverviewInactive(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.account_center_page_details = AccountCenterDetailsPage( 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.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_inactive(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() self.account_center_page_details.account_center_iframe() actual_total_inctive = self.account_center_page_details.get_actual_total_inactve( ) # 点击未激活 self.account_center_page_details.account_overview('未激活') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/device/toDeviceManage?statusFlag=inactive&lowerDevFlag=1' self.assertEqual(expect_url, actual_url, '点击未激活后,实际的url和期望的不一样!') sleep(3) self.account_center_page_details.click_more_in_dev_manage() self.assertEqual( self.assert_text.account_center_page_activing_text(), self.driver.get_text( 'x,//*[@id="allDev"]/div[2]/div[1]/div/div[6]/div[6]/div[2]/div/div/span[2]' )) self.assertEqual( True, self.driver.get_element( 'x,//*[@id="lowerFlag"]/div/input').is_selected()) expect_total_inactive = self.account_center_page_details.get_total_dev_number_after_ckick_all_dev_number( ) self.assertEqual(actual_total_inctive, str(expect_total_inactive), '账号总览统计未激活数量错误') # 验证清空按钮 self.account_center_page_details.click_clear_all_button() lower_user_input_value = self.account_center_page_details.get_lower_input_value( ) self.assertEqual(False, lower_user_input_value) get_text = self.account_center_page_details.click_active_get_text( ) self.assertEqual( self.assert_text.account_center_page_active_status_text(), get_text) # 点搜索 self.account_center_page_details.click_search_button() lower_user_input_value_again = self.account_center_page_details.get_lower_input_value( ) self.assertEqual(False, lower_user_input_value_again) get_text = self.account_center_page_details.click_active_get_text( ) self.assertEqual( self.assert_text.account_center_page_active_status_text(), get_text) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase67CustManageCustTransferCustSearch(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.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_transfer_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() sleep(2) # 点击编辑用户 self.cust_manage_basic_info_and_add_cust_page.click_transfer_customer() self.cust_manage_basic_info_and_add_cust_page.click_cancel_edit() self.cust_manage_basic_info_and_add_cust_page.click_transfer_customer() # 循环点击五次 for n in range(5): self.cust_manage_basic_info_and_add_cust_page.locate_to_iframe() self.driver.click_element('x,//*[@id="treeDemo2_%s_span"]' % str(n + 3)) sleep(2) 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) """ # 2搜索 seatch_data = ["无", "test", "yonghu222啦啦啦", "休息休息12", "#@@@ %"] for user in range(len(seatch_data)): search_result = self.cust_manage_basic_info_and_add_cust_page.transfer_import_account_search( seatch_data[user]) if type(search_result) is str: self.assertIn( self.assert_text.account_center_page_no_data_text(), search_result, "搜索结果为暂无数据时,提示不一致") else: for subscript in range(len(search_result)): text = search_result[subscript].split("(")[0] self.assertIn(seatch_data[user], text, "搜索结果不一致")
class TestCase13AccountCenterOverviewForm(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.account_center_page_details = AccountCenterDetailsPage( 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.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_form(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击统计报表 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('统计报表') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/deviceReport/statisticalReport' self.assertEqual(expect_url, actual_url, '点击统计报表后,实际的url和期望的不一样!') # 验证文本 actual_text = self.account_center_page_details.click_report_after_text( ) self.assertEqual( self.assert_text.account_center_page_statistical_form_text( ), actual_text) # 验证运动统计是否被选中 # get_value_sport_statistion = self.account_center_page_navi_bar.get_value_sport_statistiacl_value() # self.assertEqual('active', get_value_sport_statistion) # 验证运动总览 get_value_sport_overview = self.account_center_page_navi_bar.get_value_sport_overview_value( ) self.assertEqual('active', get_value_sport_overview) # 验证右侧区域是否为运动总览 get_text = self.account_center_page_navi_bar.get_text_after_report( ) self.assertEqual( self.assert_text.account_center_page_sport_overview_text(), get_text) # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
class TestCase19AccountCenterOverviewAlarm(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.account_center_page_details = AccountCenterDetailsPage( 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.assert_text = AssertText() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_overview_set_up_landmark(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.account_center_page_navi_bar.click_account_center_button() sleep(2) account_center_handle = self.driver.get_current_window_handle() # 点击告警 self.account_center_page_details.account_center_iframe() self.account_center_page_details.account_overview('告警') self.driver.default_frame() all_handles = self.driver.get_all_window_handles() for handle in all_handles: if handle != account_center_handle: self.driver.switch_to_window(handle) sleep(2) expect_url = self.driver.get_current_url() actual_url = self.base_url + '/deviceReport/statisticalReport?modularId=alarmDdetails' self.assertEqual(expect_url, actual_url, '点击告警后,实际的url和期望的不一样!') sleep(2) actual_text = self.account_center_page_details.get_actual_text_after_click_alarms( ) self.assertEqual( self.assert_text.account_center_page_alarm_details_text(), actual_text, '点击告警后,页面没有跳转到告警总览页面上') # 查看控制台告警设置能否打开 self.account_center_page_navi_bar.click_alarm_button_in_console( ) # 断言 get_text = self.account_center_page_navi_bar.get_text_after_click_alarm_button( ) self.assertEqual( self.assert_text.account_center_page_alarm_manager_text(), get_text) self.account_center_page_navi_bar.close_alarm_in_console() self.driver.close_current_page() # 回到账户中心窗口 self.driver.switch_to_window(account_center_handle) self.driver.wait()
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 TestCase37AccountCenterSearchLowerClientVerify(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.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.account_center_page_details = AccountCenterDetailsPage( self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.account_center_change_page = AccountCenterChangePage( self.driver, self.base_page) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_search_lower_client(self): '''通过csv测试账户详情--下级客户--查找不同账号功能''' # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in() self.driver.wait(1) self.account_center_page_navi_bar.click_account_center_button() self.account_center_change_page.switch_fast_sale_enable() self.account_center_change_page.switch_to_fast_sale_frame() csv_file = self.account_center_page_read_csv.read_csv( 'search_different_account.csv') csv_data = csv.reader(csv_file) for row in csv_data: search_account = {"account": row[0]} # 查找账户 search_result = self.account_center_page_details.subordinate_account_search( search_account["account"]) if type(search_result) is str: self.assertIn( self.assert_text.account_center_page_no_data_text(), search_result, "搜索结果为暂无数据时,提示不一致") else: for subscript in range(len(search_result)): text = search_result[subscript].split("(")[0] self.assertIn(search_account["account"], text, "搜索结果不一致") self.driver.wait() # 直接选择用户 for user in range(8): self.account_center_page_details.fast_sales() self.account_center_page_details.click_list_subordinate_client( user + 1) # 验证enter键输入 self.account_center_page_details.fast_sales() self.account_center_page_details.search_subordinate_client_click_enter( "1234") self.driver.wait() self.driver.default_frame() csv_file.close()
class TestCase48AccountCenterVerifyInfo(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.account_center_page_navi_bar = AccountCenterNaviBarPage( self.driver, self.base_url) self.account_center_page_details = AccountCenterDetailsPage( self.driver, self.base_url) self.account_center_page_refill_card = AccountCenterRefillCardPage( self.driver, self.base_url) self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.account_center_page = AccountCenterPage(self.driver, self.base_url) self.search_sql = SearchSql() self.assert_text = AssertText() self.assert_text2 = AssertText2() self.driver.set_window_max() self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_page) self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) def tearDown(self): self.driver.quit_browser() def test_account_center_verify_info(self): # 打开途强在线首页-登录页 self.base_page.open_page() # 登录账号 self.log_in_base.log_in_jimitest() self.account_center_page_navi_bar.click_account_center_button() ## 进入账号详情的frame self.account_center_page.switch_to_account_info_frame() ## 获取到登录账号的信息 account = self.account_center_page.get_account_in_account_info_page() account_type = self.account_center_page.get_account_type_in_account_info_page( ) account_telephone = self.account_center_page.get_account_telephone_in_account_info_page( ) ## 获取最下方客户信息 account_01 = self.account_center_page.get_account_01_in_account_info_page( ) account_type_01 = self.account_center_page.get_account_type_01_in_account_info_page( ) account_telephone_01 = self.account_center_page.get_account_telephone_01_in_account_info_page( ) ## 断言 self.assertEqual(account, account_01) self.assertEqual(account_type, account_type_01) self.assertEqual(account_telephone, account_telephone_01) ## 获取电话、短信告警总数信息 telephone_alarm_number = self.account_center_page.get_telephone_alarm_number_in_account_info_page( ) massage_alarm_number = self.account_center_page.get_massage_alarm_number_in_account_info_page( ) ## 获取数据库剩余电话短信的条数 telephone_and_massage_alarm_number_in_mysql = self.account_center_page.get_telephone_and_massage_alarm_number_in_mysql( account) try: telephone_alarm_number_01 = str( telephone_and_massage_alarm_number_in_mysql[0][0]) massage_alarm_number_01 = str( telephone_and_massage_alarm_number_in_mysql[0][1]) self.assertEqual(telephone_alarm_number, telephone_alarm_number_01) self.assertEqual(massage_alarm_number, massage_alarm_number_01) except: self.assertEqual(telephone_alarm_number, '0') self.assertEqual(massage_alarm_number, '0') ## 获取充值卡剩余数量 year_card_number = self.account_center_page.get_year_card_number_in_account_info_page( ) life_card_number = self.account_center_page.get_life_card_number_in_account_info_page( ) ## 获取数据库剩余充值卡数量 try: year_and_life_card_number_in_mysql = self.account_center_page.get_year_and_life_card_number_in_mysql( account) year_card_number_01 = str(year_and_life_card_number_in_mysql[0][0]) life_card_number_01 = str(year_and_life_card_number_in_mysql[0][1]) self.assertEqual(year_card_number, year_card_number_01) self.assertEqual(life_card_number, life_card_number_01) except: self.assertEqual(year_card_number, '0') self.assertEqual(life_card_number, '0') ## 获取昨天消费统计数 consume_massage_alarm_number = self.account_center_page.get_consume_massage_alarm_number_in_account_info_page( ) consume_telephone_alarm_number = self.account_center_page.get_consume_telephone_alarm_number_in_account_info_page( ) consume_year_card_number = self.account_center_page.get_consume_year_card_number_in_account_info_page( ) consume_life_card_number = self.account_center_page.get_consume_life_card_number_in_account_info_page( ) # 分别获取昨天的短信、电话、年卡、终生卡消费情况 begin_time = self.account_center_page.get_bengin_time('昨天') end_time = self.account_center_page.get_end_time('昨天') try: consume_number = self.account_center_page.get_consume_number_in_mysql( begin_time, end_time, account) self.assertEqual(consume_massage_alarm_number, consume_number[0]) self.assertEqual(consume_telephone_alarm_number, consume_number[1]) self.assertEqual(consume_year_card_number, consume_number[2]) self.assertEqual(consume_life_card_number, consume_number[3]) except: self.assertEqual(consume_massage_alarm_number, '0') self.assertEqual(consume_telephone_alarm_number, '0') self.assertEqual(consume_year_card_number, '0') self.assertEqual(consume_life_card_number, '0') # 点击当月 self.account_center_page.click_this_month_in_account_page() ## 获取当月消费统计数 consume_massage_alarm_number = self.account_center_page.get_consume_massage_alarm_number_in_account_info_page_this_month( ) consume_telephone_alarm_number = self.account_center_page.get_consume_telephone_alarm_number_in_account_info_page_this_month( ) consume_year_card_number = self.account_center_page.get_consume_year_card_number_in_account_info_page_this_month( ) consume_life_card_number = self.account_center_page.get_consume_life_card_number_in_account_info_page_this_month( ) # 分别获取昨天的短信、电话、年卡、终生卡消费情况 begin_time = self.account_center_page.get_bengin_time('本月') end_time = self.account_center_page.get_end_time('本月') try: consume_number = self.account_center_page.get_consume_number_in_mysql( begin_time, end_time, account) self.assertEqual(consume_massage_alarm_number, consume_number[0]) self.assertEqual(consume_telephone_alarm_number, consume_number[1]) self.assertEqual(consume_year_card_number, consume_number[2]) self.assertEqual(consume_life_card_number, consume_number[3]) except: self.assertEqual(consume_massage_alarm_number, '0') self.assertEqual(consume_telephone_alarm_number, '0') self.assertEqual(consume_year_card_number, '0') self.assertEqual(consume_life_card_number, '0') # 点击上月 self.account_center_page.click_last_month_in_account_page() ## 获取上月消费统计数 consume_massage_alarm_number = self.account_center_page.get_consume_massage_alarm_number_in_account_info_page_last_month( ) consume_telephone_alarm_number = self.account_center_page.get_consume_telephone_alarm_number_in_account_info_page_last_month( ) consume_year_card_number = self.account_center_page.get_consume_year_card_number_in_account_info_page_last_month( ) consume_life_card_number = self.account_center_page.get_consume_life_card_number_in_account_info_page_last_month( ) # 分别获取昨天的短信、电话、年卡、终生卡消费情况 begin_time = self.account_center_page.get_bengin_time('上月') end_time = self.account_center_page.get_end_time('上月') try: consume_number = self.account_center_page.get_consume_number_in_mysql( begin_time, end_time, account) self.assertEqual(consume_massage_alarm_number, consume_number[0]) self.assertEqual(consume_telephone_alarm_number, consume_number[1]) self.assertEqual(consume_year_card_number, consume_number[2]) self.assertEqual(consume_life_card_number, consume_number[3]) except: self.assertEqual(consume_massage_alarm_number, '0') self.assertEqual(consume_telephone_alarm_number, '0') self.assertEqual(consume_year_card_number, '0') self.assertEqual(consume_life_card_number, '0') self.driver.default_frame()