def test_all_game(self, hw_name, bank_type):
        if hw_name == '磨耳朵':
            if self.home.wait_check_home_page(True):
                # PC端先删除后布置磨耳朵游戏
                web_driver = GetWebDriver()
                web_driver.set_driver()
                AssignGrindEarHomeWork().assign_grind_ear_hwk_operate()
                web_driver.quit_web()
        nickname = 0
        try:
            user_info = UserCenterPage().get_user_info()
            stu_id = user_info[0]
            nickname = user_info[-1]
            # HomeworkDataHandle().delete_student_homework_data(stu_id)
        except:
            self.base_assert.except_error("删除作业记录失败")

        if self.home.wait_check_home_page():
            self.home.click_hk_tab(index=2)
            self.library.enter_into_game(hw_name, bank_type)
            bank_name_list = []
            self.forLoop_find_bankType(bank_type, nickname, bank_name_list)
            if self.library.wait_check_bank_list_page():
                self.library.click_back_up_button()
                if self.library.wait_check_homework_list_page():
                    self.library.click_back_up_button()
Ejemplo n.º 2
0
    def test_recite_word_again(self):
        """下一年级单词"""
        if self.home.wait_check_home_page():  # 页面检查点
            stu_info = UserCenterPage().get_user_info()
            stu_id = stu_info[0]
            if self.home.wait_check_home_page():
                print('进入主界面')
                self.home.click_hk_tab(1)  # 点击 背单词
                """
                进入单词本有两种状况:
                1、脚本test002运行未完成,出现继续图标
                2、脚本test002运行完成,
                """
                if self.word.wait_check_start_page():  # 页面检查点

                    if self.word.wait_check_start_page():  # 页面检查点
                        self.word.word_start_button()  # 点击 Go按钮
                        print("开始单词本练习")
                        if self.result.wait_check_next_grade():
                            self.result.confirm_button()
                            if self.word.wait_check_game_page():
                                self.word.play_word_book(stu_id)
                                self.result.result_page_handle()

                    elif self.word.wait_check_continue_page():  # 页面检查点
                        print("脚本test002 运行失败 ,此脚本无法继续执行!")
    def test_have_different_teacher(self):
        """测试拥有不同老师,不同班级的情况"""
        if self.home.wait_check_home_page():
            test_class_num = VANCLASS_ID
            van_num = test_class_num.copy()
            QuitAddClass().apply_class_operate(van_num)
            web_driver = Driver()
            web_driver.set_driver()
            for x in TEACHER_ACCOUNT:
                AssignWord().assign_wordbook_operate(test_class_num, x, STU_PASSWORD)
                LoginWebPage().logout_operate()

            web_driver.quit_web()
            if self.home.wait_check_home_page():
                stu_info = UserCenterPage().get_user_info()
                stu_id = stu_info[0]
                teacher_trans_ids = WordDataHandlePage().get_teacher_words_trans_id(stu_id)
                if self.home.wait_check_home_page():
                    self.home.click_hk_tab(1)  # 点击 背单词
                    if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                        self.word_rebuild.word_start_button()  # 点击 Go按钮
                        word_info = FlashCard().scan_game_operate(is_exit=True)
                        WorldBookPublicPage().check_word_order_is_right(teacher_trans_ids, word_info[0])
                    if self.word_rebuild.wait_check_continue_page():
                        self.word_rebuild.click_back_up_button()
 def test_have_class(self, test_class_num):
     """测试有老师的情况, 一个班或者多个班的情况"""
     if self.home.wait_check_home_page():
         van_num = test_class_num.copy()
         QuitAddClass().apply_class_operate(van_num)
         web_driver = GetWebDriver()
         web_driver.set_driver()
         AssignWord().assign_wordbook_operate(test_class_num,
                                              TEACHER_ACCOUNT[0],
                                              STU_PASSWORD)
         web_driver.quit_web()
         if self.home.wait_check_home_page():
             stu_info = UserCenterPage().get_user_info()
             stu_id = stu_info[0]
             teacher_trans_ids = WordDataHandlePage(
             ).get_teacher_words_trans_id(stu_id)
             if self.home.wait_check_home_page():
                 self.home.click_hk_tab(1)  # 点击 背单词
                 if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                     self.word_rebuild.word_start_button()  # 点击 Go按钮
                     word_info = FlashCard().scan_game_operate(is_exit=True)
                     WorldBookPublicPage().check_word_order_is_right(
                         teacher_trans_ids, word_info[0])
                 if self.word_rebuild.wait_check_continue_page():
                     self.word_rebuild.click_back_up_button()
