Example #1
0
 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 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)
Example #3
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 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 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"], "付款账号长度不一致")
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()