class TestCase211UserCenterLogout(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.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_logout(self): self.base_page.open_page() self.log_in_base.log_in() # 点击退出登录 self.user_center_page.click_user_center_button() # 点击退出登录按钮 self.user_center_page.click_logout_button() # 点击取消 self.user_center_page.click_cancel_button() # 点击退出登录 self.user_center_page.click_user_center_button() # 点击退出登录按钮 self.user_center_page.click_logout_button() # 点击取消 self.user_center_page.click_close_button() # 点击退出登录 self.user_center_page.click_user_center_button() # 点击退出登录按钮 self.user_center_page.click_logout_button() # 点击取消 self.user_center_page.click_ensure_button()
class TestCase201UserCenterModifyInfo(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_details = AccountCenterDetailsPage(self.driver, self.base_url) self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.user_center_page = UserCenterPage(self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.driver.clear_cookies() # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.log_in_base.log_in() def tearDown(self): self.driver.quit_browser() def test_user_center_modify_info(self): # 通过csv测试修改资料功能 self.account_center_page_navi_bar.click_account_center_button() csv_file = self.account_center_page_read_csv.read_csv('user_to_modify_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: user_to_modify_info = { "username": row[0], "phone": row[1], "email": row[2] } # 获取当前登录账号 log_in_account = self.log_in_base.get_log_in_account() # 从数据库获取登录账号的客户名称、电话、邮箱 account_info = self.user_center_page.get_account_info(log_in_account) print(account_info) # 点击个人中心 - 修改资料 self.user_center_page.click_user_center_button() self.user_center_page.click_modify_user_info() # 获取修改资料里面的信息 user_account = self.user_center_page.get_user_account_in_modify_page() user_name = self.user_center_page.get_user_name_in_modify_page() user_phone = self.user_center_page.get_user_phone_in_modify_page() user_email = self.user_center_page.get_user_email_in_modify_page() # 断言 self.assertEqual(log_in_account, user_account) self.assertEqual(account_info[0], user_name) self.assertEqual(account_info[1], user_phone) self.assertEqual(account_info[2], user_email) # 填写客户名称、电话、邮箱 self.user_center_page.add_data_to_modify_info(user_to_modify_info) # 点击取消的按钮 self.user_center_page.click_cancel_button() # 从数据库获取登录账号的客户名称、电话、邮箱 account_info1 = self.user_center_page.get_account_info(log_in_account) print(account_info1) self.assertEqual(account_info, account_info1) # 点击个人中心 - 修改资料 self.user_center_page.click_user_center_button() self.user_center_page.click_modify_user_info() # 获取修改资料里面的信息 user_account = self.user_center_page.get_user_account_in_modify_page() user_name = self.user_center_page.get_user_name_in_modify_page() user_phone = self.user_center_page.get_user_phone_in_modify_page() user_email = self.user_center_page.get_user_email_in_modify_page() # 断言 self.assertEqual(log_in_account, user_account) self.assertEqual(account_info1[0], user_name) self.assertEqual(account_info1[1], user_phone) self.assertEqual(account_info1[2], user_email) # 点击关闭 # 填写客户名称、电话、邮箱 self.user_center_page.add_data_to_modify_info(user_to_modify_info) self.user_center_page.click_close_button() # 从数据库获取登录账号的客户名称、电话、邮箱 account_info2 = self.user_center_page.get_account_info(log_in_account) print(account_info2) self.assertEqual(account_info, account_info2) # 点击个人中心 - 修改资料 self.user_center_page.click_user_center_button() self.user_center_page.click_modify_user_info() # 获取修改资料里面的信息 user_account = self.user_center_page.get_user_account_in_modify_page() user_name = self.user_center_page.get_user_name_in_modify_page() user_phone = self.user_center_page.get_user_phone_in_modify_page() user_email = self.user_center_page.get_user_email_in_modify_page() # 断言 self.assertEqual(log_in_account, user_account) self.assertEqual(account_info2[0], user_name) self.assertEqual(account_info2[1], user_phone) self.assertEqual(account_info2[2], user_email) # 填写客户名称、电话、邮箱 self.user_center_page.add_data_to_modify_info(user_to_modify_info) # 点击确认 self.user_center_page.click_ensure_button() # 从数据库获取登录账号的客户名称、电话、邮箱 account_info3 = self.user_center_page.get_account_info(log_in_account) print(account_info3) web_data = [user_to_modify_info['username'], user_to_modify_info['phone'], user_to_modify_info['email']] self.assertEqual(account_info3, web_data) # 点击个人中心 - 修改资料 self.user_center_page.click_user_center_button() self.user_center_page.click_modify_user_info() # 获取修改资料里面的信息 user_account = self.user_center_page.get_user_account_in_modify_page() user_name = self.user_center_page.get_user_name_in_modify_page() user_phone = self.user_center_page.get_user_phone_in_modify_page() user_email = self.user_center_page.get_user_email_in_modify_page() # 断言 self.assertEqual(log_in_account, user_account) self.assertEqual(account_info3[0], user_name) self.assertEqual(account_info3[1], user_phone) self.assertEqual(account_info3[2], user_email) self.user_center_page.click_close_button() 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 TestCase202UserCenterModifyInfo2(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_details = AccountCenterDetailsPage(self.driver, self.base_url) self.account_center_page_read_csv = AccountCenterPageReadCsv() self.log_in_base = LogInBaseServer(self.driver, self.base_url) self.user_center_page = UserCenterPage(self.driver, self.base_url) self.assert_text = AssertText() self.driver.set_window_max() self.driver.clear_cookies() # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.log_in_base.log_in() def tearDown(self): self.driver.quit_browser() def test_user_center_modify_info2(self): # 通过csv测试修改资料功能 current_handle = self.driver.get_current_window_handle() self.account_center_page_navi_bar.click_account_center_button() self.base_page.change_windows_handle(current_handle) # 点击个人中心 - 修改资料 self.user_center_page.click_user_center_button() self.user_center_page.click_modify_user_info() # 1.特殊字符 special_char = "/\^<>!~%*" # 在客户名称、电话中输入特殊字符 self.user_center_page.input_user_name_in_modify_info(special_char) self.user_center_page.input_user_phone_in_modify_info(special_char) # 点击保存 self.user_center_page.click_ensure_button() # 验证 # 获取主页上的用户名称和电话 user_name = self.user_center_page.get_user_name_in_main_page() user_phone = self.user_center_page.get_user_phone_in_main_page() self.assertNotEqual(special_char, user_name) self.assertNotEqual(special_char, user_phone) # 2.验证客户名称必填 self.user_center_page.input_user_name_in_modify_info('') self.user_center_page.input_user_phone_in_modify_info('') # 点击保存 self.user_center_page.click_ensure_button() # 获取到客户名称的异常提醒 user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page() self.assertEqual(self.assert_text.user_name_not_null(), user_name_exception) # 3.长度限制 long_char = 'fsaffsdafsadfvczxfsdsafdfasdfasdfsdfsdfasdfasdffffffffffffffffffffffarfwqefsadfasdfasdcfsaasdcascsdc' self.user_center_page.input_user_name_in_modify_info(long_char) # 点击保存 self.user_center_page.click_ensure_button() # 获取到客户名称的异常提醒 user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page() self.assertEqual(self.assert_text.user_name_not_to_long(), user_name_exception) shot_char = '12' self.user_center_page.input_user_name_in_modify_info(shot_char) # 点击保存 self.user_center_page.click_ensure_button() # 获取到客户名称的异常提醒 user_name_exception = self.user_center_page.get_user_name_exception_in_modify_info_page() self.assertEqual(self.assert_text.user_name_not_to_shot(), user_name_exception) # 4.邮箱格式限制 email_format = "fdsaffadsfasdf" self.user_center_page.input_user_email_in_modify_info(email_format) # 点击保存 self.user_center_page.click_ensure_button() # 获取到客户邮箱的异常提示 user_email_exception = self.user_center_page.get_user_email_exception_in_modify_info_page() self.assertEqual(self.assert_text.user_email_format_error(), user_email_exception)
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 TestCase207UserCenterCustomerLog(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_customer_log(self): self.base_page.open_page() self.log_in_base.log_in() user_account = self.log_in_base.get_log_in_account() # 点击客户管理 new_customer_data = ['新增的客户', 'new_1226'] current_handle = self.driver.get_current_window_handle() self.user_center_page.click_customer_mangement() self.base_page.change_windows_handle(current_handle) # 新增客户按钮 self.user_center_page.click_add_new_customer_buttons() # 点击切换到frame self.user_center_page.switch_to_add_new_customer_frame() # 填写用户名称和账号 self.user_center_page.add_user_name_and_user_account(new_customer_data) self.driver.default_frame() # 点击确定 self.user_center_page.click_ensure_button() # 搜索新增的用户 self.user_center_page.search_user_in_customer_management( new_customer_data[1]) # 修改用户信息 - 点击编辑 self.user_center_page.click_edit_customer_button() # 点击保存 self.user_center_page.click_ensure_button() # 点击重置密码 self.user_center_page.click_reset_password_button() # 点击保存 self.user_center_page.click_ensure_button() # 点击转移客户 self.user_center_page.click_transfer_customer_button() # 点击保存 self.user_center_page.click_ensure_button() # 点击删除客户 self.user_center_page.click_delete_customer_button() # 点击保存 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_customer_management_condition() self.user_center_page.select_add_new_customer_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(new_customer_data[1], target_account_01) self.assertEqual('网页端', operation_platform_01) web_desc_01 = "用户%s执行添加客户操作" % user_account self.assertEqual(web_desc_01, desc_01) # 查询修改用户信息 self.user_center_page.select_edit_customer_log() # 点击搜索 self.user_center_page.click_search_button_in_business_log() operation_02 = self.user_center_page.get_operation_in_business_log() target_account_02 = self.user_center_page.get_target_account_in_business_log( ) operation_platform_02 = self.user_center_page.get_operation_platform_in_business_log( ) desc_02 = self.user_center_page.get_desc_in_business_log() self.assertEqual(" " + user_account, operation_02) self.assertEqual(new_customer_data[1], target_account_02) self.assertEqual('网页端', operation_platform_02) web_desc_02 = "用户%s执行修改用户信息操作" % user_account self.assertEqual(web_desc_02, desc_02) # 查询删除用户信息 self.user_center_page.select_delete_customer_log() # 点击搜索 self.user_center_page.click_search_button_in_business_log() operation_03 = self.user_center_page.get_operation_in_business_log() target_account_03 = self.user_center_page.get_target_account_in_business_log( ) operation_platform_03 = self.user_center_page.get_operation_platform_in_business_log( ) desc_03 = self.user_center_page.get_desc_in_business_log() self.assertEqual(" " + user_account, operation_03) self.assertEqual(new_customer_data[1], target_account_03) self.assertEqual('网页端', operation_platform_03) web_desc_03 = "用户%s执行删除用户信息操作" % user_account self.assertEqual(web_desc_03, desc_03) # 查询重置密码信息 self.user_center_page.select_reset_password_log() # 点击搜索 self.user_center_page.click_search_button_in_business_log() operation_04 = self.user_center_page.get_operation_in_business_log() target_account_04 = self.user_center_page.get_target_account_in_business_log( ) operation_platform_04 = self.user_center_page.get_operation_platform_in_business_log( ) desc_04 = self.user_center_page.get_desc_in_business_log() self.assertEqual(" " + user_account, operation_04) self.assertEqual(new_customer_data[1], target_account_04) self.assertEqual('网页端', operation_platform_04) web_desc_04 = "用户%s执行重置密码操作" % user_account self.assertEqual(web_desc_04, desc_04) # 查询转移客户信息 self.user_center_page.select_transfer_customer_log() # 点击搜索 self.user_center_page.click_search_button_in_business_log() operation_05 = self.user_center_page.get_operation_in_business_log() target_account_05 = self.user_center_page.get_target_account_in_business_log( ) operation_platform_05 = self.user_center_page.get_operation_platform_in_business_log( ) desc_05 = self.user_center_page.get_desc_in_business_log() self.assertEqual(" " + user_account, operation_05) self.assertEqual(new_customer_data[1], target_account_05) self.assertEqual('网页端', operation_platform_05) web_desc_05 = "对用户%s从%s到%s执行转移客户操作" % (new_customer_data[1], user_account, user_account) self.assertEqual(web_desc_05, desc_05) self.driver.default_frame()