Example #1
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()
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 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()
Example #4
0
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 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()