Ejemplo n.º 5
0
    def test_homework_ranking(self):
        self.login.app_status()  # 判断APP当前状态

        if self.home.wait_check_home_page():  # 页面检查点
            self.login.enter_user_info_page()  # 由 主界面 进入个人信息页
            if UserInfoPage().wait_check_page():
                nickname = UserInfoPage().nickname()  # 获取昵称
                self.homework.back_up_button()  # 返回个人中心页面
                if UserCenterPage().wait_check_user_center_page():
                    self.home.click_tab_hw()  # 进入主界面

                    if self.home.wait_check_home_page():  # 页面检查点
                        self.home.click_test_vanclass()  # 班级tab
                        if self.van.wait_check_page():  # 页面检查点

                            van = self.van.vanclass_name()  # 班级名称
                            for i in range(len(van)):
                                if van[i].text == gv.CLASS_NAME:
                                    van[i].click()  # 进入班级详情页
                                    break
                            if self.van.wait_check_vanclass_page(gv.CLASS_NAME):  # 页面检查点
                                self.van.vanclass_hw()  # 点击 本班作业 tab
                                if self.detail.wait_check_page(gv.CLASS_NAME):  # 页面检查点
                                    print('%s 本班作业:' % gv.CLASS_NAME)
                                    if self.van.wait_check_empty_tips():
                                        print('暂无数据')
                                    else:
                                        all_hw = self.detail.all_tab()  # 全部 tab
                                        if self.detail.selected(all_hw) is False:
                                            self.base_assert.except_error('Error- 未默认在 全部页面')
                                        else:
                                            print('--------------全部tab-------------------')
                                            if self.van.wait_check_empty_tips():
                                                print('暂无数据')
                                            else:
                                                self.hw_operate(nickname)  # 具体操作
                                        if self.detail.wait_check_page(gv.HW_NAME):  # 页面检查点
                                            self.home.click_back_up_button()  # 返回 班级详情页面
                                            if self.detail.wait_check_page(gv.CLASS_NAME):
                                                self.home.click_back_up_button()
                                            if self.van.wait_check_quit_vanclass(gv.CLASS_NAME):
                                                self.home.click_back_up_button()
                                            if self.van.wait_check_page():
                                                self.home.click_tab_hw()

                                        else:
                                            print('未返回 本班作业页面')
                                else:
                                    print('未进入班级 -本班作业tab')
                                    self.home.click_back_up_button()
                                    if self.van.wait_check_page():  # 班级 页面检查点
                                        self.home.click_tab_hw()  # 返回主界面
        else:
            Toast().find_toast(VALID_LOGIN_TOAST.login_failed())
            print("未进入主界面")
 def setUp(cls):
     """启动应用"""
     cls.result = unittest.TestResult()
     cls.base_assert = ExpectingTest(cls, cls.result)
     cls.login = LoginPage()
     cls.home = HomePage()
     cls.user_center = UserCenterPage()
     cls.user_info = UserInfoPage()
     cls.phone = PhoneReset()
     BasePage().set_assert(cls.base_assert)
     cls.login.app_status()
 def setUp(cls):
     """启动应用"""
     cls.result = unittest.TestResult()
     cls.base_assert = ExpectingTest(cls, cls.result)
     cls.login_page = LoginPage()
     cls.home = HomePage()
     cls.user_center = UserCenterPage()
     cls.user_info = UserInfoPage()
     cls.screen_shot = ScreenShot()
     BasePage().set_assert(cls.base_assert)
     cls.login_page.app_status()
Ejemplo n.º 8
0
 def setUp(cls):
     """启动应用"""
     cls.result = unittest.TestResult()
     cls.base_assert = ExpectingTest(cls, cls.result)
     cls.login_page = LoginPage()
     cls.home = HomePage()
     cls.user_center = UserCenterPage()
     cls.setting = Setting()
     cls.privacy = Privacy()
     BasePage().set_assert(cls.base_assert)
     cls.login_page.app_status()
    def test_study_word(self, group_index):
        """新词练习"""
        print('===== 第{}组练习 ====='.format(group_index))
        word_info = {}
        recite_words_count = 0
        wrong_again_words = []
        if group_index == 1:
            if self.home.wait_check_home_page():
                UserCenterPage().get_user_info()  # 获取学生信息
                if self.home.wait_check_home_page():
                    self.home.click_hk_tab(1)  # 点击 背单词
                    if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                        self.word_rebuild.word_start_button()  # 点击 Go按钮
                    elif self.word_rebuild.wait_check_continue_page():
                        print('❌❌❌ 缓存未清除成功')
                    time.sleep(3)
            else:
                print('❌❌❌ 未进入主页面')
            today_already_study_word_data = [0, 0, 0]
        else:
            today_already_study_word_data = self.word_rebuild.data.get_student_today_word_data(
                self.stu_id)

        while self.word_rebuild.wait_check_game_title_page():
            title = self.word_rebuild.public.game_title().text
            if '新词' in title or '新释义' in title:
                flash_result = FlashCardProcess().flash_card_operate(word_info)
                if flash_result:
                    GameOperate().new_word_other_game_operate(
                        flash_result, word_info, self.stu_id)
            elif '复习' in title:
                recite_words_count = ReciteWordPage().word_book_recite_operate(
                    self.stu_id, wrong_again_words)
            else:
                break

        if self.word_rebuild.wait_check_start_wrong_again_page():
            self.word_rebuild.confirm_btn().click()
            SpellingWord().dictation_random_pattern_recite(
                self.stu_id, wrong_again_words)
            if self.word_rebuild.wait_check_game_title_page():
                if '单词拼写(复习)' in self.word_rebuild.public.game_title().text:
                    print('❌❌❌ 错题再练个数与记录个数不一致')
        else:
            print('没有错题再练')

        if ResultPage().wait_check_result_page():
            # 结果页单词统计核实
            WordResultPage().verify_result_page_data(
                self.stu_id, today_already_study_word_data, word_info,
                recite_words_count, group_index)
    def est_recite_B_return_new_words(self, familiar_type):
        first_group_familiar = []  # 第一组标熟单词
        right_words = []  # 新词做对单词
        all_new_words = []
        if self.home.wait_check_home_page():
            stu_info = UserCenterPage().get_user_info()  # 获取学生信息
            stu_id = stu_info[0]
            self.word_rebuild.data.clear_student_word_data(
                stu_id)  # 清除学生已学单词记录

            if self.home.wait_check_home_page():
                self.home.click_hk_tab(1)  # 点击 背单词
                if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                    self.word_rebuild.word_start_button()  # 点击 Go按钮
                elif self.word_rebuild.wait_check_continue_page():
                    self.base_assert.except_error('缓存未清除成功')

                word_has_different_explain = self.word_rebuild.data.get_word_has_different_explains(
                    stu_id)
                for x in range(2):
                    do_right = self.word_rebuild.set_do_right_by_familiar_type(
                        familiar_type, x)
                    # 不同情况的标熟情况
                    flash_result = FlashCard().\
                        flash_different_familiar_operate(stu_id, self.word_info, familiar_type, x,
                                                         first_group_familiar, word_has_different_explain)
                    if flash_result:
                        first_group_familiar = list(flash_result[1].values())
                        print('标熟单词:', first_group_familiar)

                        group_new_explain_words = flash_result[3]  # 每组的新词新释义单词
                        all_new_words.append(len(
                            flash_result[0]))  # 将所有单词数量 加入所有新词中
                        self.new_explain_words.extend(
                            group_new_explain_words)  # 将每组新释义单词加入数组中
                        # 其他新词游戏过程
                        normal_game_words = self.word_rebuild.normal_study_new_word_operate(
                            stu_id, flash_result, do_right)
                        if do_right:
                            right_words.extend(normal_game_words)
                        print('正确单词:', all_new_words)
                    if ResultPage().wait_check_result_page():
                        # 结果页单词统计核实
                        ResultPage().result_page_handle(
                            len(self.word_info.keys()),
                            len(self.new_explain_words),
                            already_recite_count=0,
                            group_count=x)
                self.word_rebuild.from_wordbook_back_to_home()
