class TestCase05UserCenterLogout(unittest.TestCase): # 测试用户中心退出登录 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() 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_user_center_logout(self): '''测试用户中心退出登录功能''' self.base_page.open_page() self.login_page.test_user_login() # 取消退出登录 self.user_center.logout_dismiss() # 关闭退出登录 self.user_center.logout_close() # 确认退出登录 self.user_center.logout()
class TestCase04LoginWithTester(unittest.TestCase): # 测试体验账号登录 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() 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_user_login_exception(self): '''测试体验账号登录''' # 打开风控首页-登录页 self.base_page.open_page() # 点击“我要体验” self.login_page.taste() # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() self.assertEqual('小明', username, '登录成功后招呼栏的用户名错误') # 成功退出系统 sleep(2) self.user_center.logout()
class TestCase04UserCenterModifyPassword(unittest.TestCase): # 测试个人中心修改密码 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_user_center_modify_password(self): # 通过csv测试修改密码功能 # 点击打开修改密码框 self.user_center.click_edit_password() csv_file = self.user_center_read_csv.read_csv( "modify_password_exception.csv") csv_data = csv.reader(csv_file) for row in csv_data: data = { "old_password": row[0], "new_password": row[1], "new_password2": row[2], "pwd_prompt": row[3], } text = self.user_center.get_modify_pwd_exception_prompt( data['old_password'], data['new_password'], data['new_password2']) self.assertIn(data["pwd_prompt"], text, "修改密码,错误提示语显示不一致") csv_file.close() # 关闭修改密码框 self.user_center.click_edit_password_close() # 退出登录 self.user_center.logout()
class TestCase01UserCenterModifyInfo(unittest.TestCase): # 测试个人中心修改资料 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() 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_user_center_modify_info(self): # 通过csv测试修改资料功能 csv_file = self.user_center_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], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() # 获取当前登录账号 log_in_account = self.user_center.get_login_account() print(log_in_account) # 从数据库获取登录账号的客户名称、电话 account_info = self.user_center.get_account_info_by_sql( log_in_account) print(account_info) # 获取修改资料里面的信息 user_info = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info['login_account']) self.assertEqual(account_info[1], user_info['name']) self.assertEqual(account_info[2], user_info['tel']) # 编辑客户名称、电话后点击取消 self.user_center.edit_user_info_not_save( user_to_modify_info['username'], user_to_modify_info['phone']) # 从数据库获取登录账号的客户名称、电话 account_info1 = self.user_center.get_account_info_by_sql( log_in_account) print(account_info1) self.assertEqual(account_info, account_info1) # 获取修改资料里面的信息 user_info1 = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info1['login_account']) self.assertEqual(account_info1[1], user_info1['name']) self.assertEqual(account_info1[2], user_info1['tel']) # 编辑客户名称、电话后点击关闭按钮 self.user_center.edit_user_info_close( user_to_modify_info['username'], user_to_modify_info['phone']) # 从数据库获取登录账号的客户名称、电话 account_info2 = self.user_center.get_account_info_by_sql( log_in_account) print(account_info2) self.assertEqual(account_info, account_info2) # 获取修改资料里面的信息 user_info2 = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info2['login_account']) self.assertEqual(account_info2[1], user_info2['name']) self.assertEqual(account_info2[2], user_info2['tel']) # 编辑客户名称、电话后保存 print(user_to_modify_info['username'], user_to_modify_info['phone']) self.user_center.edit_user_info_exception( user_to_modify_info['username'], user_to_modify_info['phone']) # 从数据库获取登录账号的客户名称、电话 account_info3 = self.user_center.get_account_info_by_sql( log_in_account) print(account_info3) web_data = [ log_in_account, user_to_modify_info['username'], user_to_modify_info['phone'] ] self.assertEqual(account_info3, web_data) # 获取修改资料里面的信息 user_info3 = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info3['login_account']) self.assertEqual(account_info3[1], user_info3['name']) self.assertEqual(account_info3[2], user_info3['tel']) # 退出登录 self.user_center.logout() csv_file.close()
class TestCase05RoleManageSearchRole(unittest.TestCase): # 测试角色管理搜索角色 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() 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_search_role(self): # 通过csv测试搜索角色功能 csv_file = self.role_management_read_csv.read_csv('search_role.csv') csv_data = csv.reader(csv_file) for row in csv_data: search_role = { "account": row[0], "password": row[1], "search_name": row[2], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(search_role['account'], search_role['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( search_role['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入角色管理 self.role_management.click_role_manage() # 输入搜索关键词进行搜索 self.role_management.search_role(search_role['search_name']) # 获取搜索结果 num = int(self.role_management.get_search_result_num()) role_name = self.role_management.get_search_result_all() # 数据库查询搜索结果 role_name_by_sql = self.role_management.get_search_result_rolename_by_sql( search_role['account'], search_role['search_name']) num_by_sql = self.role_management.get_search_result_num_by_sql( search_role['account'], search_role['search_name']) # 验证搜索结果是否一致 self.assertEqual(num, num_by_sql) self.assertEqual(set(role_name), set(role_name_by_sql)) # 跳出外层frame self.role_management.switch_to_default_content() # 退出登录 self.user_center.logout() csv_file.close()
class TestCase02LoanReport(unittest.TestCase): # 逾期还款统计 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.statistics_report = StatisticsReport(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.statistics_report_read_csv = StatisticsReportReadCsv() self.driver.set_window_max() 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_loan_report(self): # 测试逾期还款统计 # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_statistics_login_user_normal() # 获取当前登录账号 log_in_account = self.user_center.get_login_account() print(log_in_account) # 从数据库获取登录账号的客户名称、电话 account_info = self.user_center.get_account_info_by_sql(log_in_account) print(account_info) # 获取修改资料里面的信息 user_info = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info['login_account']) self.assertEqual(account_info[1], user_info['name']) self.assertEqual(account_info[2], user_info['tel']) # 点击统计报表 self.statistics_report.click_statistics_report() # 点击进入逾期还款报表 self.statistics_report.click_loan() # 切入frame self.statistics_report.switch_to_myframe() csv_file = self.statistics_report_read_csv.read_csv('loan_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: loan_info = { "times": row[0], } # 勾选包含下级车主 self.statistics_report.click_contain_lower() # 选择逾期次数 self.statistics_report.choose_loan_times(loan_info['times']) # 点击搜索 self.statistics_report.click_loan_search() # 获取搜索结果 result_info = self.statistics_report.get_loan_search_result() print(result_info) # 获取数据库查询结果 info = self.statistics_report.get_loan_search_result_by_sql( log_in_account) print(info) # 验证搜索结果是否一致 self.assertEqual(result_info, info) # 跳出frame self.statistics_report.switch_default() # 退出登录 self.user_center.logout()
class TestCase04RoleManageEditRole(unittest.TestCase): # 测试角色管理修改角色 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() 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_edit_role(self): # 通过csv测试修改角色功能 csv_file = self.role_management_read_csv.read_csv('edit_role_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: edit_role_info = { "account": row[0], "password": row[1], "search_key": row[2], "edit_role_name": row[3], "edit_role_description": row[4], "edit_role_limit": row[5], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(edit_role_info['account'], edit_role_info['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( edit_role_info['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入角色管理 self.role_management.click_role_manage() # 查找11111角色 self.role_management.search_role(edit_role_info['search_key']) # 获取页面查找结果 search_role_name_01 = self.role_management.get_search_result_one() # 查询数据库获取搜索结果 role_info_00 = self.role_management.get_search_result_by_sql( edit_role_info['account'], edit_role_info['search_key']) role_name_00 = role_info_00[0] role_desc_00 = role_info_00[1] self.assertEqual(search_role_name_01, role_name_00) # 点击修改 self.role_management.click_edit_role() # 切入内层frame self.role_management.switch_to_2_frame() # 获取当前显示的角色名称是否与未修改前一致 current_role_name_01 = self.role_management.get_current_role_name() self.assertEqual(search_role_name_01, current_role_name_01) # 获取显示的角色描述是否与未修改前一致 current_role_desc = self.role_management.get_current_role_desc() self.assertEqual(role_desc_00, current_role_desc) # 输入角色名称 self.role_management.input_add_role_name( edit_role_info['edit_role_name']) # 输入角色描述 self.role_management.input_add_role_description( edit_role_info['edit_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( edit_role_info['edit_role_limit']) # 点击取消 self.role_management.click_add_role_dismiss() # 数据库查询是否修改失败 role_info_01 = self.role_management.get_search_result_by_sql( edit_role_info['account'], edit_role_info['search_key']) role_name_01 = role_info_01[0] role_desc_01 = role_info_01[1] self.assertEqual(role_name_00, role_name_01) self.assertEqual(role_desc_00, role_desc_01) # 点击修改 self.role_management.click_edit_role() # 切入内层frame self.role_management.switch_to_2_frame() # 获取当前显示的角色名称是否与未修改前一致 current_role_name_01 = self.role_management.get_current_role_name() self.assertEqual(search_role_name_01, current_role_name_01) # 获取显示的角色描述是否与未修改前一致 current_role_desc = self.role_management.get_current_role_desc() self.assertEqual(role_desc_00, current_role_desc) # 输入角色名称 self.role_management.input_add_role_name( edit_role_info['edit_role_name']) # 输入角色描述 self.role_management.input_add_role_description( edit_role_info['edit_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( edit_role_info['edit_role_limit']) # 点击关闭按钮 self.role_management.click_add_role_close() # 数据库查询是否修改失败 role_info_02 = self.role_management.get_search_result_by_sql( edit_role_info['account'], edit_role_info['search_key']) role_name_02 = role_info_02[0] role_desc_02 = role_info_02[1] self.assertEqual(role_name_00, role_name_02) self.assertEqual(role_desc_00, role_desc_02) # 点击修改 self.role_management.click_edit_role() # 切入内层frame self.role_management.switch_to_2_frame() # 获取当前显示的角色名称是否与未修改前一致 current_role_name_01 = self.role_management.get_current_role_name() self.assertEqual(search_role_name_01, current_role_name_01) # 获取显示的角色描述是否与未修改前一致 current_role_desc = self.role_management.get_current_role_desc() self.assertEqual(role_desc_00, current_role_desc) # 输入角色名称 self.role_management.input_add_role_name( edit_role_info['edit_role_name']) # 输入角色描述 self.role_management.input_add_role_description( edit_role_info['edit_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( edit_role_info['edit_role_limit']) # 点击保存按钮 self.role_management.click_add_role_save() # 数据库查询是否修改成功 role_info_03 = self.role_management.get_search_result_by_sql( edit_role_info['account'], edit_role_info['edit_role_name']) role_name_03 = role_info_03[0] role_desc_03 = role_info_03[1] self.assertNotEqual(role_name_00, role_name_03) self.assertNotEqual(role_desc_00, role_desc_03) # 跳出外层frame self.role_management.switch_to_default_content() # 退出登录 self.user_center.logout() csv_file.close()
class TestCase04AccountLog(unittest.TestCase): # 账号管理记录 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.operation_log = OperationLog(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.operation_log_read_csv = OperationLogReadCsv() self.driver.set_window_max() 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_log(self): # 测试账号管理记录 # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_log_login_user_normal() # 获取当前登录账号 log_in_account = self.user_center.get_login_account() print(log_in_account) # 从数据库获取登录账号的客户名称、电话 account_info = self.user_center.get_account_info_by_sql(log_in_account) print(account_info) # 获取修改资料里面的信息 user_info = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info['login_account']) self.assertEqual(account_info[1], user_info['name']) self.assertEqual(account_info[2], user_info['tel']) # 点击设置 self.operation_log.click_setup() # 点击进入操作日志 self.operation_log.click_operation_log() # 切入frame self.operation_log.switch_to_myframe() # 点击账号管理记录 self.operation_log.click_account_log() csv_file = self.operation_log_read_csv.read_csv('account_log.csv') csv_data = csv.reader(csv_file) for row in csv_data: account_log = { "start_time": row[0], "end_time": row[1], "type": row[2], } # 输入时间段 self.operation_log.account_input_time(account_log['start_time'], account_log['end_time']) # 选择类型 self.operation_log.account_choose_type(account_log['type']) # 点击搜索 self.operation_log.account_click_search() '''# 获取搜索结果 result_info = self.operation_log.get_account_log_search_result() print(result_info) # 获取数据库查询结果 info = self.operation_log.get_account_log_search_result_by_sql(log_in_account,account_log['start_time'],account_log['end_time']) # 验证搜索结果是否一致 self.assertEqual(result_info,info)''' # 点击重置 self.operation_log.account_click_reset() # 跳出frame self.operation_log.switch_default() # 退出登录 self.user_center.logout()
class TestCase04OrgManageEditOrg(unittest.TestCase): # 测试部门管理修改公司部门 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() 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_edit_org(self): # 通过csv测试修改公司部门功能 csv_file = self.user_center_read_csv.read_csv('edit_org_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: edit_org_info = { "account": row[0], "password": row[1], "search_key": row[2], "edit_org_name": row[3], "choose_sup_org": row[4], "edit_org_tel": row[5], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(edit_org_info['account'], edit_org_info['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( edit_org_info['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入部门管理 self.organize_management.click_org_manage() # 查找test00000部门 self.organize_management.search_org(edit_org_info['search_key']) # 获取页面查找结果 search_org_name_01 = self.organize_management.get_search_result_one( ) # 查询数据库获取搜索结果 org_info_00 = self.organize_management.get_search_result_by_sql( edit_org_info['account'], edit_org_info['search_key']) org_name_00 = org_info_00[0] sup_org_name_00 = org_info_00[1] org_tel_00 = org_info_00[2] self.assertEqual(search_org_name_01, org_name_00) # 点击修改 self.organize_management.click_edit_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 获取当前显示的部门名称是否与未修改前一致 current_org_name_01 = self.organize_management.get_current_org_name( ) self.assertEqual(search_org_name_01, current_org_name_01) # 获取显示的所属上级是否与未修改前一致 current_sup_org = self.organize_management.get_current_sup_org_name( ) self.assertEqual(sup_org_name_00, current_sup_org) # 获取显示的联系方式是否与未修改前一致 current_org_tel = self.organize_management.get_current_org_tel() self.assertEqual(org_tel_00, current_org_tel) # 修改部门名称 self.organize_management.edit_org_name( edit_org_info['edit_org_name']) # 修改所属上级 self.organize_management.edit_sup_org( edit_org_info['choose_sup_org']) # 修改联系方式 self.organize_management.edit_org_tel( edit_org_info['edit_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 取消 self.organize_management.click_org_modify_dismiss() # 数据库查询是否修改失败 org_info_01 = self.organize_management.get_search_result_by_sql( edit_org_info['account'], edit_org_info['search_key']) org_name_01 = org_info_01[0] sup_org_name_01 = org_info_01[1] org_tel_01 = org_info_01[2] self.assertEqual(org_name_00, org_name_01) self.assertEqual(sup_org_name_00, sup_org_name_01) self.assertEqual(org_tel_00, org_tel_01) # 点击修改 self.organize_management.click_edit_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 修改部门名称 self.organize_management.edit_org_name( edit_org_info['edit_org_name']) # 修改所属上级 self.organize_management.edit_sup_org( edit_org_info['choose_sup_org']) # 修改联系方式 self.organize_management.edit_org_tel( edit_org_info['edit_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 关闭 self.organize_management.click_org_modify_close() # 数据库查询是否修改失败 org_info_02 = self.organize_management.get_search_result_by_sql( edit_org_info['account'], edit_org_info['search_key']) org_name_02 = org_info_02[0] sup_org_name_02 = org_info_02[1] org_tel_02 = org_info_02[2] self.assertEqual(org_name_00, org_name_02) self.assertEqual(sup_org_name_00, sup_org_name_02) self.assertEqual(org_tel_00, org_tel_02) # 点击修改 self.organize_management.click_edit_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 修改部门名称 self.organize_management.edit_org_name( edit_org_info['edit_org_name']) # 修改所属上级 self.organize_management.edit_sup_org( edit_org_info['choose_sup_org']) # 修改联系方式 self.organize_management.edit_org_tel( edit_org_info['edit_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 修改(保存) self.organize_management.click_org_modify_button() # 数据库查询是否修改成功 org_info_03 = self.organize_management.get_search_result_by_sql( edit_org_info['account'], edit_org_info['search_key']) org_name_03 = org_info_03[0] sup_org_name_03 = org_info_03[1] org_tel_03 = org_info_03[2] self.assertEqual(edit_org_info['edit_org_name'], org_name_03) self.assertEqual(edit_org_info['choose_sup_org'], sup_org_name_03) self.assertEqual(edit_org_info['edit_org_tel'], org_tel_03) # 跳出外层frame self.organize_management.switch_to_default_content() # 退出登录 self.user_center.logout() csv_file.close()
class TestCase02UserCenterModifyInfoException(unittest.TestCase): # 测试个人中心修改资料 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_user_center_modify_info_exception(self): # 测试修改资料异常 # 1.特殊字符 special_char = "/\^<>!~%*" # 在电话中输入特殊字符 self.user_center.edit_user_info_exception('孙燕妮测试用户', special_char) # 验证 # 获取到电话的异常提醒 phone_text = self.user_center.get_phone_exception_text() self.assertEqual('请输入正确的手机号码',phone_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户电话 phone_text = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone_text,special_char) # 2.验证用户名称、电话必填 # 用户名称、电话输入为空 self.user_center.edit_user_info_exception('', '') # 获取到用户名称、电话为空的异常提醒 all_null_text = self.user_center.get_name_and_phone_null_text() self.assertEqual('请输入用户名称',all_null_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 username_null_text = self.user_center.get_user_info()['name'] self.assertNotEqual(username_null_text, '') # 获取修改后的当前用户电话 phone_null_text = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone_null_text, '') # 用户名称输入为空、电话输入正确 phone_01 = '13852654587' self.user_center.edit_user_info_exception('', phone_01) # 获取到用户名称为空的异常提醒 username_text = self.user_center.get_name_null_text() self.assertEqual('请输入用户名称',username_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 name_null_only_text = self.user_center.get_user_info()['name'] self.assertNotEqual(name_null_only_text, '') # 获取修改后的当前用户电话 phone01 = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone01,phone_01) # 用户名输入正确、电话为空 name_01 = '孙燕妮测试用户' self.user_center.edit_user_info_exception(name_01, '') # 获取到电话为空的异常提醒 phone_null_text = self.user_center.get_phone_null_text() self.assertEqual('请输入正确的手机号码',phone_null_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 name01 = self.user_center.get_user_info()['name'] self.assertNotEqual(name01, name_01) # 获取修改后的当前用户电话 phone02 = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone02, '') # 3.验证用户名称、电话长度限制 long_char = 'fsaffsdafsadfvczxfsdsafdfasdfasdfsdfsdfasdfasdffffffff' long_tel = '123456789456' short_tel = '1234567894' # 用户名输入超出字符长度限制、电话输入正确 tel = '13582698666' self.user_center.edit_user_info_exception(long_char, tel) # 获取到用户名超长的异常提醒 username_long_text = self.user_center.get_username_long_text() self.assertEqual('用户名称不能大于50个字符',username_long_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 name03 = self.user_center.get_user_info()['name'] self.assertNotEqual(name03, long_char) # 获取修改后的当前用户电话 phone03 = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone03, tel) # 用户名输入正确、电话输入超出长度限制 name_04 = '孙燕妮测试' self.user_center.edit_user_info_exception(name_04, long_tel) # 获取到电话输入超长的异常提醒 long_tel_text = self.user_center.get_phone_exception_text() self.assertEqual('请输入正确的手机号码',long_tel_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 name04 = self.user_center.get_user_info()['name'] self.assertNotEqual(name04, name_04) # 获取修改后的当前用户电话 phone04 = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone04, long_tel) # 用户名输入正确、电话输入低于正常限制 name_05 = '孙燕妮测试' self.user_center.edit_user_info_exception(name_05, short_tel) # 获取到电话输入超长的异常提醒 short_tel_text = self.user_center.get_phone_exception_text() self.assertEqual('请输入正确的手机号码', short_tel_text) # 关闭修改资料弹框 self.user_center.click_close_edit_info() # 获取修改后的当前用户名 name05 = self.user_center.get_user_info()['name'] self.assertNotEqual(name05, name_05) # 获取修改后的当前用户电话 phone05 = self.user_center.get_user_info()['tel'] self.assertNotEqual(phone05, short_tel) # 退出登录 self.user_center.logout()
class TestCase04UserManageEditUser(unittest.TestCase): # 测试用户管理修改用户 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.user_management = UserManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.user_management_read_csv = UserManagementReadCsv() self.driver.set_window_max() 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_edit_user(self): # 通过csv测试修改用户功能 csv_file = self.user_management_read_csv.read_csv('edit_user_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: edit_user_info = { "account": row[0], "password": row[1], "search_key": row[2], "edit_user_name": row[3], "edit_user_phone": row[4], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(edit_user_info['account'], edit_user_info['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql(edit_user_info['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入用户管理 self.user_management.click_user_manage() # 查找用户testAddUser2 self.user_management.search_user(edit_user_info['search_key']) # 获取页面查找结果 search_user_name_01 = self.user_management.get_search_result_one() # 查询数据库获取搜索结果 user_info_00 = self.user_management.get_search_result_by_sql(edit_user_info['account'], edit_user_info['search_key']) user_name_00 = user_info_00[0] user_tel_00 = user_info_00[1] self.assertEqual(search_user_name_01, user_name_00) # 点击修改 self.user_management.click_edit_user() # 切入内层frame self.user_management.switch_to_2_frame() # 获取当前显示的用户名称是否与未修改前一致 current_user_name_01 = self.user_management.get_current_user_name() self.assertEqual(search_user_name_01, current_user_name_01) # 获取显示的用户手机号码是否与未修改前一致 current_user_tel_01 = self.user_management.get_current_user_tel() self.assertEqual(user_tel_00, current_user_tel_01) # 输入用户名称 self.user_management.input_add_user_name(edit_user_info['edit_user_name']) # 输入用户手机号码 self.user_management.input_add_user_phone(edit_user_info['edit_user_phone']) # 点击取消 self.user_management.click_add_user_dismiss() # 数据库查询是否修改失败 user_info_01 = self.user_management.get_search_result_by_sql(edit_user_info['account'], edit_user_info['search_key']) user_name_01 = user_info_01[0] user_tel_01 = user_info_01[1] self.assertEqual(user_name_00, user_name_01) self.assertEqual(user_tel_00, user_tel_01) # 点击修改 self.user_management.click_edit_user() # 切入内层frame self.user_management.switch_to_2_frame() # 获取当前显示的角色名称是否与未修改前一致 current_user_name_02 = self.user_management.get_current_user_name() self.assertEqual(search_user_name_01, current_user_name_02) # 获取显示的角色描述是否与未修改前一致 current_user_tel_02 = self.user_management.get_current_user_tel() self.assertEqual(user_tel_00, current_user_tel_02) # 输入用户名称 self.user_management.input_add_user_name(edit_user_info['edit_user_name']) # 输入用户手机号码 self.user_management.input_add_user_phone(edit_user_info['edit_user_phone']) # 点击关闭按钮 self.user_management.click_add_user_close() # 数据库查询是否修改失败 user_info_02 = self.user_management.get_search_result_by_sql(edit_user_info['account'], edit_user_info['search_key']) user_name_02 = user_info_02[0] user_tel_02 = user_info_02[1] self.assertEqual(user_name_00, user_name_02) self.assertEqual(user_tel_00, user_tel_02) # 点击修改 self.user_management.click_edit_user() # 切入内层frame self.user_management.switch_to_2_frame() # 获取当前显示的角色名称是否与未修改前一致 current_user_name_03 = self.user_management.get_current_user_name() self.assertEqual(search_user_name_01, current_user_name_03) # 获取显示的角色描述是否与未修改前一致 current_user_tel_03 = self.user_management.get_current_user_tel() self.assertEqual(user_tel_00, current_user_tel_03) # 输入用户名称 self.user_management.input_add_user_name(edit_user_info['edit_user_name']) # 输入用户手机号码 self.user_management.input_add_user_phone(edit_user_info['edit_user_phone']) # 点击保存按钮 self.user_management.click_add_user_save() # 数据库查询是否修改成功 user_info_03 = self.user_management.get_search_result_by_sql(edit_user_info['account'], edit_user_info['edit_user_name']) user_name_03 = user_info_03[0] user_tel_03 = user_info_03[1] self.assertNotEqual(user_name_00, user_name_03) self.assertNotEqual(user_tel_00, user_tel_03) # 跳出外层frame self.user_management.switch_to_default_content() # 退出登录 self.user_center.logout() csv_file.close()
class TestCase05OrgManageEditOrgException(unittest.TestCase): # 测试部门管理修改公司部门异常情况 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() 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_edit_org_exception(self): # 通过csv测试修改公司部门功能异常情况 # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) # 点击进入部门管理 self.organize_management.click_org_manage() # 查找test00000部门 search_key = '00000' self.organize_management.search_org(search_key) # 获取页面查找结果 search_org_name_01 = self.organize_management.get_search_result_one() # 查询数据库获取搜索结果 org_info_00 = self.organize_management.get_search_result_by_sql(log_in_account, search_key) org_name_00 = org_info_00[0] sup_org_name_00 = org_info_00[1] org_tel_00 = org_info_00[2] self.assertEqual(search_org_name_01, org_name_00) csv_file = self.user_center_read_csv.read_csv('edit_org_info_exception.csv') csv_data = csv.reader(csv_file) for row in csv_data: edit_org_info_exception = { "edit_org_name": row[0], "edit_org_tel": row[1], "exception_text": row[2], } # 点击修改 self.organize_management.click_edit_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 获取当前显示的部门名称是否与未修改前一致 current_org_name_01 = self.organize_management.get_current_org_name() self.assertEqual(search_org_name_01, current_org_name_01) # 获取显示的所属上级是否与未修改前一致 current_sup_org = self.organize_management.get_current_sup_org_name() self.assertEqual(sup_org_name_00, current_sup_org) # 获取显示的联系方式是否与未修改前一致 current_org_tel = self.organize_management.get_current_org_tel() self.assertEqual(org_tel_00, current_org_tel) # 修改部门名称 self.organize_management.edit_org_name(edit_org_info_exception['edit_org_name']) # 修改联系方式 self.organize_management.edit_org_tel(edit_org_info_exception['edit_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 修改(保存) self.organize_management.click_org_modify_button() # 获取异常提示语 exception_text = self.organize_management.get_edit_org_exception_text() self.assertEqual(edit_org_info_exception['exception_text'],exception_text) # 数据库查询是否修改失败 org_info = self.organize_management.get_search_result_by_sql(log_in_account, search_key) org_name = org_info[0] org_tel = org_info[2] self.assertNotEqual(edit_org_info_exception['edit_org_name'], org_name) self.assertNotEqual(edit_org_info_exception['edit_org_tel'], org_tel) # 跳出内层frame self.organize_management.switch_to_parent_content() # 关闭 self.organize_management.click_org_modify_close() csv_file.close() # 跳出外层frame self.organize_management.switch_to_default_content() # 退出登录 self.user_center.logout()
class TestCase01OrgManageAddOrg(unittest.TestCase): # 测试部门管理新增公司部门 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() 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_add_org(self): # 通过csv测试新增公司部门功能 csv_file = self.user_center_read_csv.read_csv('add_org_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_org_info = { "account": row[0], "password": row[1], "add_org_name": row[2], "add_org_tel": row[3], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(add_org_info['account'], add_org_info['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( add_org_info['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入部门管理 self.organize_management.click_org_manage() # 点击新增公司部门 self.organize_management.click_add_org() # 验证上级部门是否显示正确 sup_org_name = self.organize_management.get_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_user_sup_org_by_sql( add_org_info['account']) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 选择上级部门 self.organize_management.choose_sup_org() # 填写新增部门名称 self.organize_management.input_add_org_name( add_org_info['add_org_name']) # 填写联系方式 self.organize_management.input_add_org_tel( add_org_info['add_org_tel']) # 点击取消 self.organize_management.click_add_org_dismiss() # 从数据库查询验证未新增成功 new_org_name_01 = self.organize_management.get_add_org_by_sql( add_org_info['account']) self.assertNotEqual(new_org_name_01, add_org_info['add_org_name']) self.driver.wait(1) # 点击新增公司部门 self.organize_management.click_add_org() # 验证上级部门是否显示正确 sup_org_name = self.organize_management.get_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_user_sup_org_by_sql( add_org_info['account']) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 选择上级部门 self.organize_management.choose_sup_org() # 填写新增部门名称 self.organize_management.input_add_org_name( add_org_info['add_org_name']) # 填写联系方式 self.organize_management.input_add_org_tel( add_org_info['add_org_tel']) # 点击关闭按钮 self.organize_management.click_add_org_close() # 从数据库查询验证未新增成功 new_org_name_02 = self.organize_management.get_add_org_by_sql( add_org_info['account']) self.assertNotEqual(new_org_name_02, add_org_info['add_org_name']) self.driver.wait(1) # 点击新增公司部门 self.organize_management.click_add_org() # 验证上级部门是否显示正确 sup_org_name = self.organize_management.get_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_user_sup_org_by_sql( add_org_info['account']) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 选择上级部门 self.organize_management.choose_sup_org() # 填写新增部门名称 self.organize_management.input_add_org_name( add_org_info['add_org_name']) # 填写联系方式 self.organize_management.input_add_org_tel( add_org_info['add_org_tel']) # 点击保存按钮 self.organize_management.click_add_org_save() # 跳出最外层frame self.organize_management.switch_to_default_content() # 从数据库查询验证新增成功 new_org_name_03 = self.organize_management.get_add_org_by_sql( add_org_info['account']) self.assertEqual(new_org_name_03, add_org_info['add_org_name']) self.driver.wait(1) # 退出登录 self.user_center.logout() csv_file.close()
class TestCase06UserCenterFeedback(unittest.TestCase): # 测试用户中心意见反馈 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() 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_user_center_feedback(self): '''通过csv测试用户中心意见反馈功能''' data = ["部门管理", "设备", "贷款客户", "车辆监控中心", "统计报表", "设置"] csv_file = self.user_center_read_csv.read_csv('user_feedback_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: user_feedback_info = { "account": row[0], "passwd": row[1], "type": row[2], "content": row[3], "linkman": row[4], "phone": row[5], } # 打开风控首页-登录页 self.base_page.open_page() # 输入用户信息进行登录 self.login_page.user_login(user_feedback_info["account"], user_feedback_info["passwd"]) self.driver.wait(1) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( user_feedback_info['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 验证模块 module = self.user_center.get_module_name() print(module) self.assertEqual(data, module, "用户账号登录,模块显示错误") self.driver.wait(10) # 进入意见反馈 self.user_center.click_feedback() # 提交反馈信息 self.user_center.choose_problem_type(user_feedback_info['type']) self.user_center.input_problem_content( user_feedback_info['content']) self.user_center.input_linkman(user_feedback_info['linkman']) self.user_center.input_phone(user_feedback_info['phone']) self.user_center.click_submit() # 获取提交反馈信息成功提示语 text = self.user_center.get_feedback_success_text() self.assertEqual('意见反馈成功', text) # 从数据库获取反馈信息验证是否提交成功 feedback_info = self.user_center.get_feedback_info_by_sql( user_feedback_info['account']) print(feedback_info) self.assertEqual(user_feedback_info['account'], feedback_info[0]) self.assertEqual(user_feedback_info['type'], feedback_info[1]) self.assertEqual(user_feedback_info['content'], feedback_info[2]) self.assertEqual(user_feedback_info['linkman'], feedback_info[3]) self.assertEqual(user_feedback_info['phone'], feedback_info[4]) # # 成功退出系统 sleep(2) self.user_center.logout() csv_file.close()
class TestCase06OrgManageViewOrg(unittest.TestCase): # 测试部门管理查看公司部门 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() 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_view_org(self): # 通过csv测试查看公司部门功能 # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) # 点击进入部门管理 self.organize_management.click_org_manage() csv_file = self.user_center_read_csv.read_csv('view_org_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: view_org_info = { "view_org_name": row[0], "view_org_tel": row[1], } # 点击查看公司部门 self.organize_management.click_view_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 验证所属上级是否显示正确 sup_org_name = self.organize_management.get_current_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_belong_to_superior_org_by_sql( log_in_account) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 编辑公司/部门名称 self.organize_management.edit_org_name( view_org_info['view_org_name']) # 编辑联系方式 self.organize_management.edit_org_tel( view_org_info['view_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 取消 self.organize_management.click_org_modify_dismiss() # 从数据库查询验证未修改成功 current_org_info_01 = self.organize_management.get_current_org_info_by_sql( log_in_account) edit_org_name_01 = current_org_info_01[0] edit_org_tel_01 = current_org_info_01[1] self.assertNotEqual(edit_org_name_01, view_org_info['view_org_name']) self.assertNotEqual(edit_org_tel_01, view_org_info['view_org_tel']) self.driver.wait(1) # 点击查看公司部门 self.organize_management.click_view_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 验证所属上级是否显示正确 sup_org_name = self.organize_management.get_current_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_belong_to_superior_org_by_sql( log_in_account) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 编辑公司/部门名称 self.organize_management.edit_org_name( view_org_info['view_org_name']) # 编辑联系方式 self.organize_management.edit_org_tel( view_org_info['view_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 关闭 self.organize_management.click_org_modify_close() # 从数据库查询验证未修改成功 current_org_info_02 = self.organize_management.get_current_org_info_by_sql( log_in_account) edit_org_name_02 = current_org_info_02[0] edit_org_tel_02 = current_org_info_02[1] self.assertNotEqual(edit_org_name_02, view_org_info['view_org_name']) self.assertNotEqual(edit_org_tel_02, view_org_info['view_org_tel']) self.driver.wait(1) # 点击查看公司部门 self.organize_management.click_view_org() # 切入内层frame self.organize_management.switch_to_2_frame() # 验证所属上级是否显示正确 sup_org_name = self.organize_management.get_current_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_belong_to_superior_org_by_sql( log_in_account) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 编辑公司/部门名称 self.organize_management.edit_org_name( view_org_info['view_org_name']) # 编辑联系方式 self.organize_management.edit_org_tel( view_org_info['view_org_tel']) # 跳出内层frame self.organize_management.switch_to_parent_content() # 修改(保存) self.organize_management.click_org_modify_button() # 从数据库查询验证修改成功 current_org_info_03 = self.organize_management.get_current_org_info_by_sql( log_in_account) edit_org_name_03 = current_org_info_03[0] edit_org_tel_03 = current_org_info_03[1] self.assertEqual(edit_org_name_03, view_org_info['view_org_name']) self.assertEqual(edit_org_tel_03, view_org_info['view_org_tel']) self.driver.wait(1) # 跳出外层frame self.organize_management.switch_to_default_content() csv_file.close() # 退出登录 self.user_center.logout()
class TestCase08OrgManageDeleteOrg(unittest.TestCase): # 测试部门管理删除公司部门 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() 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_delete_org(self): # 通过csv测试删除公司部门功能 # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) # 点击进入部门管理 self.organize_management.click_org_manage() csv_file = self.user_center_read_csv.read_csv('delete_org.csv') csv_data = csv.reader(csv_file) for row in csv_data: delete_org = { "org_name": row[0], } # 按名称查找部门 self.organize_management.search_org(delete_org['org_name']) # 点击删除 self.organize_management.click_delete_org() # 跳出frame self.organize_management.switch_to_default_content() # 取消 self.organize_management.delete_org_dismiss() # 切入frame self.organize_management.switch_to_1_frame() # 点击删除 self.organize_management.click_delete_org() # 跳出frame self.organize_management.switch_to_default_content() # 关闭 self.organize_management.delete_org_close() # 切入frame self.organize_management.switch_to_1_frame() # 点击删除 self.organize_management.click_delete_org() # 跳出frame self.organize_management.switch_to_default_content() # 确认 self.organize_management.delete_org_accept() # 数据库查找验证部门是否删除成功 # 数据库查找部门 org_name_after_delete = self.organize_management.get_search_result_orgname_by_sql( log_in_account, '') self.assertNotIn(delete_org['org_name'], org_name_after_delete) # 切入frame self.organize_management.switch_to_1_frame() csv_file.close() # 跳出frame self.organize_management.switch_to_default_content() # 退出登录 self.user_center.logout()
class TestCase01OrgManageAddRole(unittest.TestCase): # 测试角色管理新增角色 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() 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_add_role(self): # 通过csv测试新增角色功能 csv_file = self.role_management_read_csv.read_csv('add_role.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_role = { "account": row[0], "password": row[1], "add_role_name": row[2], "add_role_description": row[3], "add_role_limit": row[4], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(add_role['account'], add_role['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( add_role['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入角色管理 self.role_management.click_role_manage() # 点击创建角色 self.role_management.click_add_role() # 切入内层frame self.role_management.switch_to_2_frame() # 输入角色名称 self.role_management.input_add_role_name(add_role['add_role_name']) # 输入角色描述 self.role_management.input_add_role_description( add_role['add_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( add_role['add_role_limit']) # 点击取消 self.role_management.click_add_role_dismiss() # 从数据库查询验证角色未创建成功 new_role_name_01 = self.role_management.get_add_role_by_sql( add_role['account']) self.assertNotEqual(new_role_name_01, add_role['add_role_name']) self.driver.wait(1) # 点击创建角色 self.role_management.click_add_role() # 切入内层frame self.role_management.switch_to_2_frame() # 输入角色名称 self.role_management.input_add_role_name(add_role['add_role_name']) # 输入角色描述 self.role_management.input_add_role_description( add_role['add_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( add_role['add_role_limit']) # 点击关闭按钮 self.role_management.click_add_role_close() # 从数据库查询验证角色未创建成功 new_role_name_02 = self.role_management.get_add_role_by_sql( add_role['account']) self.assertNotEqual(new_role_name_02, add_role['add_role_name']) self.driver.wait(1) # 点击创建角色 self.role_management.click_add_role() # 切入内层frame self.role_management.switch_to_2_frame() # 输入角色名称 self.role_management.input_add_role_name(add_role['add_role_name']) # 输入角色描述 self.role_management.input_add_role_description( add_role['add_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( add_role['add_role_limit']) # 点击保存按钮 self.role_management.click_add_role_save() # 跳出最外层frame self.role_management.switch_to_default_content() # 从数据库查询验证角色创建成功 new_role_name_03 = self.role_management.get_add_role_by_sql( add_role['account']) self.assertEqual(new_role_name_03, add_role['add_role_name']) self.driver.wait(1) # 退出登录 self.user_center.logout() csv_file.close()
class TestCase03UserCenterModifyPassword(unittest.TestCase): # 测试个人中心修改密码 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.driver.set_window_max() 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_user_center_modify_password(self): # 通过csv测试修改密码功能 csv_file = self.user_center_read_csv.read_csv( 'user_to_modify_password.csv') csv_data = csv.reader(csv_file) for row in csv_data: user_to_modify_password = { "account": row[0], "old_passwd": row[1], "new_passwd": row[2], } # 打开途强在线首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(user_to_modify_password['account'], user_to_modify_password['old_passwd']) # 修改密码 self.user_center.click_edit_password() self.user_center.input_old_password( user_to_modify_password['old_passwd']) self.user_center.input_new_password( user_to_modify_password['new_passwd']) self.user_center.input_password_again( user_to_modify_password['new_passwd']) # 确认 self.user_center.click_edit_password_confirm() self.driver.wait() # 用旧密码登录,验证提示 self.login_page.user_login(user_to_modify_password['account'], user_to_modify_password['old_passwd']) exception_text = self.login_page.get_exception_text() self.assertEqual('登录密码验证错误', exception_text) self.driver.wait() # 用新密码登录,验证是否修改成功 self.login_page.user_login(user_to_modify_password['account'], user_to_modify_password['new_passwd']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( user_to_modify_password['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 退出登录 self.user_center.logout() csv_file.close()
class TestCase01LoginSuccess(unittest.TestCase): # 测试用户账号登录成功 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() 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_user_login_by_csv(self): '''通过csv测试用户账户成功登录和成功退出功能''' data = ["部门管理", "设备", "贷款客户", "车辆监控中心", "统计报表", "设置"] csv_file = self.log_in_page_read_csv.read_csv('login_account.csv') csv_data = csv.reader(csv_file) for row in csv_data: user_to_login = { "account": row[0], "passwd": row[1], } # 打开风控首页-登录页 self.base_page.open_page() # 输入用户信息进行登录 self.login_page.user_login(user_to_login["account"], user_to_login["passwd"]) self.driver.wait(1) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql( user_to_login['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 验证模块 module = self.user_center.get_module_name() print(module) self.assertEqual(data, module, "用户账号登录,模块显示错误") # 取消退出系统 sleep(2) self.user_center.logout_dismiss() # 关闭退出系统弹框 sleep(2) self.user_center.logout_close() # 成功退出系统 sleep(2) self.user_center.logout() # 再次登录判断是否成功退出到登录页并登录成功 self.login_page.user_login(user_to_login["account"], user_to_login["passwd"]) # # 成功退出系统 sleep(2) self.user_center.logout() csv_file.close()
class TestCase03LoginWithRememberMe(unittest.TestCase): # 测试登录时记住密码 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.driver.set_window_max() 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_user_login_exception(self): '''测试登录时记住密码''' # 打开风控首页-登录页 self.base_page.open_page() # 登录时勾选“记住我”复选框 self.login_page.account_input('syntest') self.login_page.password_input('jimi123') self.login_page.remember_me() self.login_page.login_button_click() self.driver.wait() # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql('syntest') print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 成功退出系统 sleep(2) self.user_center.logout() # 输入用户名 self.login_page.account_input('syntest') # 点击密码输入框 self.login_page.click_password() self.driver.wait() # 验证退出系统后“记住我”复选框是否是已勾选状态 box_status = self.login_page.check_remember_me() self.assertEqual(True, box_status, '记住密码失败') self.driver.wait() # 输入用户名,不输入密码直接点击登录 self.login_page.login_button_click() self.driver.wait() # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql('syntest') print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 成功退出系统 sleep(2) self.user_center.logout() # 输入用户名 self.login_page.account_input('syntest') # 点击密码输入框 self.login_page.click_password() # 验证退出系统后“记住我”复选框是否是已勾选状态 box_status = self.login_page.check_remember_me() self.assertEqual(True, box_status, '记住密码失败') self.driver.wait() # 输入用户名,取消勾选“记住我”复选框,输入密码再次登录 self.login_page.account_input('syntest') # 点击密码输入框 self.login_page.click_password() self.driver.wait(2) # 取消勾选“记住我”复选框 self.login_page.remember_me() # 验证“记住我”复选框是否是未勾选状态 box_status = self.login_page.check_remember_me() self.assertEqual(False, box_status, '取消记住密码失败') # 点击登录 self.login_page.login_button_click() self.driver.wait() # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql('syntest') print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 成功退出系统 sleep(2) self.user_center.logout() # 输入用户名 self.login_page.account_input('syntest') # 点击密码输入框 self.login_page.click_password() # 验证退出系统后“记住我”复选框是否是未勾选状态 box_status = self.login_page.check_remember_me() self.assertEqual(False, box_status, '取消记住密码失败')
class TestCase06RoleManageDeleteRole(unittest.TestCase): # 测试角色管理删除角色 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() 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_delete_role(self): # 通过csv测试删除角色功能 csv_file = self.role_management_read_csv.read_csv('delete_role.csv') csv_data = csv.reader(csv_file) for row in csv_data: delete_role = { "account": row[0], "passwd": row[1], "delete_role_name": row[2], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(delete_role['account'], delete_role['passwd']) # 点击进入角色管理 self.role_management.click_role_manage() # 按名称查找角色 self.role_management.search_role(delete_role['delete_role_name']) # 点击删除 self.role_management.click_delete_role() # 跳出frame self.role_management.switch_to_default_content() # 点击取消 self.role_management.delete_role_dismiss() # 切入frame self.role_management.switch_to_1_frame() # 点击删除 self.role_management.click_delete_role() # 跳出frame self.role_management.switch_to_default_content() # 点击关闭 self.role_management.delete_role_close() # 切入frame self.role_management.switch_to_1_frame() # 点击删除 self.role_management.click_delete_role() # 跳出frame self.role_management.switch_to_default_content() # 点击确认 self.role_management.delete_role_accept() # 数据库查找验证部门是否删除成功 # 数据库查找角色 role_name_after_delete = self.role_management.get_search_result_rolename_by_sql( delete_role['account'], '') self.assertNotIn(delete_role['delete_role_name'], role_name_after_delete) # 退出登录 self.user_center.logout() csv_file.close()
class TestCase01UserManageAddUser(unittest.TestCase): # 测试用户管理新增用户 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.user_management = UserManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.user_management_read_csv = UserManagementReadCsv() self.driver.set_window_max() 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_add_user(self): # 通过csv测试新增用户功能 csv_file = self.user_management_read_csv.read_csv('add_user.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_user = { "account": row[0], "password": row[1], "add_user_name": row[2], "add_login_user": row[3], "add_login_passwd": row[4], "add_user_phone": row[5], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.user_login(add_user['account'], add_user['password']) # 判断登录成功后招呼栏的用户名是否正确 username = self.user_center.get_username() # 从数据库获取登录账号的用户名 account_info = self.user_center.get_account_info_by_sql(add_user['account']) print(account_info) account_name = account_info[1] self.assertEqual(account_name, username, '登录成功后招呼栏的用户名错误') # 点击进入用户管理 self.user_management.click_user_manage() # 点击新增用户 self.user_management.click_add_user() # 切入内层frame self.user_management.switch_to_2_frame() # 输入新增用户名 self.user_management.input_add_user_name(add_user['add_user_name']) # 输入登陆账号 self.user_management.input_add_login_user(add_user['add_login_user']) # 输入登录密码 self.user_management.input_add_login_passwd(add_user['add_login_passwd']) # 输入手机号码 self.user_management.input_add_user_phone(add_user['add_user_phone']) # 分配角色 self.user_management.input_add_user_role() # 选择所属公司部门 self.user_management.choose_add_user_org() # 点击取消 self.user_management.click_add_user_dismiss() # 从数据库查询验证角色未创建成功 new_user_account_01 = self.user_management.get_add_user_by_sql(add_user['account']) self.assertNotEqual(new_user_account_01, add_user['add_login_user']) self.driver.wait(1) # 点击新增用户 self.user_management.click_add_user() # 切入内层frame self.user_management.switch_to_2_frame() # 输入新增用户名 self.user_management.input_add_user_name(add_user['add_user_name']) # 输入登陆账号 self.user_management.input_add_login_user(add_user['add_login_user']) # 输入登录密码 self.user_management.input_add_login_passwd(add_user['add_login_passwd']) # 输入手机号码 self.user_management.input_add_user_phone(add_user['add_user_phone']) # 分配角色 self.user_management.input_add_user_role() # 选择所属公司部门 self.user_management.choose_add_user_org() # 点击关闭按钮 self.user_management.click_add_user_close() # 从数据库查询验证角色未创建成功 new_user_account_02 = self.user_management.get_add_user_by_sql(add_user['account']) self.assertNotEqual(new_user_account_02, add_user['add_login_user']) self.driver.wait(1) # 点击新增用户 self.user_management.click_add_user() # 切入内层frame self.user_management.switch_to_2_frame() # 输入新增用户名 self.user_management.input_add_user_name(add_user['add_user_name']) # 输入登陆账号 self.user_management.input_add_login_user(add_user['add_login_user']) # 输入登录密码 self.user_management.input_add_login_passwd(add_user['add_login_passwd']) # 输入手机号码 self.user_management.input_add_user_phone(add_user['add_user_phone']) # 分配角色 self.user_management.input_add_user_role() # 选择所属公司部门 self.user_management.choose_add_user_org() # 点击保存按钮 self.user_management.click_add_user_save() # 跳出最外层frame self.user_management.switch_to_default_content() # 从数据库查询验证角色创建成功 new_add_account_03 = self.user_management.get_add_user_by_sql(add_user['account']) self.assertEqual(new_add_account_03, add_user['add_login_user']) self.driver.wait(1) # 退出登录 self.user_center.logout() csv_file.close()
class TestCase01LoanCustomerInput(unittest.TestCase): # 贷款客户信息录入 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.loan_customer = LoanCustomer(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.loan_customer_read_csv = LoanCustomerReadCsv() self.driver.set_window_max() 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_user_center_modify_info(self): # 通过csv测试贷款客户信息录入 csv_file = self.loan_customer_read_csv.read_csv('loan_customer_input_info.csv') csv_data = csv.reader(csv_file) for row in csv_data: loan_customer_input_info = { "name": row[0], "tel": row[1], "type": row[2], "ID": row[3], "sex": row[4], "com": row[5], "car_num": row[6], "model": row[7], "engi_num": row[8], "frame_num": row[9], "car_type": row[10], "loan_money": row[11], "loan_deadline": row[12], "current_balance": row[13], "pay_type": row[14], "pay_date": row[15], "contract_number": row[16], "imei": row[17], "install_address": row[18], "install_person": row[19], } # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() # 获取当前登录账号 log_in_account = self.user_center.get_login_account() print(log_in_account) # 从数据库获取登录账号的客户名称、电话 account_info = self.user_center.get_account_info_by_sql(log_in_account) print(account_info) # 获取修改资料里面的信息 user_info = self.user_center.get_user_info() # 断言 self.assertEqual(log_in_account, user_info['login_account']) self.assertEqual(account_info[1], user_info['name']) self.assertEqual(account_info[2], user_info['tel']) # 点击进入贷款客户录入 self.loan_customer.click_loan_customer_input() # 切入外层frame self.loan_customer.switch_to_1_frame() # 录入车主信息 # 录入车主姓名 self.loan_customer.input_owner_name(loan_customer_input_info['name']) # 录入车主电话 self.loan_customer.input_owner_tel(loan_customer_input_info['tel']) # 选择车主证件类型 self.loan_customer.choose_owner_ID_type(loan_customer_input_info['type']) # 输入车主证件号 self.loan_customer.input_owner_ID(loan_customer_input_info['ID']) # 选择车主性别 self.loan_customer.choose_owner_sex(loan_customer_input_info['sex']) # 选择车主贷款单位 self.loan_customer.choose_owner_loan_com(loan_customer_input_info['com']) # 保存 self.loan_customer.save_owner_info() # 验证是否保存成功 # 录入车辆信息 # 输入车牌号 self.loan_customer.input_car_num(loan_customer_input_info['car_num']) # 输入车型 self.loan_customer.input_car_model(loan_customer_input_info['model']) # 输入发动机号 self.loan_customer.input_car_engi_num(loan_customer_input_info['engi_num']) # 输入车架号 self.loan_customer.input_car_frame_num(loan_customer_input_info['frame_num']) # 选择车辆类型 self.loan_customer.choose_car_type(loan_customer_input_info['car_type']) # 保存车辆信息 self.loan_customer.save_car_info() # 验证是否保存成功 # 录入贷款信息 # 输入贷款日期 self.loan_customer.input_loan_date() # 输入贷款金额 self.loan_customer.input_loan_money(loan_customer_input_info['loan_money']) # 输入贷款期限 self.loan_customer.input_loan_deadline(loan_customer_input_info['loan_deadline']) # 输入应还金额 self.loan_customer.input_current_balance(loan_customer_input_info['current_balance']) # 选择还款方式 self.loan_customer.choose_pay_type(loan_customer_input_info['pay_type']) # 选择还款日 self.loan_customer.choose_pay_date(loan_customer_input_info['pay_date']) # 输入合同编号 self.loan_customer.input_contract_number(loan_customer_input_info['contract_number']) # 保存贷款信息 self.loan_customer.save_loan_info() # 验证是否保存成功 # 录入安装设备 # 点击安装设备 self.loan_customer.click_install_dev() # 输入Imei self.loan_customer.input_dev_imei(loan_customer_input_info['imei']) # 选择安装时间 self.loan_customer.choose_install_time() # 输入安装地址 self.loan_customer.input_install_address(loan_customer_input_info['install_address']) # 输入安装人员 self.loan_customer.input_install_person(loan_customer_input_info['install_person']) # 保存安装信息 self.loan_customer.save_install_info() # 跳出frame1 self.loan_customer.switch_out_frame1() # 验证是否保存成功 # 退出登录 self.user_center.logout() csv_file.close()
class TestCase03OrgManageAddOrgException2(unittest.TestCase): # 测试部门管理新增公司部门功能异常情况-部门名称已存在 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.organize_management = OrganizeManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.organize_management_read_csv = OrganizeManagementReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_add_org_exception2(self): # 通过csv测试新增公司部门功能异常情况-部门名称已存在 # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) csv_file = self.user_center_read_csv.read_csv( 'add_org_info_exception2.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_org_info_exception = { "add_org_name": row[0], "add_org_tel": row[1], "exception_text": row[2], } # 点击进入部门管理 self.organize_management.click_org_manage() # 点击新增公司部门 self.organize_management.click_add_org() # 验证上级部门是否显示正确 sup_org_name = self.organize_management.get_sup_org_name() # 数据库查询当前登录账户的上级部门 sup_org_name_by_aql = self.organize_management.get_user_sup_org_by_sql( log_in_account) self.assertEqual(sup_org_name, sup_org_name_by_aql) # 选择上级部门 self.organize_management.choose_sup_org() # 填写新增部门名称 self.organize_management.input_add_org_name( add_org_info_exception['add_org_name']) # 填写联系方式 self.organize_management.input_add_org_tel( add_org_info_exception['add_org_tel']) # 点击保存按钮 self.organize_management.click_add_org_save() # 跳出最外层frame self.organize_management.switch_to_default_content() # 获取名称重复异常提示 text = self.organize_management.get_add_org_exception2() self.assertEqual(add_org_info_exception['exception_text'], text) # 切入外层frame self.organize_management.switch_to_1_frame() # 切入内层frame self.organize_management.switch_to_2_frame() # 关闭新增公司部门框 self.organize_management.click_add_org_close() # 跳出最外层frame self.organize_management.switch_to_default_content() # 从数据库查询验证新增失败 new_org_name = self.organize_management.get_add_org_by_sql( log_in_account) self.assertNotEqual(new_org_name, add_org_info_exception['add_org_name']) self.driver.wait(1) csv_file.close() # 退出登录 self.user_center.logout()
class TestCase02UserManageAddUserException1(unittest.TestCase): # 测试用户管理新增用户功能异常情况 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.user_management = UserManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.user_management_read_csv = UserManagementReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_add_user_exception1(self): # 通过csv测试新增用户功能异常情况 # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) csv_file = self.user_management_read_csv.read_csv('add_user_exception1.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_user_exception = { "add_user_name": row[0], "add_login_user": row[1], "add_login_passwd": row[2], "add_user_phone": row[3], "add_user_role":row[4], "exception_text": row[5], } # 点击进入用户管理 self.user_management.click_user_manage() # 点击新增用户 self.user_management.click_add_user() # 切入内层frame self.user_management.switch_to_2_frame() # 输入新增用户名 self.user_management.input_add_user_name(add_user_exception['add_user_name']) # 输入登陆账号 self.user_management.input_add_login_user(add_user_exception['add_login_user']) # 输入登录密码 self.user_management.input_add_login_passwd(add_user_exception['add_login_passwd']) # 输入手机号码 self.user_management.input_add_user_phone(add_user_exception['add_user_phone']) # 判断分配用户角色 if add_user_exception['add_user_role'] == '1': self.user_management.input_add_user_role() # 选择所属公司部门 self.user_management.choose_add_user_org() # 点击保存按钮 self.user_management.click_add_user_save() # 获取异常提示 text = self.user_management.get_add_user_exception1() self.assertEqual(add_user_exception['exception_text'], text) # 关闭新增用户框 self.user_management.click_add_user_close() # 跳出最外层frame self.user_management.switch_to_default_content() # 从数据库查询验证新增失败 new_user_name = self.user_management.get_add_user_by_sql(log_in_account) self.assertNotEqual(new_user_name, add_user_exception['add_user_name']) self.driver.wait(1) csv_file.close() # 退出登录 self.user_center.logout()
class TestCase02RoleManageAddRoleException1(unittest.TestCase): # 测试角色管理新增角色功能异常情况 def setUp(self): self.driver = AutomateDriver() self.base_url = self.driver.base_url self.base_page = BasePage(self.driver, self.base_url) self.login_page = LoginPage(self.driver, self.base_url) self.user_center = UserCenter(self.driver, self.base_url) self.role_management = RoleManagement(self.driver, self.base_url) self.log_in_page_read_csv = LogInPageReadCsv() self.user_center_read_csv = UserCenterReadCsv() self.role_management_read_csv = RoleManagementReadCsv() self.driver.set_window_max() self.connect_sql = ConnectSql() self.driver.wait(1) self.driver.clear_cookies() self.driver.wait(1) # 打开风控首页-登录页 self.base_page.open_page() sleep(1) # 登录账号 self.login_page.test_user_login() def tearDown(self): self.driver.quit_browser() def test_add_role_exception1(self): # 通过csv测试新增角色功能异常情况 # 获取当前登录账户 log_in_account = self.user_center.get_login_account() print(log_in_account) csv_file = self.role_management_read_csv.read_csv( 'add_role_exception1.csv') csv_data = csv.reader(csv_file) for row in csv_data: add_role_exception = { "add_role_name": row[0], "add_role_description": row[1], "add_role_limit": row[2], "exception_text": row[3], } # 点击进入角色管理 self.role_management.click_role_manage() # 点击创建角色 self.role_management.click_add_role() # 切入内层frame self.role_management.switch_to_2_frame() # 输入角色名称 self.role_management.input_add_role_name( add_role_exception['add_role_name']) # 输入角色描述 self.role_management.input_add_role_description( add_role_exception['add_role_description']) # 选择角色权限 self.role_management.choose_add_role_limit( add_role_exception['add_role_limit']) # 点击保存按钮 self.role_management.click_add_role_save() # 获取异常提示 text = self.role_management.get_add_role_exception1() self.assertEqual(add_role_exception['exception_text'], text) # 关闭创建角色框 self.role_management.click_add_role_close() # 跳出最外层frame self.role_management.switch_to_default_content() # 从数据库查询验证新增失败 new_role_name = self.role_management.get_add_role_by_sql( log_in_account) self.assertNotEqual(new_role_name, add_role_exception['add_role_name']) self.driver.wait(1) csv_file.close() # 退出登录 self.user_center.logout()