Beispiel #1
0
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 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()
Beispiel #3
0
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()
Beispiel #4
0
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 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()
Beispiel #6
0
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()
Beispiel #7
0
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 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 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()