Beispiel #1
0
class TestCase271AccountCenterModifyInfoException(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.clear_cookies()

    def test_modify_info_exception(self):
        "修改资料错误提示"

        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.driver.wait(1)
        # 点击招呼栏的修改资料
        self.account_center_page_navi_bar.click_modify_usr_info()

        csv_find = self.account_center_page_read_csv.read_csv(
            "modify_info_exception.csv")
        csv_data = csv.reader(csv_find)
        for row in csv_data:
            data = {
                "name": row[0],
                "phone": row[1],
                "email": row[2],
                "name_prompt": row[3],
                "phone_prompt": row[4],
                "email_prompt": row[5]
            }

            all_prompt = self.account_center_page_navi_bar.get_modify_info_exception_prompt(
                data)

            self.assertEqual(data["name_prompt"], all_prompt["name"],
                             "个人资料,客户名称错误提示语显示不一致")

            self.assertEqual(data["phone_prompt"], all_prompt["phone"],
                             "个人资料,电话错误提示语显示不一致")

            self.assertEqual(data["email_prompt"], all_prompt["email"],
                             "个人资料,邮箱错误提示语显示不一致")

        # 验证长度
        len = self.account_center_page_navi_bar.get_modifgy_info_element_len()
        self.assertEqual(20, len["phone_len"], "电话号码长度显示不一致")
        self.assertEqual(50, len["email_len"], "邮箱长度显示不一致")

        csv_find.close()
        # 关闭修改资料框
        self.account_center_page_navi_bar.cancel_modify_user_info()
        # 退出
        # self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
Beispiel #2
0
class TestCase801MessageCenterSearchMassage(unittest.TestCase):
    ###############################################################
    # # 测试 消息中心 消息搜索
    ###############################################################
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.message_center_page = MessageCenterPage(self.driver,
                                                     self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.help_page = HelpPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        self.base_page.open_page()
        self.log_in_base.log_in()

    def tearDown(self):
        self.driver.close_window()
        self.driver.quit_browser()

    def test_case_801_message_center_search_massage(self):
        user_account = self.log_in_base.get_log_in_account()
        # 点击消息中心
        self.message_center_page.click_message_center_button()

        csv_file = self.account_center_page_read_csv.read_csv(
            'message_center_search.csv')
        csv_data = csv.reader(csv_file)
        i = 1
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'imei': row[0],
                'massage_type': row[1],
                'is_read': row[2]
            }
            print(search_data)
            self.message_center_page.add_data_search_message_data(search_data)
            # 获取当前用户和下级用户的所有用户id
            all_user_id = self.help_page.get_all_user_id(user_account)
            # 获取数据库查询的条数
            sql_total = self.message_center_page.get_sql_total_search_center_massage(
                search_data, all_user_id)
            # 获取页面上的数据条数
            web_total = self.message_center_page.get_web_total_search_center_massage(
            )
            print('第%s次查询的数据库总数:%s' % (i, sql_total))
            print('第%s次查询的页面总数:%s' % (i, web_total))
            i += 1
            self.assertEqual(sql_total, web_total)

        csv_file.close()
class TestCase08AccountCenterVisualAccount(unittest.TestCase):

    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_visual_account = AccountCenterVisualAccountPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.assert_text = AssertText()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_visual_account(self):
        '''通过csv测试虚拟账户管理功能'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(2)
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.account_center_page_visual_account.enter_visual_account()

        csv_file = self.account_center_page_read_csv.read_csv('add_visual_account.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            acc_to_add = {
                "account": row[0],
                "passwd": row[1]
            }
            # 登录
            # 获取虚拟账户管理title
            visual_account_title = self.account_center_page_visual_account.get_visual_account_title()
            # 验证消息中心title是否正确显示
            self.assertIn(self.assert_text.account_center_page_virtual_account_manager(), visual_account_title,
                          "虚拟账户管理title有误!")

            # 添加虚拟账户
            self.account_center_page_visual_account.add_visual_account(acc_to_add["account"], acc_to_add["passwd"])
            state = self.account_center_page_visual_account.get_visual_account_limits_state()
            self.assertEqual(False, state["edit_data"], "修改数据默认勾选了")
            self.assertEqual(False, state["instruction"], "下发指令默认勾选了")
            # 保存
            self.account_center_page_visual_account.save_add_info()

            # 验证是否保存成功
            save_status = self.account_center_page_visual_account.get_save_status()
            self.assertIn(self.assert_text.account_center_page_operation_done(), save_status, "保存成功")
            self.driver.wait()

        csv_file.close()
class TestCase39AccountCenterOperCustLog(unittest.TestCase):
    """ 帮助--业务日志 """

    # author:邓肖斌
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_oper_cust_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        # 获取登录账号的用户名
        current_account = self.log_in_base.get_log_in_account()

        # 点击招呼栏-业务日志
        self.account_center_page_operation_log.click_help_button()
        self.help_page.click_business_log()
        # 判断当前页面是否正确跳转至业务日志页面
        expect_url = self.base_url + "/userFeedback/toHelp"
        self.assertEqual(expect_url, self.driver.get_current_url(), "当前页面跳转错误")

        i = 0

        csv_file = self.account_center_page_read_csv.read_csv(
            'search_cus_manager_log_data.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'search_type': row[0],
                'begin_time': row[1],
                'end_time': row[2],
                'more': row[3]
            }
            self.help_page.search_business_log(search_data)

            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect.cursor()

            # 执行sql脚本查询当前登录账号的userId,fullParent
            get_id_sql = \
                "select o.account,o.userId,o.fullParentId from user_info o where o.account = " \
                "'" + current_account + "' ;"
            cur.execute(get_id_sql)
            # 读取数据
            user_relation = cur.fetchall()
            # 遍历数据
            for row1 in user_relation:
                user_relation_id = {
                    "account": row1[0],
                    "userId": row1[1],
                    "fullParent": row1[2]
                }

                # 执行sql脚本,根据当前登录账号的userId,fullParent查询出当前账户的所有下级账户
                get_lower_account_sql = "select userId from user_info where fullParentId like" + \
                                        "'" + user_relation_id["fullParent"] + user_relation_id["userId"] + "%'" + ";"
                cur.execute(get_lower_account_sql)
                # 读取数据
                lower_account = cur.fetchall()
                lower_account_list = [user_relation_id["userId"]]
                for range1 in lower_account:
                    for range2 in range1:
                        lower_account_list.append(range2)
                lower_account_tuple = tuple(lower_account_list)
                get_total_sql = self.help_page_sql.business_log_sql(
                    lower_account_tuple, search_data)
                print(get_total_sql)
                cur.execute(get_total_sql)
                # 读取数据
                total_data = cur.fetchall()
                # 从数据tuple中获取最终查询记录统计条数
                total_list = []
                for range3 in total_data:
                    for range4 in range3:
                        total_list.append(range4)
                total = len(total_list)
                i += 1
                print('第%s次查询数据库的条数为:%s' % (i, total))
                web_total = self.help_page.get_current_customer_log()
                print('第%s次查询页面的条数是:%s' % (i, web_total))
                self.assertEqual(total, web_total)

            cur.close()
            connect.close()

        csv_file.close()
Beispiel #5
0
class TestCase49AccountCenterBillList(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_page = AccountCenterPage(self.driver,
                                                     self.base_url)
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_account_center_bill_list(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in_jimitest()
        self.account_center_page_navi_bar.click_account_center_button()
        account = self.log_in_base.get_log_in_account()
        # 点击账单按钮
        self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page.clcik_bill_button_in_account_info_page()

        csv_file = self.account_center_page_read_csv.read_csv('bill_list.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'date_type': row[0],
                'begin_time': row[1],
                'end_time': row[2],
                'imei': row[3],
                'telephone': row[4],
                'alarm_type': row[5],
                'result': row[6]
            }
            self.account_center_page.add_data_to_search_bill_list_in_bill_list_page(
                search_data)

            ## 获取数据库查询的条数
            sql_number = self.account_center_page.get_sql_number_after_click_search_button(
                account, search_data)
            # 获取页面上的条数
            web_number = self.account_center_page.get_web_number_after_click_search_button(
            )
            self.assertEqual(sql_number, web_number)
        csv_file.close()
class TestCase016AccountCenterFastSaleReset(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_change_page = AccountCenterChangePage(
            self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_fast_sale_reset(self):
        '''通过csv测试账户详情-快捷销售-删除设备、重置功能'''
        csv_file = self.account_center_page_read_csv.read_csv(
            'fast_sale_exact_find_and_sale.csv')
        csv_data = csv.reader(csv_file)

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        # self.log_in_base.log_in()
        self.log_in_base.log_in_with_csv("dzltest", "jimi123")
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()

        for row in csv_data:
            search_account = {
                "account": row[0],
                "device_imei": row[1],
                "imei_count": row[2],
                "selected_dev": row[2]
            }
            # 进入快捷销售页面
            sleep(1)
            # self.account_center_page_details.account_center_iframe()
            # self.account_center_page_details.fast_sales()

            self.account_center_change_page.switch_fast_sale_enable()
            self.account_center_change_page.switch_to_fast_sale_frame()
            # 查找账户
            self.account_center_page_details.fast_sales_find_account(
                search_account["account"])
            #点取消
            self.account_center_page_details.fast_sales_find_and_dis_add_device(
                "123123123")

            # 输入设备imei精确查找设备并添加
            self.account_center_page_details.fast_sales_find_and_add_device(
                search_account["device_imei"])
            self.driver.default_frame()
            self.driver.wait()

            #验证消息中的失败个数
            failure_count = self.account_center_page_details.get_device_prompt_failure_count(
            )
            list_failure_count = self.account_center_page_details.get_device_list_failure_count(
            )
            self.assertEqual(failure_count, list_failure_count,
                             "显示的失败个数与列表中的失败数不一致")

            #验证消息中的成功个数
            all_data = self.account_center_page_details.get_prompt_list_data()
            succeed_count = self.account_center_page_details.get_device_prompt_succeed_count(
            )
            self.account_center_page_details.click_prompt_close()
            self.account_center_change_page.switch_to_fast_sale_frame()
            list_count = self.account_center_page_details.get_list_succeed_count(
            )
            self.assertEqual(succeed_count, list_count, "成功添加的设备数不一致")

            #断言失败提示中的信息
            for s in range(list_failure_count):
                self.assertIsNotNone(all_data["imei"][s], "sim卡号为空")
                self.assertEqual("失败", all_data["state"][s], "存在不是失败的数据")
                self.assertIsNotNone(all_data["cause"][s], "失败原因中存在空数据")

            # 验证已选设备计数是否准确
            dev_num = self.account_center_page_details.get_selected_device_num(
            )
            self.assertEqual(list_count, dev_num, "已选设备个数不准确")
            # 删除列表中的设备
            self.account_center_page_details.delete_list_device()

            self.assertEqual(
                0, self.account_center_page_details.get_selected_device_num(),
                "删除设备后,已选设备数不是0")

            # 重置验证
            self.account_center_page_details.fast_sales_find_and_add_device(
                search_account["device_imei"])
            self.driver.default_frame()
            self.account_center_page_details.click_prompt_close()
            self.account_center_change_page.switch_to_fast_sale_frame()
            self.account_center_page_details.choose_account_expired_time("三个月")
            self.driver.wait(1)
            self.account_center_page_details.reset_device()

            self.assertEqual(
                0, self.account_center_page_details.get_list_succeed_count(),
                "重置后,列表中已添加的设备的数不是0")
            self.assertEqual(
                0, self.account_center_page_details.get_selected_device_num(),
                "重置后,已选设备数不是0")
            self.assertEqual(
                self.assert_text2.account_center_please_select(),
                self.account_center_page_details.get_account_expired_time_text(
                ), "重置后,用户到期时间不是请选择")

            self.driver.default_frame()
        csv_file.close()
class TestCase37AccountCenterSearchLowerClientVerify(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_change_page = AccountCenterChangePage(
            self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_search_lower_client(self):
        '''通过csv测试账户详情--下级客户--查找不同账号功能'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()
        self.account_center_change_page.switch_fast_sale_enable()
        self.account_center_change_page.switch_to_fast_sale_frame()

        csv_file = self.account_center_page_read_csv.read_csv(
            'search_different_account.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            search_account = {"account": row[0]}

            # 查找账户
            search_result = self.account_center_page_details.subordinate_account_search(
                search_account["account"])
            if type(search_result) is str:
                self.assertIn(
                    self.assert_text.account_center_page_no_data_text(),
                    search_result, "搜索结果为暂无数据时,提示不一致")

            else:
                for subscript in range(len(search_result)):
                    text = search_result[subscript].split("(")[0]
                    self.assertIn(search_account["account"], text, "搜索结果不一致")

            self.driver.wait()

        # 直接选择用户
        for user in range(8):
            self.account_center_page_details.fast_sales()
            self.account_center_page_details.click_list_subordinate_client(
                user + 1)

        # 验证enter键输入
        self.account_center_page_details.fast_sales()
        self.account_center_page_details.search_subordinate_client_click_enter(
            "1234")

        self.driver.wait()
        self.driver.default_frame()
        csv_file.close()
class TestCase07AccountCenterMsgSearch(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_msg_center = AccountCenterMsgCenterPage(
            self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.search_sql = SearchSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_msg_search(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()

        # self.driver.switch_to_frame('x,//*[@id="usercenterFrame"]')
        # 获取登录账号的用户名
        current_account = self.log_in_base.get_log_in_account()
        #self.driver.default_frame()

        # 进入消息中心
        self.account_center_page_msg_center.enter_msg_center()
        self.driver.wait(10)

        # 进入iframe
        # self.account_center_page_msg_center.message_center_iframe()
        # 获取消息中心title
        msg_center_title = self.account_center_page_msg_center.get_msg_center_title(
        )
        # 验证消息中心title是否正确显示
        self.assertIn(
            self.assert_text.account_center_page_message_center_text(),
            msg_center_title, "消息中心title有误!")

        csv_file = self.account_center_page_read_csv.read_csv(
            'search_massage_data.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {'imei': row[0], 'type': row[1], 'status': row[2]}
            # 搜索
            self.account_center_page_operation_log.add_data_to_search_massages(
                search_data)
            connect1 = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect1.cursor()
            # 执行sql脚本查询当前登录账号的userId,fullParent
            get_id_sql = "select o.account,o.userId,o.fullParentId from user_info o where o.account = '" + current_account + "';"
            cur.execute(get_id_sql)
            # 读取数据
            user_relation = cur.fetchall()
            # 遍历数据
            for row in user_relation:
                user_relation_id = {
                    "account": row[0],
                    "userId": row[1],
                    "fullParent": row[2]
                }

                # 执行sql脚本,根据当前登录账号的userId,fullParent查询出当前账户的所有下级账户
                get_lower_account_sql = "select userId from user_info where fullParentId like" + \
                                        "'" + user_relation_id["fullParent"] + user_relation_id["userId"] + "%'" + ";"
                cur.execute(get_lower_account_sql)
                # 读取数据
                lower_account = cur.fetchall()
                lower_account_list = [user_relation_id["userId"]]
                for range1 in lower_account:
                    for range2 in range1:
                        lower_account_list.append(range2)
                self.lower_account_tuple = tuple(lower_account_list)
            cur.close()
            connect1.close()

            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect.cursor()
            get_total_sql = self.search_sql.search_massage_sql(
                self.lower_account_tuple, search_data)
            print(get_total_sql)
            cur.execute(get_total_sql)
            # 读取数据
            total_data = cur.fetchall()
            # 从数据tuple中获取最终查询记录统计条数
            total_list = []
            for range1 in total_data:
                for range2 in range1:
                    total_list.append(range2)
            total = len(total_list)
            print('本次查询数据库的条数为:%s' % total)
            web_total = self.account_center_page_operation_log.get_msg_number()
            print('本次查询页面的条数是:%s' % web_total)
            self.assertEqual(total, web_total)
            cur.close()
            connect.close()
        csv_file.close()
Beispiel #9
0
class TestCase201UserCenterModifyInfo(unittest.TestCase):
    # 测试个人中心修改资料
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.user_center_page = UserCenterPage(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(1)
        # 登录账号
        self.log_in_base.log_in()

    def tearDown(self):
        self.driver.quit_browser()

    def test_user_center_modify_info(self):
        # 通过csv测试修改资料功能
        self.account_center_page_navi_bar.click_account_center_button()

        csv_file = self.account_center_page_read_csv.read_csv('user_to_modify_info.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            user_to_modify_info = {
                "username": row[0],
                "phone": row[1],
                "email": row[2]
            }
            # 获取当前登录账号
            log_in_account = self.log_in_base.get_log_in_account()

            # 从数据库获取登录账号的客户名称、电话、邮箱
            account_info = self.user_center_page.get_account_info(log_in_account)
            print(account_info)
            # 点击个人中心 - 修改资料
            self.user_center_page.click_user_center_button()
            self.user_center_page.click_modify_user_info()
            # 获取修改资料里面的信息
            user_account = self.user_center_page.get_user_account_in_modify_page()
            user_name = self.user_center_page.get_user_name_in_modify_page()
            user_phone = self.user_center_page.get_user_phone_in_modify_page()
            user_email = self.user_center_page.get_user_email_in_modify_page()
            # 断言
            self.assertEqual(log_in_account, user_account)
            self.assertEqual(account_info[0], user_name)
            self.assertEqual(account_info[1], user_phone)
            self.assertEqual(account_info[2], user_email)

            # 填写客户名称、电话、邮箱
            self.user_center_page.add_data_to_modify_info(user_to_modify_info)
            # 点击取消的按钮
            self.user_center_page.click_cancel_button()
            # 从数据库获取登录账号的客户名称、电话、邮箱
            account_info1 = self.user_center_page.get_account_info(log_in_account)
            print(account_info1)
            self.assertEqual(account_info, account_info1)

            # 点击个人中心 - 修改资料
            self.user_center_page.click_user_center_button()
            self.user_center_page.click_modify_user_info()
            # 获取修改资料里面的信息
            user_account = self.user_center_page.get_user_account_in_modify_page()
            user_name = self.user_center_page.get_user_name_in_modify_page()
            user_phone = self.user_center_page.get_user_phone_in_modify_page()
            user_email = self.user_center_page.get_user_email_in_modify_page()
            # 断言
            self.assertEqual(log_in_account, user_account)
            self.assertEqual(account_info1[0], user_name)
            self.assertEqual(account_info1[1], user_phone)
            self.assertEqual(account_info1[2], user_email)
            # 点击关闭 # 填写客户名称、电话、邮箱
            self.user_center_page.add_data_to_modify_info(user_to_modify_info)
            self.user_center_page.click_close_button()
            # 从数据库获取登录账号的客户名称、电话、邮箱
            account_info2 = self.user_center_page.get_account_info(log_in_account)
            print(account_info2)
            self.assertEqual(account_info, account_info2)

            # 点击个人中心 - 修改资料
            self.user_center_page.click_user_center_button()
            self.user_center_page.click_modify_user_info()
            # 获取修改资料里面的信息
            user_account = self.user_center_page.get_user_account_in_modify_page()
            user_name = self.user_center_page.get_user_name_in_modify_page()
            user_phone = self.user_center_page.get_user_phone_in_modify_page()
            user_email = self.user_center_page.get_user_email_in_modify_page()
            # 断言
            self.assertEqual(log_in_account, user_account)
            self.assertEqual(account_info2[0], user_name)
            self.assertEqual(account_info2[1], user_phone)
            self.assertEqual(account_info2[2], user_email)
            # 填写客户名称、电话、邮箱
            self.user_center_page.add_data_to_modify_info(user_to_modify_info)
            # 点击确认
            self.user_center_page.click_ensure_button()
            # 从数据库获取登录账号的客户名称、电话、邮箱
            account_info3 = self.user_center_page.get_account_info(log_in_account)
            print(account_info3)
            web_data = [user_to_modify_info['username'], user_to_modify_info['phone'], user_to_modify_info['email']]
            self.assertEqual(account_info3, web_data)
            # 点击个人中心 - 修改资料
            self.user_center_page.click_user_center_button()
            self.user_center_page.click_modify_user_info()
            # 获取修改资料里面的信息
            user_account = self.user_center_page.get_user_account_in_modify_page()
            user_name = self.user_center_page.get_user_name_in_modify_page()
            user_phone = self.user_center_page.get_user_phone_in_modify_page()
            user_email = self.user_center_page.get_user_email_in_modify_page()
            # 断言
            self.assertEqual(log_in_account, user_account)
            self.assertEqual(account_info3[0], user_name)
            self.assertEqual(account_info3[1], user_phone)
            self.assertEqual(account_info3[2], user_email)
            self.user_center_page.click_close_button()
        csv_file.close()
Beispiel #10
0
class TestCase010AccountCenterModifyPasswd(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_modify_info(self):
        '''通过csv测试修改密码功能'''
        csv_file = self.account_center_page_read_csv.read_csv(
            'user_to_modify_passwd.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            user_to_modify_passwd = {
                "account": row[0],
                "old_passwd": row[1],
                "new_passwd": row[2],
            }

            # 打开途强在线首页-登录页
            self.base_page.open_page()
            # 登录账号
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["old_passwd"])
            self.driver.wait()
            self.account_center_page_navi_bar.click_account_center_button()
            # 招呼栏修改资料
            modify_status = self.account_center_page_navi_bar.modify_user_passwd(
                user_to_modify_passwd["old_passwd"],
                user_to_modify_passwd["new_passwd"])
            # 判断是否修改成功
            # self.assertEqual("密码修改成功", modify_status, "密码修改失败")
            # 点击确定
            self.account_center_page_navi_bar.modify_passwd_success_comfrim()
            # 判断点击确定后是否关闭弹框并回到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "修改成功后页面跳转错误")

            # 使用旧密码登录
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["old_passwd"])
            self.assertEqual(self.assert_text.log_in_page_password_error(),
                             self.login_page.get_exception_text(),
                             "旧密码登录,提示不一致")

            # 新密码登录账号
            self.login_page.user_login(user_to_modify_passwd["account"],
                                       user_to_modify_passwd["new_passwd"])

            self.driver.wait()
            self.account_center_page_navi_bar.click_account_center_button()
            # 招呼栏修改资料
            modify_status = self.account_center_page_navi_bar.modify_user_passwd(
                user_to_modify_passwd["new_passwd"],
                user_to_modify_passwd["old_passwd"])
            # 判断是否修改成功
            # self.assertEqual("密码修改成功", modify_status, "密码修改失败")
            # 点击确定
            self.account_center_page_navi_bar.modify_passwd_success_comfrim()
            # 判断点击确定后是否关闭弹框并回到登录页
            self.assertEqual(self.base_url + "/",
                             self.driver.get_current_url(), "修改成功后页面跳转错误")
        csv_file.close()
class TestCase29AccountCenterVisualAccountException(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.visual_account_page = AccountCenterVisualAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def test_visual_account_exception(self):
        '''虚拟账户管理,异常错误提示'''

        # 登录
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入虚拟账户管理
        self.visual_account_page.enter_visual_account()
        # 点击添加
        self.visual_account_page.click_add_button()

        csv_file = self.account_center_page_read_csv.read_csv(
            'visual_account_exception.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            data = {
                "name": row[0],
                "new_password": row[1],
                "new_password2": row[2],
                "name_prompt": row[3],
                "new_pwd_prompt": row[4],
                "new_pwd2_prompt": row[5]
            }
            # 虚拟账号添加与编辑方法
            prompt = self.visual_account_page.get_visu_account_error_prompt(
                "add", data["new_password"], data["new_password2"],
                data["name"])
            self.assertEqual(data["name_prompt"], prompt["name_error_prompt"],
                             "虚拟账号,登陆名称错误提示语显示不一致")

            self.assertEqual(data["new_pwd_prompt"],
                             prompt["pwd_error_prompt"], "虚拟账号,密码错误提示语显示不一致")

            self.assertEqual(data["new_pwd2_prompt"],
                             prompt["pwd2_error_prompt"],
                             "虚拟账号,确认密码错误提示语显示不一致")

        # 验证密码输入长度
        self.assertEqual(
            16, self.visual_account_page.get_visual_add_and_edit_len(),
            "密码限制长度显示不一致")
        # 点取消
        self.visual_account_page.dis_save_add_info()
        csv_file.close()
        self.driver.wait(1)
        # 退出登录
        # self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
Beispiel #12
0
class TestCase52VirtualUserLimitVerification(unittest.TestCase):
    # 虚拟账号权限
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.virtual_user_limit_page = VirtualUserLimitsPage(
            self.driver, self.base_url)
        self.read_csv = AccountCenterPageReadCsv()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.base_page.open_page()

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_52_virtual_user_limit_verification(self):
        csv_file = self.read_csv.read_csv('virtual_user_limits.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            data = {
                'v_account': row[0],
                'v_password': row[1],
                'v_limit': row[2]
            }
            self.log_in_base.log_in()
            # 点击工作台,进入首页
            self.virtual_user_limit_page.click_workbench_button()
            # 点击进入设置-虚拟账号管理
            self.virtual_user_limit_page.click_set_up_and_virtual_user_management(
            )
            # 点击添加按钮
            self.virtual_user_limit_page.click_add_virtual_user_button()
            # 填写账号、密码、确认密码
            self.virtual_user_limit_page.input_virtual_account_password(data)
            # 选择虚拟账号的权限
            self.virtual_user_limit_page.select_virtual_user_limit(
                data['v_limit'])
            # 点击确定
            self.virtual_user_limit_page.click_ensure_add_virtual_user_button()
            # 退出
            self.virtual_user_limit_page.logout()
            # 登录创建的虚拟账号
            self.log_in_base.log_in_with_csv(data['v_account'],
                                             data['v_password'])
            self.virtual_user_limit_page.click_workbench_button()
            # 获取抬头列表个数
            name_list = []
            list_number = self.virtual_user_limit_page.get_list_number_in_look_up(
            )
            for n in range(list_number):
                name_list.append(
                    self.virtual_user_limit_page.get_per_name_in_list(n).split(
                        ' ')[1])
            print(name_list)
            self.assertNotIn(data['v_limit'], name_list)
            self.virtual_user_limit_page.logout()
            self.log_in_base.log_in()
            # 点击虚拟账号管理
            self.virtual_user_limit_page.click_set_up_and_virtual_user_management(
            )
            # 点击删除-确定
            self.virtual_user_limit_page.click_delete_button_and_ensure()
            # 再次退出
            self.virtual_user_limit_page.logout()
        csv_file.close()
class TestCase28AccountCenterModifyPasswordException(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.base_page.open_page()
        self.driver.set_window_max()
        self.driver.clear_cookies()

    def test_modify_password_exception(self):
        "修改密码异常操作,错误提示"

        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        self.driver.wait(1)
        # 点击招呼栏的修改密码
        self.account_center_page_navi_bar.click_modify_usr_password()

        csv_find = self.account_center_page_read_csv.read_csv(
            "modify_password_exception.csv")
        csv_data = csv.reader(csv_find)
        for row in csv_data:
            data = {
                "old_password": row[0],
                "new_password": row[1],
                "new_password2": row[2],
                "old_pwd_prompt": row[3],
                "new_pwd_prompt": row[4],
                "new_pwd2_prompt": row[5]
            }

            all_prompt = self.account_center_page_navi_bar.get_modify_pwd_exception_prompt(
                data)

            self.assertEqual(data["old_pwd_prompt"], all_prompt["old_Pwd"],
                             "修改密码,旧密码错误提示语显示不一致")

            self.assertEqual(data["new_pwd_prompt"], all_prompt["new_Pwd"],
                             "修改密码,新密码提示语显示不一致")

            self.assertEqual(data["new_pwd2_prompt"], all_prompt["new_Pwd2"],
                             "修改密码,确认新密码提示语显示不一致")

            try:
                self.assertEqual("原密码不正确", all_prompt["text"], "修改密码,提示语显示不一致")
            except:
                print("没有原密码不正确的提示")

        csv_find.close()
        # 关闭修改资料框
        self.account_center_page_navi_bar.click_password_cancel()
        self.driver.wait(1)
        # 退出
        self.account_center_page_navi_bar.usr_logout()

    def tearDown(self):
        self.driver.quit_browser()
class TestCase460918AccountCenterRefillCardTransfer(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_transfer_refill_card_succeed(self):
        '''充值卡--充值卡转移成功'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        # self.log_in_base.log_in_with_csv("kankan111", "jimi123")
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()
        self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page_refill_card.click_refill_card()

        csv_file = self.account_center_page_read_csv.read_csv(
            'transfer_refill_card.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            data = {
                "account": row[0],
                "year_number": row[1],
                "lifetime_number": row[2],
                "username": row[3]
            }
            #获取头部数量
            top_quantity = self.account_center_page_refill_card.get_refill_card_page_top_quantity(
            )

            #点转移
            self.account_center_page_refill_card.click_refill_card_transfer_button(
            )
            #获取数量
            transfer_quantity = self.account_center_page_refill_card.get_refill_card_transfer_quantity(
            )
            self.assertEqual(top_quantity["year_number"],
                             transfer_quantity["year_quantity"] + "张",
                             "页面顶部与转移中显示的年卡不一致")
            self.assertEqual(top_quantity["lifetime_number"],
                             transfer_quantity["lifetime_quantity"] + "张",
                             "页面顶部与转移中显示的终身卡不一致")

            #充值卡转移-取消
            self.account_center_page_refill_card.refill_card_transfer_cancel()
            self.account_center_page_refill_card.click_refill_card_transfer_button(
            )
            # 充值卡转移
            self.account_center_page_refill_card.refill_card_transfer(
                data["account"], data["year_number"], data["lifetime_number"])
            # 获取转移提示
            information = self.account_center_page_refill_card.get_refill_card_transfer_data_information(
            )

            statu = self.account_center_page_refill_card.get_operate_status()
            self.assertEqual(
                self.assert_text2.account_center_refill_card_transfer_succeed(
                ), statu, "充值卡转移失败")

            # 验证转移数据与转移提示中的信息
            self.assertEqual(data["username"], information["target_user"],
                             "转移提示中,目标账号显示不一致")
            self.assertEqual(data["year_number"] + " 张",
                             information["year_number"], "转移提示中,一年充值卡显示不一致")
            self.assertEqual(data["lifetime_number"] + " 张",
                             information["lifetime_number"],
                             "转移提示中,终身充值卡显示不一致")

        csv_file.close()
Beispiel #15
0
class TestCase40AccountCenterOperLoginLog(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_login_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        self.log_in_base.click_account_center_button()
        # 获取登录账号的用户名
        current_account = self.log_in_base.get_log_in_account()

        # 点击招呼栏-业务日志
        self.account_center_page_operation_log.click_help_button()
        self.help_page.click_log_in_log()
        # 判断当前页面是否正确跳转至业务日志页面
        expect_url = self.base_url + "/userFeedback/toHelp"
        self.assertEqual(expect_url, self.driver.get_current_url(), "当前页面跳转错误")

        i = 0

        csv_file = self.account_center_page_read_csv.read_csv('search_log_in_log_data.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'account': row[0],
                'begin_time': row[1],
                'end_time': row[2]
            }
            self.help_page.search_login_log(search_data)

            connect = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect.cursor()

            # 执行sql脚本查询当前登录账号的userId,fullParent
            get_id_sql = "select o.userId from user_info o where o.account = '" + current_account + "' ;"
            cur.execute(get_id_sql)
            # 读取数据
            user_relation = cur.fetchall()
            # 遍历数据
            for row1 in user_relation:
                user_relation_id = {
                    "userId": row1[0]
                }
                get_total_sql = self.help_page_sql.search_log_in_sql(user_relation_id['userId'], search_data)
                print(get_total_sql)
                cur.execute(get_total_sql)
                # 读取数据
                total_data = cur.fetchall()
                # 从数据tuple中获取最终查询记录统计条数
                total_list = []
                for range1 in total_data:
                    for range2 in range1:
                        total_list.append(range2)
                total = len(total_list)
                i += 1
                print('第%s次查询数据库的条数为:%s' % (i, total))
                web_total = self.help_page.get_current_login_log()
                print('第%s次查询页面的条数是:%s' % (i, web_total))
                self.assertEqual(total, web_total)

            cur.close()
            connect.close()

        csv_file.close()
class TestCase450919AccountCenterRefillCardRefillRecordSearch(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='CHROME')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.connect_sql = ConnectSql()
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_refill_record_search(self):
        '''充值卡-充值记录--搜索'''
        csv_file = self.account_center_page_read_csv.read_csv('search_refill_record_data.csv')
        csv_data = csv.reader(csv_file)

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入充值卡页面
        # self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page_refill_card.click_refill_card()

        # 验证页面顶部我的账号
        my_account = self.account_center_page_refill_card.get_title_display_account()
        self.assertIn(self.account_center_page_refill_card.get_current_login_account(), my_account, "登录账号显示一致")

        for row in csv_data:
            data = {
                "refill_type": row[0],
                "device_imei": row[1]

            }
            # 点击充值记录
            self.account_center_page_refill_card.click_refill_record()
            # 搜索
            count = self.account_center_page_refill_card.refill_record_search_data(data["refill_type"],
                                                                                   data["device_imei"])
            # 验证imei计数
            self.assertEqual(count["import_count"], int(count["add_count"]), "输入框中imei的计数显示错误")

            # 获取页面列表条数
            page_number = self.account_center_page_refill_card.get_refill_record_number()

            # 获取当前账号id
            sql_data = self.search_sql.search_current_account_data(my_account)

            connect1 = self.connect_sql.connect_tuqiang_sql()
            # 创建数据库游标
            cur = connect1.cursor()
            # 获取数据库条数
            get_sql = self.search_sql.search_refill_record_sql(sql_data[0], data)
            print(get_sql)
            cur.execute(get_sql)
            # 读取数据
            total_data = cur.fetchall()
            # 从数据tuple中获取最终查询记录统计条数
            total_list = []
            for range1 in total_data:
                for range2 in range1:
                    total_list.append(range2)
            total = len(total_list)
            print('本次查询数据库的条数为:%s' % total)

            # 获取数据库条数
            self.assertEqual(total, page_number, "转移记录中,平台与sql搜索出来的数据条数不一致")
        # 点击充值记录
        self.account_center_page_refill_card.click_refill_record()
        # 获取设备有多少个分页
        total_page = self.account_center_page_refill_card.get_total_page_number_search_refill_record()
        print(total_page)
        if total_page[0] == 0:
            text = self.account_center_page_refill_card.get_refill_record_page_no_data_text()
            self.assertIn(self.assert_text.account_center_page_no_data_text(), text)

        elif total_page[0] == 1:
            up_page_class = self.account_center_page_refill_card.get_up_page_class_active_in_refill_search()
            self.assertEqual('active', up_page_class)

        else:
            for n in range(total_page[0]):
                self.account_center_page_refill_card.click_per_page(n)
                get_per_first_number = self.account_center_page_refill_card.get_per_frist_number_in_refill_search()
                self.assertEqual(get_per_first_number, str(10 * (n + 1) - 9))

            # 点击每页20条
            list = [20, 30, 50, 100]
            for m in list:
                self.account_center_page_refill_card.click_per_page_number_refill_record()
                page_number = self.account_center_page_refill_card.get_page_number_in_refill_record_search()
                print(page_number)
                self.assertEqual(int(total_page[1] / m) + 1, page_number)

        csv_file.close()
class TestCase51AccountCenterManageAndTelephoneAlarm(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_page = AccountCenterPage(self.driver,
                                                     self.base_url)
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_case_account_center_manage_and_telephone_alarm(self):
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in_jimitest()
        self.account_center_page_navi_bar.click_account_center_button()
        account = self.log_in_base.get_log_in_account()
        # 点击订单管理
        self.account_center_page.clcik_massage_and_telephone_alarm_button_in_account_info_page(
        )

        ## 进入账号详情的frame
        self.account_center_page.switch_to_massage_and_telephone_alarm_frame()

        csv_file = self.account_center_page_read_csv.read_csv(
            'massage_and_telephone_alarm.csv')
        csv_data = csv.reader(csv_file)

        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {'alarm_name': row[0], 'alarm_type': row[1]}
            self.account_center_page.add_data_to_search_massage_and_telephone_alarm_in_set_page(
                search_data)

            ## 获取数据库查询的条数
            sql_number = self.account_center_page.get_sql_number_after_click_massage_and_telephone_alarm_set_search_button(
                account, search_data)
            # 获取页面上的条数
            web_number = self.account_center_page.get_web_number_after_click_massage_and_telephone_alarm_search_button(
            )
            self.assertEqual(sql_number, web_number)
        csv_file.close()
        self.driver.default_frame()
class TestCase210UserCenterLoginLog(unittest.TestCase):
    # 测试登录日志查询
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.help_page = HelpPage(self.driver, self.base_url)
        self.account_center_page_operation_log = AccountCenterOperationLogPage(
            self.driver, self.base_url)
        self.help_page_sql = HelpPageSql()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.connect_sql = ConnectSql()
        self.connect_es = ConnectEs()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_user_center_login_log(self):
        self.base_page.open_page()
        self.log_in_base.log_in()
        sleep(3)
        current_handle = self.driver.get_current_window_handle()
        self.log_in_base.click_account_center_button()
        self.base_page.change_windows_handle(current_handle)

        # 获取登录账号的用户名
        current_account = self.log_in_base.get_log_in_account()

        # 点击招呼栏-业务日志
        self.account_center_page_operation_log.click_help_button()
        self.help_page.click_log_in_log()
        # 判断当前页面是否正确跳转至业务日志页面
        expect_url = self.base_url + "/userFeedback/toHelp"
        self.assertEqual(expect_url, self.driver.get_current_url(), "当前页面跳转错误")

        i = 0
        csv_file = self.account_center_page_read_csv.read_csv(
            'search_log_in_log_data.csv')
        csv_data = csv.reader(csv_file)
        is_header = True
        for row in csv_data:
            if is_header:
                is_header = False
                continue
            search_data = {
                'account': row[0],
                'begin_time': row[1],
                'end_time': row[2]
            }
            self.help_page.search_login_log(search_data)

            # 获取当前登录账号和下级账号全部的userid
            all_user_id = self.help_page.get_all_user_id(current_account)
            print(all_user_id)
            '''connect = self.connect_sql.connect_tuqiang_sql()
            cursor = connect.cursor()
            get_total_sql = self.help_page_sql.search_log_in_sql(all_user_id, search_data)
            cursor.execute(get_total_sql)
            total_list = cursor.fetchall()
            cursor.close()
            connect.close()'''
            # 连接Elastic search
            es = self.connect_es.connect_es()
            # 搜索的数据
            query_data = self.help_page.get_search_log_in_log_query_data(
                all_user_id, search_data)
            res_01 = es.search(index='userlogin_log_2',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            res_02 = es.search(index='userlogin_log_12',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            res_03 = es.search(index='userlogin_log_1',
                               body={
                                   'query': query_data,
                                   'size': 20000
                               })
            total = len(res_01['hits']['hits']) + len(
                res_02['hits']['hits']) + len(res_03['hits']['hits'])
            i += 1
            print('第%s次查询数据库的条数为:%s' % (i, total))
            web_total = self.help_page.get_current_login_log()
            print('第%s次查询页面的条数是:%s' % (i, web_total))
            if total != 0:
                total += 10
            self.assertEqual(total, web_total)

        csv_file.close()
class TestCase430918AccountCenterRefillCardApplyException(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.search_sql = SearchSql()
        self.assert_text = AssertText()
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_apply_refill_card_exception_verify(self):
        '''充值卡-申请记录--申请充值卡-异常验证'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入充值卡页面
        # self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page_refill_card.click_refill_card()
        # 点申请充值卡
        self.account_center_page_refill_card.click_apply_refill_card_button()

        csv_file = self.account_center_page_read_csv.read_csv(
            'apply_refill_card_exception.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            data = {
                "year": row[0],
                "lifetime": row[1],
                "name": row[2],
                "phone": row[3],
                "payment_account": row[4],
                "year_prompt1": row[5],
                "lifetime_prompt1": row[6],
                "name_prompt1": row[7],
                "phone_prompt1": row[8],
                "account_prompt1": row[9]
            }

            # 获取提示
            prompt = self.account_center_page_refill_card.get_apply_refill_card_exception_hint(
                data["year"], data["lifetime"], data["name"], data["phone"],
                data["payment_account"])

            self.assertIn(data["year_prompt1"], prompt["year_prompt2"],
                          "一年充值卡提示不一致")
            self.assertIn(data["lifetime_prompt1"],
                          prompt["lifetimet_prompt2"], "终身充值卡提示不一致")
            self.assertEqual(data["name_prompt1"], prompt["name_prompt2"],
                             "付款姓名提示不一致")
            self.assertEqual(data["phone_prompt1"], prompt["phone_prompt2"],
                             "付款手机号卡提示不一致")
            self.assertEqual(data["account_prompt1"],
                             prompt["account_prompt2"], "付款账号提示不一致")

        # 长度
        length = self.account_center_page_refill_card.get_apply_refill_card_len(
        )
        self.assertEqual(5, length["year_len"], "一年充值卡长度不一致")
        self.assertEqual(5, length["lifetime_len"], "终身充值卡长度不一致")
        self.assertEqual(20, length["name_len"], "姓名长度不一致")
        self.assertEqual(20, length["phone_len"], "手机号长度不一致")
        self.assertEqual(200, length["account_len"], "付款账号长度不一致")
Beispiel #20
0
class TestCase09AccountCenterVisuEditAndDel(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_visual_account = AccountCenterVisualAccountPage(
            self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_visu_edit_and_del(self):
        '''通过csv测试虚拟账户管理-编辑、删除功能'''
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录
        self.log_in_base.log_in()
        self.account_center_page_navi_bar.click_account_center_button()
        # 进入虚拟账户管理
        self.account_center_page_visual_account.enter_visual_account()
        csv_file = self.account_center_page_read_csv.read_csv(
            'add_visual_account.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            acc_to_add = {"account": row[0], "passwd": row[1]}
            # 添加虚拟账户
            self.account_center_page_visual_account.add_visual_account(
                acc_to_add["account"], acc_to_add["passwd"])
            # 取消添加
            self.account_center_page_visual_account.dis_save_add_info()
            self.driver.wait()

            # 编辑列表中的虚拟账户
            self.account_center_page_visual_account.edit_visu_account(
                acc_to_add["passwd"])
            # 验证是否保存成功
            save_status = self.account_center_page_visual_account.get_save_status(
            )
            self.assertIn(
                self.assert_text.account_center_page_operation_done(),
                save_status, "保存成功")
            self.account_center_page_visual_account.dis_edit()
            self.driver.wait(1)

            # 删除列表中的虚拟账户
            self.account_center_page_visual_account.del_visu_account()

            # 验证是否操作成功
            save_status = self.account_center_page_visual_account.get_save_status(
            )
            self.assertIn(
                self.assert_text.account_center_page_operation_done(),
                save_status, "操作成功")
            self.driver.wait()
        csv_file.close()
Beispiel #21
0
class TestCase01AccountCenterModifyInfo(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer()
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(self.driver, self.base_url)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.driver.clear_cookies()
        # 打开途强在线首页-登录页
        self.base_page.open_page()
        sleep(1)
        # 登录账号
        self.log_in_base.log_in()

    def tearDown(self):
        self.driver.quit_browser()

    def test_account_center_modify_info(self):
        '''通过csv测试修改资料功能'''
        self.account_center_page_navi_bar.click_account_center_button()

        csv_file = self.account_center_page_read_csv.read_csv('user_to_modify_info.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            user_to_modify_info = {
                "username": row[0],
                "phone": row[1],
                "email": row[2]
            }

            # 招呼栏修改资料
            save_status = self.account_center_page_navi_bar.modify_usr_info(user_to_modify_info["username"],
                                                                            user_to_modify_info["phone"],
                                                                            user_to_modify_info["email"])
            # 判断是否修改成功
            self.assertEqual(self.assert_text.account_center_page_operation_done(), save_status, "修改失败")

            #点击账户中心
            self.account_center_page_navi_bar.click_account_center_button()
            sleep(1)
            #获取详情中用户名跟电话

            phone = self.account_center_page_navi_bar.usr_info_phone()
            self.assertEqual(user_to_modify_info["phone"], phone, "电话号码不一致")
            break
        csv_file.close()

        # 点击关闭
        self.account_center_page_navi_bar.click_modify_usr_info()
        self.account_center_page_navi_bar.cancel_modify_user_info()

        # 点击取消
        self.account_center_page_navi_bar.click_modify_usr_info()
        self.account_center_page_navi_bar.close_modify_user_info()

        # 退出登录
        self.account_center_page_navi_bar.usr_logout()
Beispiel #22
0
class TestCase410918AccountCenterRefillCardAddApply(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_refill_card = AccountCenterRefillCardPage(
            self.driver, self.base_url)
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.assert_text2 = AssertText2()
        self.driver.set_window_max()
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_apply_refill_card(self):
        '''充值卡-申请记录--申请充值卡'''

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        # self.log_in_base.log_in_with_csv("dzltest", "jimi123")
        self.log_in_base.log_in()
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()

        # 进入充值卡页面
        # self.account_center_page_navi_bar.switch_to_chongzhi_card()
        self.account_center_page_refill_card.click_refill_card()

        csv_file = self.account_center_page_read_csv.read_csv(
            'apply_refill_card.csv')
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            data = {
                "year": row[0],
                "lifetime": row[1],
                "name": row[2],
                "phone": row[3],
                "payment_account": row[4]
            }
            # 验证页面顶部我的账号
            my_account = self.account_center_page_refill_card.get_title_display_account(
            )
            # 取消
            self.account_center_page_refill_card.apply_refill_card_cancel()

            # 验证账号
            self.account_center_page_refill_card.click_apply_refill_card_button(
            )
            apply_page_account = self.account_center_page_refill_card.get_refill_account(
            )
            self.assertEqual(my_account, apply_page_account, "充值账号显示不一致")

            # 添加充值卡
            self.account_center_page_refill_card.apply_refill_card_add(
                data["year"], data["lifetime"], data["name"], data["phone"],
                data["payment_account"])

            information = self.account_center_page_refill_card.get_applicant_information(
            )

            statu = self.account_center_page_refill_card.get_operate_status()
            self.assertEqual(
                self.assert_text2.account_center_refill_card_apply_succeed(),
                statu, "申请充值卡失败")

            # 验证添加数据与申请人信息
            self.assertEqual(apply_page_account,
                             information["applicant_account"],
                             "申请人信息中,充值账号显示不一致")
            self.assertEqual(data["year"] + "张", information["year"],
                             "申请人信息中,一年充值卡张数显示不一致")
            self.assertEqual(data["lifetime"] + "张", information["lifetime"],
                             "申请人信息中,终身充值卡张数显示不一致")
            self.assertEqual(data["name"], information["name"],
                             "申请人信息中,付款人姓名显示不一致")
            self.assertEqual(data["phone"], information["phone"],
                             "申请人信息中,充值联系方式显示不一致")
            self.assertEqual(data["payment_account"],
                             information["payment_account"],
                             "申请人信息中,付款账号显示不一致")

        csv_file.close()
class TestCase400830AccountCenterFastSaleEditAddFaility(unittest.TestCase):
    def setUp(self):
        self.driver = AutomateDriverServer(choose='chrome')
        self.base_url = self.driver.base_url
        self.base_page = BasePageServer(self.driver, self.base_url)
        self.login_page = LoginPage(self.driver, self.base_url)
        self.account_center_page_navi_bar = AccountCenterNaviBarPage(
            self.driver, self.base_url)
        self.account_center_page_details = AccountCenterDetailsPage(
            self.driver, self.base_url)
        self.assert_text = AssertText()
        self.driver.set_window_max()
        self.account_center_page_read_csv = AccountCenterPageReadCsv()
        self.log_in_base = LogInBaseServer(self.driver, self.base_page)
        self.driver.wait(1)
        self.driver.clear_cookies()
        self.driver.wait(1)

    def tearDown(self):
        self.driver.quit_browser()

    def test_fast_sale_edit_add_faility_succeed(self):
        '''通过csv测试账户详情-快捷销售-编辑设备名称和设备sim卡号'''
        csv_file = self.account_center_page_read_csv.read_csv(
            'fast_sale_edit_dev_data.csv')
        csv_data = csv.reader(csv_file)

        # 打开途强在线首页-登录页
        self.base_page.open_page()
        # 登录账号
        self.log_in_base.log_in_with_csv("dzltest", "jimi123")
        self.driver.wait(1)
        self.account_center_page_navi_bar.click_account_center_button()

        for row in csv_data:
            data = {
                "account": row[0],
                "device_imei": row[1],
                "selected_dev": row[2],
                "dev_name": row[3],
                "sim": row[4],
                "old_dev_name": row[5],
                "old_sim": row[6]
            }
            # 进入快捷销售页面
            self.account_center_page_details.account_center_iframe()
            self.account_center_page_details.fast_sales()

            # 查找账户
            self.account_center_page_details.fast_sales_find_account(
                data["account"])

            # 输入设备imei精确查找设备并添加
            self.account_center_page_details.fast_sales_find_and_add_device(
                data["device_imei"])
            self.driver.default_frame()
            self.driver.wait()
            # 关闭消息提示框
            try:
                self.account_center_page_details.click_prompt_close()
            except:
                print("没有消息弹框提示")

            # self.account_center_page_details.account_center_iframe()
            # 获取列表设备imei,名称和sim卡号
            info = self.account_center_page_details.get_list_add_equipment_user_and_sim(
            )

            # 验证设备名称和sim卡的元素长度
            self.assertEqual(
                50,
                self.account_center_page_details.get_fast_sale_dev_name_len(),
                "设备名称长度不一致")
            self.assertEqual(
                20,
                self.account_center_page_details.get_fast_sale_dev_sim_len(),
                "设备sim卡长度不一致")

            # 编辑设备名称和sim卡号
            self.account_center_page_details.edit_list_add_equipment(
                info["imei"], data["dev_name"], data["sim"])

            # 点击用户到期时间
            self.account_center_page_details.account_center_iframe()
            self.account_center_page_details.choose_account_expired_time(
                data["selected_dev"])
            sleep(1)
            # 销售
            self.account_center_page_details.sale_button()
            # 通过弹出框状态验证是否销售成功
            sale_status_text = self.account_center_page_details.get_sale_status(
            )
            self.assertIn(
                self.assert_text.account_center_page_operation_done(),
                sale_status_text, "销售失败")
            self.driver.default_frame()
            sleep(2)

            # 点击设备管理
            dev_data = self.account_center_page_details.get_dev_manage_equipment_user_and_sim(
                info["imei"])
            for i in range(len(dev_data["dev_imei"])):
                if data["dev_name"] != "":
                    self.assertEqual(info["imei"][i] + data["dev_name"],
                                     dev_data["dev_name"][i], "设备名称与期望不一致")
                else:
                    self.assertIn(info["imei"][i][10:],
                                  dev_data["dev_name"][i],
                                  "为空时,设备名称不存在后五位imei")

                self.assertEqual(data["sim"], dev_data["dev_sim"][i],
                                 "sim卡与期望不一致")

            # 改设备数据
            self.account_center_page_details.dev_manage_edit_equipment_user_and_sim(
                data["old_dev_name"], data["old_sim"])

            break