Ejemplo n.º 11
0
    def test_new_word(self, do_right=False):
        """测试新词"""
        if self.home.wait_check_home_page():

            # 取消所有班级布置的单词
            # for x in TEACHER_ACCOUNT:
            #     AssignWord().revoke_van_class_wordbook_operate(x, STU_PASSWORD)
            #     LoginWebPage().logout_operate()
            # QuitAddClass().quit_all_class_operate()

            stu_info = UserCenterPage().get_user_info()  # 获取学生信息
            stu_id = stu_info[0]
            WordDataHandlePage().clear_student_word_data(stu_id)  # 清除学生已学单词记录
            self.word_info = {}
            # WordDataHandlePage().clear_word_finish_date(stu_id)

            if self.home.wait_check_home_page():
                self.home.click_hk_tab(1)  # 点击 背单词
                if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                    self.word_rebuild.word_start_button()  # 点击 Go按钮

                elif self.word_rebuild.wait_check_continue_page(
                ):  # 若为继续页面,则说明未清除缓存
                    self.base_assert.except_error('缓存未清除成功')
                    self.word_rebuild.word_continue_button()

                recite_words, all_words = [], []  # 复习单词, 新词
                for x in range(2):
                    if self.word_rebuild.wait_check_game_title_page():
                        #  闪卡学习过程 返回闪卡题数,标星标熟
                        flash_result = FlashCard().flash_study_model(
                            stu_id, self.word_info, x, do_right)
                        if flash_result:
                            group_new_explain_words = flash_result[
                                3]  # 每组新释义单词
                            all_words.append(len(
                                flash_result[0]))  # 把每组新词个数加入新词数组
                            self.new_explain_words.extend(
                                group_new_explain_words)  # 将新释义单词加入新释义数组中
                            # 其他新词游戏过程
                            self.word_rebuild.normal_study_new_word_operate(
                                stu_id, flash_result, do_right)  # 游戏过程
                    if ResultPage().wait_check_result_page():
                        # 结果页单词统计核实
                        ResultPage().result_page_handle(
                            len(self.word_info), len(self.new_explain_words),
                            len(recite_words), x)
                self.word_rebuild.click_back_up_button()
                self.home.tips_operate_commit()
class DataHandlePage(BasePage):

    mysql = LibrarySql()
    user = UserCenterPage()
    home = HomePage()

    @teststep
    def get_library_label_id(self, school_id, label_name):
        """获取图书馆标签id"""
        result = self.mysql.find_library_label_id_by_name(
            school_id, label_name)
        return result[0][0] if result else -1

    @teststep
    def get_label_book_list(self, school_id, label_id):
        """根据标签id获取图书id"""
        result = self.mysql.find_label_book_set_list(school_id, label_id)
        return {x[0]: (x[1], x[2]) for x in result}

    @teststep
    def get_book_book_set_list(self, book_id):
        """获取书籍下所有书单名称"""
        result = self.mysql.find_book_name_by_id(book_id)
        return [x[0] for x in result]

    @teststep
    def get_book_id_by_name_and_desc(self, school_id, book_name, description):
        """根据图书名称和图书简介获取图书id"""
        result = self.mysql.find_book_id_by_name_and_desc(
            school_id, book_name, description)
        return result[0][0]

    def student_today_is_submit_bank_record(self, stu_id, book_name,
                                            book_description):
        """查询此书籍的书单该学生今日是否已经学习过"""
        book_set_ids = self.mysql.find_book_set_ids(book_name,
                                                    book_description)
        if book_set_ids:
            reform_book_set_ids = str(book_set_ids[0][0].split(','))[1:-1]
            print('书籍下书单id:', reform_book_set_ids)
            book_record = self.mysql.find_student_book_today_study_record(
                stu_id, reform_book_set_ids)
            print('三本书今日是否学习过:', book_record)
            if len(book_record):
                return True
            else:
                return False
        else:
            return False
 def test_word_process(self):
     """词书进度"""
     # self.common.get_id_nick_back_home()   # 获取student_id
     if self.home.wait_check_home_page():  # 页面检查点
         stu_info = UserCenterPage().get_user_info()
         stu_id = stu_info[0]
         if self.home.wait_check_home_page():
             print('进入主界面')
             self.home.click_hk_tab(1)  # 点击 背单词
             if self.word.wait_check_start_page(
             ) or self.word.wait_check_continue_page():
                 self.progress.word_progress_icon()
                 if self.progress.wait_check_progress_page():
                     self.progress.progress_ele_check(stu_id)
                     self.word.back_to_home()
Ejemplo n.º 14
0
    def test_listen_game(self, level_name):
        if self.game.home.wait_check_home_page():  # 页面检查点
            user_data = UserCenterPage().get_user_info()
            stu_id = user_data[0]
            ListenDataHandle().delete_student_all_listening_records(stu_id)
        if self.game.home.wait_check_home_page():  # 页面检查点
            print('进入主界面', '\n')
            self.game.home.click_hk_tab(4)   # 点击每日一听
            if self.listen.wait_check_listen_everyday_home_page():
                self.listen.level_button().click()

                if self.level.wait_check_listening_level_page():
                    while not self.level.wait_check_level_page(level_name):
                        HomePage().screen_swipe_up(0.5, 0.8, 0.4, 1000)

                    if self.level.start_button(level_name).text == '开始':
                        self.level.start_button(level_name).click()
                    self.game.home.click_back_up_button()
                    level_num = int(re.findall(r'\d+', level_name)[0])
                    print('练习等级:', level_num)
                    exercise_count = 3 if level_num > 4 else 5
                    print('练习次数:', exercise_count)
                    for i in range(exercise_count + 1):
                        if self.listen.wait_check_listen_everyday_home_page():
                            self.listen.start_button().click()

                        if self.game.wait_check_gaming_page():
                            bank_type, bank_info = self.game.play_listen_game_process()
                            self.game.answer_page_operate(bank_type, bank_info)
                            if self.game.wait_check_result_page():
                                self.game.click_back_up_button()

                        elif self.listen.wait_check_degrade_page():
                            print('是否感觉题太难了,需要切换到稍简单级别的练习吗?', '\n')
                            self.game.home.commit()

                        elif self.listen.wait_check_certificate_page():
                            print('该等级已学习完毕(没有题目)')
                            GameCommonEle().share_page_operate()
                            if self.listen.wait_check_certificate_page():
                                self.listen.start_excise_button().click()

                        if i == exercise_count:
                            if self.listen.wait_today_limit_img_page():
                                print('今天你已练完{}道听力,保持适度才能事半公倍哦!'.format(exercise_count), '\n')
                                self.listen.commit_button().click()
                            else:
                                self.base_assert.except_error(' Error-- 未发现题数限制提示页面!')
 def test_mine_word(self):
     """我的单词"""
     if self.home.wait_check_home_page():  # 页面检查点
         stu_info = UserCenterPage().get_user_info()
         stu_id = stu_info[0]
         if self.home.wait_check_home_page():  # 页面检查点
             print('进入主界面')
             self.home.click_hk_tab(1)  # 点击 背单词
             if self.home.wait_check_word_title():  # 页面检查点
                 total = self.word.total_word()
                 self.mine.click_my_word_btn()
                 if self.mine.wait_check_mine_word_page():
                     if self.mine.no_word_tips():
                         self.mine.no_word_tip_text()
                     else:
                         self.mine.play_mine_word(stu_id, total)
 def test_no_class_word_data(self):
     """测试没有班级时候的"""
     if self.home.wait_check_home_page():
         QuitAddClass().quit_all_class_operate()
         stu_info = UserCenterPage().get_user_info()
         stu_id = stu_info[0]
         sys_trans_ids = WordDataHandlePage().get_sys_words_trans_id(stu_id)
         if self.home.wait_check_home_page():
             self.home.click_hk_tab(1)  # 点击 背单词
             if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                 self.word_rebuild.word_start_button()  # 点击 Go按钮
                 word_info = FlashCard().scan_game_operate(is_exit=True)
                 WorldBookPublicPage().check_word_order_is_right(
                     sys_trans_ids, word_info[0], sys_only=True)
             if self.word_rebuild.wait_check_continue_page():
                 self.word_rebuild.click_back_up_button()
    def test_normal_recite_operate(self, level):
        if self.home.wait_check_home_page():
            new_words, new_explain_words = [], []
            recite_count = 0
            stu_info = UserCenterPage().get_user_info()  # 获取学生信息
            stu_id = stu_info[0]
            self.word_rebuild.data.change_level_in_interval_date(
                stu_id, level)  # 更改指定F值的日期
            if self.home.wait_check_home_page():
                self.home.click_hk_tab(1)  # 点击 背单词
                if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                    self.word_rebuild.word_start_button()  # 点击 Go按钮

            for x in range(2):
                wrong_again_words = []
                right_explains = self.word_rebuild.data.get_student_new_all_right_explains(
                    stu_id)  # 获取学生新词全对单词
                print('新词非标熟且全对解释:', right_explains)
                if '复习' in self.word_rebuild.public.game_title().text:
                    recite_count += self.word_rebuild.recite_word_operate(
                        stu_id, level, wrong_again_words,
                        right_explains)  # 复习单词过程
                    if self.word_rebuild.wait_check_start_wrong_again_page(
                    ):  # 错题再练过程
                        self.word_rebuild.confirm_btn().click()
                        SpellingWord().dictation_random_pattern_recite(
                            stu_id, wrong_again_words)
                        if self.word_rebuild.wait_check_game_title_page():
                            if '单词拼写(复习)' in self.word_rebuild.public.game_title(
                            ).text:
                                print('❌❌❌ 错题再练个数与记录个数不一致')
                else:
                    if FlashCard().wait_check_flash_study_page():  # 遇到新词退出
                        flash_result = FlashCard().scan_game_operate(
                        )  # 闪卡游戏, 默认不标熟
                        new_words.extend(list(flash_result[0].keys()))
                        new_explain_words.extend(flash_result[-1])
                        if len(flash_result[0]) > 10:
                            print('❌❌❌ 新词个数大于10')
                        self.word_rebuild.normal_study_new_word_operate(
                            stu_id, flash_result, do_right=True)  # 其他新词游戏过程

                if ResultPage().wait_check_result_page():
                    ResultPage().result_page_handle(len(list(set(new_words))),
                                                    len(new_explain_words),
                                                    recite_count, x)
            self.word_rebuild.from_wordbook_back_to_home()
Ejemplo n.º 18
0
 def test_rank(self):
     if self.rank.home.wait_check_home_page():  # 页面检查点
         name = UserCenterPage().get_user_info()[-1]
         if self.rank.home.wait_check_home_page():
             print('进入主界面')
             self.rank.home.click_hk_tab(4)   # 点击 每日一听
             if self.listen.wait_check_listen_everyday_home_page():
                 excise_time = self.listen.excise_time()
                 print('已练听力:', excise_time.text, '\n')
                 self.listen.rank_button().click()
                 if self.rank.wait_check_rank_page():
                     self.rank.rank_ele_operate(name)
                 if self.rank.wait_check_rank_page():
                     self.rank.click_back_up_button()
                 if self.listen.wait_check_listen_everyday_home_page():
                     self.listen.click_back_up_button()
                 if self.rank.home.wait_check_home_page():
                     print('返回主页面')
 def test_recite_B_return_recite_words(self):
     if self.home.wait_check_home_page():
         stu_info = UserCenterPage().get_user_info()  # 获取学生信息
         stu_id = stu_info[0]
         self.word_rebuild.data.change_level_limit_word_date(stu_id,
                                                             1)  # 更改指定F值的日期
         if self.home.wait_check_home_page():
             self.home.click_hk_tab(1)  # 点击 背单词
             if self.word_rebuild.wait_check_start_page():  # 开始页面检查点
                 self.word_rebuild.word_start_button()  # 点击 Go按钮
                 wrong_again_words, all_words = [], []
                 right_explains = self.word_rebuild.data.get_student_new_all_right_explains(
                     stu_id)  # 获取学生新词全对单词
                 print('新词非标熟且全对解释:', right_explains)
                 self.word_rebuild.recite_word_operate(
                     stu_id, 1, wrong_again_words, right_explains)
                 if FlashCard().wait_check_flash_study_page():
                     self.word_rebuild.from_wordbook_back_to_home()
Ejemplo n.º 20
0
 def test_check_exam_detail(self):
     """查看试卷详情"""
     if self.home.wait_check_home_page():
         nick_name = UserCenterPage().get_user_info()[-1]
         if self.home.wait_check_home_page():  # 页面检查点
             print('进入主界面')
             self.home.click_hk_tab(3)  # 点击 做试卷
         if self.detail.wait_check_exam_title_page():
             exam_name = self.exam.select_one_exam()
             data_json = self.common.get_data_json_from_file()
             exam_data = data_json[exam_name]
             if self.exam.wait_check_rank_page():
                 self.detail.rank_page_operate(nick_name)
             if self.exam.wait_check_rank_page():
                 self.detail.check_detail()
                 if self.detail.wait_check_detail_page():
                     self.detail.check_ques_detail(exam_data)
                     self.home.click_back_up_button()
                     if self.detail.wait_check_rank_page():
                         self.home.click_back_up_button()
Ejemplo n.º 21
0
    def test_book_operate(self, book_name):
        """测试书籍游戏"""
        if self.home.wait_check_home_page(True):
            user_info = UserCenterPage().get_user_info()
            school_name = user_info[1]
            nickname = user_info[3]
            stu_id = user_info[0]

            if self.home.wait_check_home_page():
                self.home.screen_swipe_up(0.5, 0.9, 0.2, 1000)
                self.home.check_more()[0].click()
                label_name = '测试专用'

                # 进入其他教材标签,选择全题型书籍
                while True:
                    if self.library.wait_check_test_label_page(label_name):
                        self.library.course_more_btn(label_name).click()
                        break
                    else:
                        self.home.screen_swipe_up(0.5, 0.9, 0.4, 1000)
                while not self.library.wait_check_test_book_page('全题型'):
                    self.home.screen_swipe_up(0.5, 0.9, 0.4, 1000)
                self.library.test_book('全题型').click()

                #  进入书籍,获取书单进度,从数据库中查询此书籍的任一书籍是否已经学习过
                book_process, book_description = self.library.select_test_book_operate(book_name)
                print('书单数据库进度, 书籍描述:', book_process, book_description)
                today_has_studied = DataHandlePage().student_today_is_submit_bank_record(stu_id, '全题型', book_description)
                book_process = book_process if book_process != '完成' else '100%'

                # 书单操作,验证书单页面的排行、点赞、立即打卡功能
                book_set_info = self.library.bookset_page_operate(book_process, nickname, today_has_studied)
                bank_count = book_set_info[-1]
                if self.library.wait_check_book_set_page():
                    self.library.start_study_button().click()
                self.game_operate(bank_count, nickname)
                # 从书籍列表页面返回主页面操作
                self.library.from_bank_back_to_home_operate(school_name, label_name)
    def test_checkpoint_activity(self):
        if self.punch.wait_check_alert_punch_tip_page():
            self.punch.click_alert_tip()
            if not self.punch.wait_check_activity_book_item_page():
                self.base_assert.except_error("点击主页的打卡弹框未进入打卡页面")
            else:
                self.punch.punch_page_back_icon().click()

        if not self.home.wait_check_home_page():
            self.base_assert.except_error('在打卡页面点击退回页面未进入主页面')
        else:
            stu_info = UserCenterPage().get_user_info()
            stu_id = stu_info[0]
            nickname = stu_info[-1]
            class_ids = VanclassPage().get_vanclass_id()
            print('学生班级id:', class_ids)
            activity_class_info = self.data.get_has_punch_activity_class(class_ids)
            print('打开活动班级信息:', activity_class_info, '\n')
            if self.home.wait_check_home_page():
                self.punch.home_page_punch_tab().click()
                class_activity_book_info = self.punch.checkpoint_core_process(stu_id, activity_class_info)
                select_quoted_id = self.punch.punch_page_select_book_operate(class_activity_book_info, nickname)
                self.punch.checkpoint_page_operate(nickname, select_quoted_id)
Ejemplo n.º 23
0
 def __init__(self):
     self.home = HomePage()
     self.user_center = UserCenterPage()
     self.wait = WaitElement()
Ejemplo n.º 24
0
class PurchasePage(BasePage):
    def __init__(self):
        self.home = HomePage()
        self.user_center = UserCenterPage()
        self.wait = WaitElement()

    @teststep
    def wait_check_buy_page(self):
        """以“购买”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'在线客服')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_help_center_page(self):
        """以“帮助中心”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'帮助中心')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_card_page(self):
        """以“优惠购买”的id 为依据"""
        locator = (By.ID, self.id_type() + "discount_pay")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_agreement_page(self):
        """以“购买协议”的xpath 为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'购买协议')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_pay_confirm_page(self):
        """以“支付确认”的xpath 为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'支付确认')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_parent_pay_page(self):
        """以“支付完成”的ID 为依据"""
        locator = (By.ID, self.id_type() + "pay_complete")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_magic_page(self):
        """以“支付完成”的ID 为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'在线助教家长端')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def online_server(self):
        """在线客服"""
        locator = (By.ID, self.id_type() + 'goToCustomerService')
        return self.wait.wait_find_element(locator)

    @teststep
    def magics(self):
        locator = (By.ID, self.id_type() + 'function_des')
        return self.wait.wait_find_elements(locator)

    @teststep
    def upgrade_button(self):
        """马上购买"""
        locator = (By.ID, self.id_type() + 'goToUpgrade')
        return self.wait.wait_find_element(locator)

    @teststep
    def discount_buy(self):
        """优惠购买"""
        locator = (By.ID, self.id_type() + 'discount_pay')
        return self.wait.wait_find_element(locator)

    @teststep
    def card_type(self):
        """优惠卡类型"""
        locator = (By.ID, self.id_type() + 'one')
        return self.wait.wait_find_elements(locator)

    @teststep
    def check_radio(self, card_name):
        """选项按钮"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[contains(@text, "{}")]/../preceding-sibling::'
            'android.widget.RadioButton'.format(card_name))
        return self.wait.wait_find_element(locator)

    @teststep
    def card_price(self, card_name):
        """卡片的价格  根据卡的类型获取"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[contains(@text, "{}")]/../following-sibling::'
            'android.widget.LinearLayout/android.widget.TextView'.format(
                card_name))
        return self.wait.wait_check_element(locator)

    @teststep
    def selected_card(self):
        """已选卡型"""
        locator = (By.ID, self.id_type() + 'current_vip_card_hint')
        return self.wait.wait_find_element(locator)

    @teststep
    def direct_buy_button(self):
        locator = (By.ID, self.id_type() + 'pay')
        return self.wait.wait_find_element(locator)

    @teststep
    def confirm_pay_button(self):
        locator = (By.ID, self.id_type() + 'pay')
        return self.wait.wait_find_element(locator)

    @teststep
    def discount_buy_button(self):
        """优惠购买按钮"""
        locator = (By.ID, self.id_type() + 'discount_pay')
        return self.wait.wait_find_element(locator)

    @teststep
    def agreement(self):
        """购买协议"""
        locator = (By.ID, self.id_type() + 'pay_agreement')
        return self.wait.wait_find_element(locator)

    @teststep
    def ali_pay_tab(self):
        """支付宝支付"""
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text,"支付宝代付")]')
        return self.wait.wait_find_element(locator)

    @teststep
    def wechat_pay_tab(self):
        """微信支付"""
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text,"微信代付")]')
        return self.wait.wait_find_element(locator)

    @teststep
    def parent_check_button(self):
        locator = (By.ID, self.id_type() + 'pay_agreement')
        return self.wait.wait_find_element(locator)

    @teststep
    def get_all_text_view(self):
        """获取页面所有不为空的文本值"""
        locator = (By.CLASS_NAME, 'android.widget.TextView')
        ele = self.wait.wait_find_elements(locator)
        all_text = [
            ele[i].text for i in range(len(ele))
            if ele[i].text != '' and ele[i].text is not None
        ]
        return all_text

    @teststep
    def online_server_ele_check(self):
        self.online_server().click()
        if self.wait_check_help_center_page():
            print('在线助教客服二维码')
            self.home.click_back_up_button()

    @teststep
    def magic_ele_check(self):
        all_magics = self.magics()
        all_magics[random.randint(0, len(all_magics) - 1)].click()
        if self.wait_check_magic_page():
            print('法宝详情页....\n')
            self.home.click_back_up_button()
            if self.wait_check_buy_page():
                pass

    @teststep
    def switch_card(self):
        """切换卡片"""
        card_type = self.card_type()
        for card in card_type:
            card.click()
            check_radio = self.check_radio(card.text)
            if check_radio.get_attribute('checked') != 'true':
                print('❌❌❌ Error-- 选项按钮状态未发生变化')
            current_card = self.selected_card()
            if card.text.split(' ')[0] != current_card.text:
                print('❌❌❌ Error-- 当前卡的类型与所选类型不一致')
            else:
                print('已选择', current_card.text, '\n')

            if '年卡' in card.text:
                card_price = self.card_price(card.text)
                discount_button = self.discount_buy_button()
                if '优惠价' in card_price.text:
                    if discount_button.get_attribute('enabled') != 'true':
                        print('❌❌❌ Error-- 有优惠价,但是优惠购买按钮置灰', card.text)
                else:
                    if discount_button.get_attribute('enabled') != 'false':
                        print('❌❌❌ Error-- 无优惠价,但是优惠购买按钮未置灰', card.text)

    @teststep
    def check_agreement(self):
        agreement = self.agreement()
        location = agreement.location
        self.driver.tap([
            (location['x'] + 520, location['y'] + 50),
        ])
        if self.wait_check_agreement_page():
            print('在线助教【提分版】购买协议 .....')
            self.home.screen_swipe_down(0.5, 0.5, 0.9, 1500)
            self.home.click_back_up_button()

    @teststep
    def direct_buy(self):
        if self.wait_check_card_page():
            self.direct_buy_button().click()
            if self.wait_check_pay_confirm_page():
                self.pay_confirm_page_ele_operate()
                self.parent_check_button().click()
                self.confirm_pay_button().click()
                if self.wait_check_parent_pay_page():
                    self.ali_pay_tab().click()
                    time.sleep(2)
                    self.parent_page_ele_operate()

                    self.wechat_pay_tab().click()
                    time.sleep(2)
                    self.parent_page_ele_operate()

    @teststep
    def magics_page_ele_operate(self):
        """法宝页面元素信息"""
        text = self.get_all_text_view()
        if len(text) != 16:
            print('❌❌❌ Error-- 页面元素缺失', text)
        else:
            magic_types = numpy.reshape(text[6:-1], (3, 3))
            print("<" + text[0] + '页面>', '\n', '学生:', text[1], '\n', '手机:',
                  text[2], '\n', '提示:', text[4] + text[5], '\n', '法宝:', '\n',
                  magic_types, '\n')

    @teststep
    def buy_page_ele_operate(self):
        """购买页面(优惠卡类型) 页面"""
        text = self.get_all_text_view()
        print(len(text))
        if len(text) not in range(18, 21):
            print('❌❌❌ Error-- 页面元素缺失', text)
        else:
            print(
                '<选择优惠卡页面>\n'
                '学生:',
                text[1],
                '\n',
                '手机:',
                text[2],
                '\n',
                '提示:',
                text[4] + text[5],
                '\n',
            )
            if len(text) == 20:
                print(
                    '优惠卡类型',
                    '\n',
                    text[6],
                    text[7],
                    '\n',
                    text[8],
                    text[9],
                    '\n',
                    text[10],
                    text[11],
                    text[12],
                    '\n',
                    text[13],
                    text[14],
                    text[15],
                    '\n',
                    '协议:',
                    text[16],
                    '\n',
                    '已选类型:',
                    text[17],
                    '\n',
                    text[18],
                    text[19],
                    '\n',
                )
            else:
                print(
                    '优惠卡类型',
                    '\n',
                    text[6],
                    text[7],
                    '\n',
                    text[8],
                    text[9],
                    '\n',
                    text[10],
                    text[11],
                    '\n',
                    text[12],
                    text[13],
                    '\n',
                    '协议:',
                    text[14],
                    '\n',
                    '已选类型:',
                    text[15],
                    '\n',
                    text[16],
                    text[17],
                    '\n',
                )

    @teststep
    def pay_confirm_page_ele_operate(self):
        text = self.get_all_text_view()
        if len(text) != 12:
            print('❌❌❌ Error-- 页面元素缺失', text)
        else:
            print('<支付确认页面>\n'
                  '学生:', text[1], '\n', '手机:', text[2], '\n', '卡型:', text[6],
                  '\n', "价格:", text[4] + text[5], '\n', text[7] + ":", '\n',
                  text[8], text[9], text[10], '\n', text[11], '\n')

    @teststep
    def parent_page_ele_operate(self):
        text = self.get_all_text_view()
        if len(text) != 9:
            print('❌❌❌ Error-- 页面元素缺失', text)
        else:
            print(
                '<' + text[0] + "页面>",
                '\n',
                text[1],
                text[2],
                '\n',
                '卡型:',
                text[3],
                '\n',
                '价格:',
                text[4] + text[5],
                '\n',
                text[6],
                '\n',
                text[7],
                '\n',
                text[8],
                '\n',
            )

    @teststep
    def back_to_home(self):
        self.home.click_back_up_button()
        if self.wait_check_pay_confirm_page():
            self.home.click_back_up_button()
            if self.wait_check_card_page():
                self.home.click_back_up_button()
                if self.wait_check_buy_page():
                    self.home.click_back_up_button()
                    if self.user_center.wait_check_user_center_page():
                        self.home.click_tab_hw()
                        if self.home.wait_check_home_page():
                            print('返回主界面')
Ejemplo n.º 25
0
 def back_up(self):
     """从个人信息页 返回主界面"""
     if self.wait_check_page():
         self.back_up_button()  # 返回按钮
         if UserCenterPage().wait_check_user_center_page():  # 页面检查点
             HomePage().click_tab_hw()
Ejemplo n.º 26
0
 def enter_user_info_page(self):
     """由 主界面 进入个人信息页"""
     if HomePage().wait_check_home_page():
         HomePage().click_tab_profile()  # 进入首页后点击‘个人中心’按钮
         if UserCenterPage().wait_check_user_center_page():
             UserCenterPage().click_avatar_profile()  # 点击登录头像按钮,进行个人信息操作
Ejemplo n.º 27
0
    def test_word_test(self, test_type, do_pass):
        """
        :param test_type: 1 只校验测试单词是否正确 2: 做题,结果页数据核对,错题再练
        :param do_pass: true 全做对 false 不做全对
        :return:
        """
        if self.home.wait_check_home_page():
            stu_info = UserCenterPage().get_user_info()
            stu_id = stu_info[0]
            nickname = stu_info[-1]
            self.word_test.sql_handler.delete_student_test_data(stu_id)
            fvalue_glt_3_count = self.word_test.sql_handler.get_f_glt_3_count(stu_id)

            if self.home.wait_check_home_page():
                self.home.click_hk_tab(1)  # 点击 背单词

                for x in range(1):
                    fvalue_glt_3_words = self.word_test.sql_handler.get_test_words(stu_id, 1)
                    test_fail_words = self.word_test.sql_handler.get_test_words(stu_id, 2)
                    test_pass_words = self.word_test.sql_handler.get_test_words(stu_id, 3)
                    print('未测过且F>=3的单词个数:', len(fvalue_glt_3_words),
                          '\n测试未通过单词个数:', len(test_pass_words),
                          '\n测试通过单词个数:', len(test_fail_words),
                          '\n')

                    if self.word_rebuild.wait_check_start_page():
                        self.word_test.click_word_test_tab()

                        if self.word_test.wait_check_no_test_word_page():
                            if fvalue_glt_3_count >= 20:
                                self.base_assert.except_error('F值大于等于3的个数大于等于20,未进入复习页面')
                            self.word_test.click_confirm_btn()
                            if not self.word_rebuild.wait_check_start_page():
                                self.base_assert.except_error("无词复习点击确定后未返回单词本开始页面")

                        if self.word_test.wait_check_select_word_count_page():
                            if fvalue_glt_3_count < 20:
                                self.base_assert.except_error("F值大于等于3的个数小于20, 但是出现开始复习页面")

                    # 根据单词筛选顺序从数据库获得需要测试的单词
                    test_words_dict = self.word_test.get_test_word_list(fvalue_glt_3_words, test_fail_words, test_pass_words, x)
                    print('从数据库获取需要复习的单词:', list(test_words_dict.keys()))
                    if test_type == 1:
                        self.word_test.check_preview_word_operate(test_words_dict)
                        self.word_test.sql_handler.delete_student_test_data(stu_id)
                        self.word_test.click_back_up_button()
                    else:
                        for i in range(2):
                            test_answer, word_id_list = self.word_test.check_preview_word_operate(test_words_dict)
                            self.word_test.click_start_test_btn()
                            if i == 1:
                                do_pass = True
                            game_info = self.word_test.play_test_word_spell_operate(len(test_words_dict), test_answer, do_pass)
                            # 验证预览与做题是否打乱顺序
                            # if game_info[1] == word_id_list:
                            #     self.base_assert.except_error("预览单词顺序与实际做题顺序一致,顺序未打乱")
                            reform_words_dict = {x: test_words_dict[x] for x in game_info[1]}
                            wrong_word_dict = self.word_result.check_result_page_data_operate(stu_id, nickname, reform_words_dict, game_info[0], i)
                            if self.word_result.wait_check_test_result_page():
                                if i != 1:
                                    self.word_result.wrong_again_btn().click()
                                    test_words_dict = wrong_word_dict
                                else:
                                    self.word_result.result_back_btn().click()