コード例 #1
0
 def test_book_test(self, vocab_right, spell_right):
     SelectCoursePage().select_course_operate('英语',
                                              card_index=CARD_INDEX,
                                              book_index=BOOK_INDEX)
     unit_status = self.home.status_list()  # 所有单元状态
     not_complete_unit = [x for x in unit_status if '100%' not in x.text]
     self.home.click_book_test_btn()
     if len(not_complete_unit):
         if self.game.wait_check_error_flash_page():
             print(self.game.error_content())
         else:
             self.base_assert.except_error(
                 '未完成本书所有单元, 点击本书测试未提示请先完成本书的学习再来进行整体测试')
     else:
         start_content = self.home.start_text()  # 页面文本
         print(start_content)
         book_test_time = {}
         self.home.click_start_button()  # 开始学习
         book_id = re.findall(r'\d+', self.home.driver.current_url)[0]
         print('书籍id:', book_id)
         book_word_ids = self.game.data.get_student_book_word_count(
             self.stu_id, book_id)
         print('本书已背单词个数:', book_word_ids)
         book_test_time['本书测试'] = self.exam.exam_game_operate(
             self.stu_id,
             book_id,
             book_word_ids,
             exam_name_suffix='本书测试',
             vocab_right=vocab_right,
             spell_right=spell_right,
             is_book_test=True)
         print(book_test_time)
コード例 #2
0
 def test_enforce_review(self):
     if self.home.wait_check_home_page():
         SelectCoursePage().select_course_operate('英语',
                                                  card_index=CARD_INDEX,
                                                  book_index=BOOK_INDEX)
     if self.home.wait_check_home_page():
         book_id = self.home.driver.current_url.split('/')[-1]
         print('书籍id:', book_id)
         update_words = self.game.data.update_student_word_date_to_review(
             self.stu_id, book_id)
         self.home.click_study_word_tab()
         if self.game.wait_check_start_study_page():
             start_content = self.home.start_text()
             print(start_content, '\n')
             self.home.click_start_button()
             if '强制复习' not in start_content:
                 self.base_assert.except_error(
                     "已经设置单词学习记录, 点击单词学习未出现强制复习页面")
             else:
                 recite_word_info = ReciteWordPage().recite_word_process(
                     self.stu_id, book_id, start_content)
                 if [
                         x for x in update_words
                         if str(x) not in list(recite_word_info.keys())
                 ]:
                     self.base_assert.except_error(
                         "强制复习单词与数据查询单词不一致,查询数据为{}, 实际复习单词为{}".format(
                             str(update_words),
                             str(list(recite_word_info.keys()))))
コード例 #3
0
    def test_exam_process(self):
        """试卷做题过程"""
        SelectCoursePage().select_course_operate('地理', card_index=0, book_index=0)
        if self.home.wait_check_home_page():
            self.home.exam().click()
            mine_answer_info = {}
            #  选择一个试卷,并输出试卷信息
            if self.exam.wait_check_exam_record_list_page():
                exam_list = self.exam.exam_group_ele()
                random_index = random.randint(0, len(exam_list) - 1)
                select_exam = exam_list[random_index]
                exam_name = self.exam.exam_name(select_exam)
                exam_date = self.exam.latest_exam_date(select_exam)
                exam_time = self.exam.exam_used_time(select_exam)
                exam_score = self.exam.exam_score(select_exam)

                print('试卷名称:', exam_name, '\n',
                      '试卷最新完成时间:', exam_date, '\n',
                      '试卷耗时:', exam_time, '\n',
                      '试卷得分:', exam_score, '\n')
                start_exam_btn = self.exam.start_exam_by_ele(select_exam)
                ActionChains(self.exam.driver).click(start_exam_btn).perform()

                #  中途做对退出,验证分数是否变化
                if self.home.wait_check_start_study_page():
                    print(self.home.start_text())
                    self.home.click_start_button()
                self.exam.exam_operate(do_right=True, half_exit=True, mine_answer_info=mine_answer_info)
                if self.exam.wait_check_exam_record_list_page():
                    if self.exam.exam_score(select_exam) == exam_score:   # 待议
                        self.base_assert.except_error('已经做对一题, 中途退出以后成绩未发生变化')

                #  完成所有题
                ActionChains(self.exam.driver).click(start_exam_btn).perform()
                if self.home.wait_check_start_study_page():
                    print(self.home.start_text())
                    self.home.click_start_button()
                    mine_answer_info = {}
                    do_right = random.choice([False, True])
                    self.exam.exam_operate(do_right=do_right, half_exit=False, mine_answer_info=mine_answer_info)
                    self.exam.exit_icon().click()

                    # 查看报告,验证记录答案和页面答案是否一致
                    if self.exam.wait_check_exam_record_list_page():
                        check_report_btn = self.exam.check_report(select_exam)
                        ActionChains(self.exam.driver).click(check_report_btn).perform()
                    if self.exam.wait_check_answer_card_page():
                        exam_result_score = self.exam.exam_result_score()
                        check_score = 100 if do_right else 0
                        if exam_result_score != check_score:
                            self.base_assert.except_error('试卷得分与计算得分不一致')
                        self.exam.check_answer_operate(do_right, mine_answer_info)
コード例 #4
0
 def test_section_all_process(self):
     # self.chapter.data.delete_student_all_record()
     SelectCoursePage().select_course_operate('地理',
                                              card_index=0,
                                              book_index=0)
     if self.home.wait_check_home_page():
         book_id = self.home.book_id()
         self.home.chapter_study().click()
         time.sleep(2)
         if self.chapter.wait_chapter_page():
             active_chapters = self.chapter.check_chapter_is_available(
                 book_id)
             chapter_ele, chapter_id = active_chapters[CHAPTER_INDEX]
             print('选择章节:', chapter_ele.text, '\n')
             chapter_ele.click()
             time.sleep(2)
             active_section_index = self.chapter.check_section_available_status(
                 book_id, chapter_id)
             exit_start_text = 0
             for x in range(len(active_section_index)):
                 if self.chapter.wait_chapter_page():
                     self.chapter.order_study_btn().click()
                     if self.home.wait_check_start_study_page():
                         print(self.home.start_text())
                         if exit_start_text:
                             if self.home.start_text() != exit_start_text:
                                 self.base_assert.except_error(
                                     '顺序学习中途退出后,再次点击顺序学习, 页面提示与退出时的提示不一致')
                         self.home.click_start_button()
                         time.sleep(1)
                         knowledge_exit_text = self.game.section_knowledge_operate(
                             self.wrong_note,
                             do_right=True,
                             is_order_study=True)
                         if self.chapter.wait_chapter_page():
                             self.chapter.order_study_btn().click()
                             time.sleep(1)
                             if self.home.wait_check_start_study_page():
                                 print('======= 小节练习 ========\n')
                                 print(self.chapter.start_text(), '\n')
                                 if knowledge_exit_text != self.chapter.start_text(
                                 ):
                                     self.base_assert.except_error(
                                         '顺序学习中途退出后,再次点击顺序学习, 页面提示与退出时的提示不一致'
                                     )
                                 self.chapter.click_start_button()
                                 time.sleep(1)
                                 exit_id, exit_start_text = self.game.section_sync_operate(
                                     self.wrong_note,
                                     do_right=True,
                                     is_order_study=True)
コード例 #5
0
    def test_chapter_last_oder(self):
        SelectCoursePage().select_course_operate('地理', card_index=0, book_index=0)
        if self.home.wait_check_home_page():
            book_id = self.home.book_id()
            page_chapter_num = self.home.chapter_total_num()
            self.chapter.chapter_num_check(book_id, page_chapter_num)
            self.home.chapter_study().click()
            time.sleep(2)
            if self.chapter.wait_chapter_page():
                # 验证小节是否已上架,并随机选择已上架的一个小节
                active_chapters = self.chapter.check_chapter_is_available(book_id)
                chapter_ele, chapter_id = active_chapters[CHAPTER_INDEX]
                print('选择章节:', chapter_ele.text, '\n')
                chapter_ele.click()
                time.sleep(3)
                self.chapter.check_shelves_chapter_data(book_id, chapter_id)
                active_section_index = self.chapter.check_section_available_status(book_id, chapter_id)
                select_section_index, section_id = active_section_index[SECTION_INDEX]

                section_ele = self.chapter.section_father_box_ele()[select_section_index]
                self.chapter.section_sync_exercise(section_ele).click()
                if self.home.wait_check_start_study_page():
                    print(self.home.start_text(), '\n')
                    self.home.click_start_button()
                    self.game.section_sync_operate(self.wrong_note, section_id=section_id)

                exit_id = 0
                if self.chapter.wait_chapter_page():
                    section_ele = self.chapter.section_father_box_ele()[select_section_index]
                    self.chapter.section_sync_exercise(section_ele).click()
                    time.sleep(2)
                    self.home.click_start_button()
                    exit_id = self.game.section_sync_operate(self.wrong_note, is_half_exit=True, section_id=section_id)
                    print('退出时页面题目id:', exit_id)

                if exit_id == 0:
                    print('同步练习只有一道选择题')
                else:
                    if self.chapter.wait_chapter_page():
                        section_ele = self.chapter.section_father_box_ele()[select_section_index]
                        self.chapter.section_sync_exercise(section_ele).click()
                        time.sleep(2)
                        self.home.click_start_button()
                        time.sleep(2)
                        game_id = self.chapter.bank_id()
                        print('再次进入时题目id:', game_id)
                        if game_id == exit_id:
                            self.base_assert.except_error("同步练习中途退出后, 再次点击进入的题目id与退出时的题目id一致")
コード例 #6
0
 def test_review_word_operate(self):
     """测试复习单词"""
     if self.home.wait_check_home_page():
         SelectCoursePage().select_course_operate('英语',
                                                  card_index=CARD_INDEX,
                                                  book_index=BOOK_INDEX)
     book_id = self.home.driver.current_url.split('/')[-1]
     print('书籍id:', book_id)
     print(self.home.wordbook_tip_content())
     unit_list = self.home.unit_list()
     unit_list[1].click()
     self.home.click_review_word_tab()
     start_content = self.home.start_text()
     print(start_content)
     self.home.click_start_button()
     spend_time_info = {}
     self.recite.recite_word_process(self.stu_id, book_id, start_content)
     print(spend_time_info)
     print('本次做题总用时:',
           sum([spend_time_info[x]['总用时'] for x in spend_time_info]))
コード例 #7
0
    def test_study_word(self):
        """测试新词学习"""
        if self.home.wait_check_home_page():
            SelectCoursePage().select_course_operate('英语', card_index=CARD_INDEX, book_index=BOOK_INDEX)
        if self.home.wait_check_home_page():
            book_id = self.home.driver.current_url.split('/')[-1]
            print('书籍id:', book_id)
            stu_id = self.word_test.data.get_student_id(STUDENT_ACCOUNT)
            print('学生id:', stu_id)
            student_name = self.word_test.data.get_user_name(stu_id)
            print('学生名称:', student_name)
            book_name = self.home.book_name()
            print('书籍名称:', book_name)
            book_type = self.word_test.data.get_book_type(book_id, stu_id)
            print('书籍类型:', book_type)
            print(self.home.wordbook_tip_content(), '\n')

            # 点击一个单元,根据当前所有单元状态, 验证点击单词学习和自主复习后的提示状态
            unit_list = self.home.unit_list()
            uncomplete_unit_index = [i for i, x in enumerate(unit_list) if x.text not in ['未完成', "100%"]]
            random_index = random.randint(0, len(unit_list) - 1)
            unit_index = uncomplete_unit_index[0] if uncomplete_unit_index else random_index
            unit_status_list = self.home.status_list()        # 所有单元状态
            self.home.check_click_tab_tip_by_unit_status(unit_status_list)
            unit_name = unit_list[unit_index].text
            unit_state = unit_status_list[unit_index].text
            unit_id = self.word_test.data.get_unit_catalog_id(book_id, unit_name)
            unit_translation_ids = self.word_test.data.get_unit_word_translations_ids(unit_id)
            # 验证点击单词学习弹出的页面提示, 并清除单元所有学习记录
            print('单元id:', unit_id)
            unit_list[unit_index].click()
            time.sleep(1)
            self.home.click_study_word_tab()
            # 开始单词学习整体流程
            if self.word_test.wait_check_start_study_page():
                start_content = self.home.start_text()
                print(start_content, '\n')
                content_num = re.findall(r'\d+', self.home.content_desc())
                print('content_num:', content_num)
                unit_total_words = int(content_num[0])
                if len(content_num) == 2:
                    rest_word_count = unit_total_words - int(content_num[-1])
                else:
                    rest_word_count = unit_total_words
                group_word_count = 5 if rest_word_count >= 5 else rest_word_count
                self.home.click_start_button()
                all_word_info = {}
                fl_change = False if unit_state == '100%' else True
                # 游戏过程
                self.game.new_word_study_process(stu_id, book_id, all_word_info=all_word_info, fl_change=fl_change,
                                                 group_count=group_word_count, book_type=book_type)
                # 学后测试及错题再练过程
                if self.word_test.wait_check_after_test_page():
                    self.word_test.start_test_btn().click()
                    mine_answer, right_words, wrong_words = \
                        self.word_test.word_test_process(stu_id, unit_translation_ids, do_right=False)
                    self.word_test.word_before_test_fail_operate(mine_answer, len(right_words))
                    if not self.word_test.wait_check_wrong_again_btn_page():
                        self.base_assert.except_error('学后测试未做全对未出现错题再练按钮')
                    else:
                        self.word_test.wrong_again_btn().click()
                        self.word_test.word_test_process(stu_id, unit_translation_ids, do_right=True,
                                                         wrong_word_list=wrong_words)

                    self.word_test.test_report_page_operate(student_name, book_name, unit_name, len(mine_answer))
                    self.word_test.exit_icon().click()
                    time.sleep(2)
コード例 #8
0
    def test_back_text(self, unit_index, tp=3):
        """测试背课文"""
        if self.home.wait_check_home_page():
            self.back_text.handle.clear_student_text_overview()
            self.back_text.driver.refresh()
            time.sleep(3)
            SelectCoursePage().select_course_operate('英语',
                                                     card_index=1,
                                                     book_index=4)

            if self.back_text.wait_check_back_text_page():
                self.back_text.unit_name_list()[unit_index].click()
                unit_status = self.back_text.unit_status()[unit_index].text
                time.sleep(1)

                if self.back_text.wait_check_module_page():
                    if '未完成' in unit_status:
                        practice_name = self.back_text.module_list()  # 获取模块列表
                        print('模块名称列表: ', [x.text for x in practice_name])
                        study_btn_class = [
                            GetAttribute().get_class(
                                self.back_text.module_study_btn(x))
                            for x in practice_name
                        ]  # 新学
                        review_btn_class = [
                            GetAttribute().get_class(
                                self.back_text.module_review_btn(x))
                            for x in practice_name
                        ]  # 复习
                        for index, btn_class in enumerate(
                                zip(study_btn_class, review_btn_class)):
                            if index == 0:  # 判断第一模块新学、复习状态
                                if 'primary' not in btn_class[0]:
                                    self.base_assert.except_error(
                                        '第一模块新学按钮未默认点亮')

                                if 'info' not in btn_class[1]:
                                    self.base_assert.except_error(
                                        '第一模块复习按钮未置灰')
                            else:  # 判断其他模块新学、复习状态
                                if 'info' not in btn_class[0]:
                                    self.base_assert.except_error(
                                        '非第一模块新学按钮未置灰')

                                if 'info' not in btn_class[1]:
                                    self.base_assert.except_error(
                                        '非第一模块复习按钮未置灰')

                        self.back_text.module_review_btn(
                            practice_name[0]).click()  # 点击第一个复习按钮
                        if self.back_text.wait_check_error_tip_page():
                            print(self.game.error_content())
                        else:
                            self.back_text.game_exit_btn().click()

                        time.sleep(3)
                        if len(practice_name) > 1:  # 若模块个数大于1 ,点击最后一个新学,
                            self.back_text.module_study_btn(
                                practice_name[-1]).click()
                            if self.back_text.wait_check_error_tip_page():
                                print(self.game.error_content())
                            time.sleep(3)

                    module_ele = self.back_text.module_list()
                    module_index = 0
                    self.back_text.module_study_btn(
                        module_ele[module_index]).click()  # 点击第一个新学
                    self.back_text.alert_tip_operate()

                    if tp == 1:  # 中途退出校验
                        self.check_half_exit_operate()

                    elif tp == 2:  # 跨单元验证进度是否保存
                        self.change_unit_exit_operate()

                    elif tp == 3:  # 完整的练习一个模块过程steps
                        self.check_complete_operate(unit_index, module_index)
コード例 #9
0
    def test_study_word(self, test_do_right):
        """测试新词学习"""
        if self.home.wait_check_home_page():
            SelectCoursePage().select_course_operate('英语', card_index=CARD_INDEX, book_index=BOOK_INDEX)
        if self.home.wait_check_home_page():
            book_id = self.home.driver.current_url.split('/')[-1]
            print('书籍id:', book_id)
            stu_id = self.word_test.data.get_student_id(STUDENT_ACCOUNT)
            print('学生id:', stu_id)
            student_name = self.word_test.data.get_user_name(stu_id)
            print('学生名称:', student_name)
            book_name = self.home.book_name()
            print('书籍名称:', book_name)
            book_type = self.word_test.data.get_book_type(book_id, stu_id)
            print('书籍类型:', book_type)

            # 选择一个单元, 若存在未完成单元,则选择, 若不存在则随机选择一个单元
            unit_list = self.home.unit_list()
            uncomplete_unit_index = [i for i, x in enumerate(unit_list) if x.text not in ['未完成', "100%"]]
            random_index = random.randint(0, len(unit_list) - 1)
            unit_index = uncomplete_unit_index[0] if uncomplete_unit_index else random_index
            unit_name = unit_list[unit_index].text
            unit_state = self.home.status_list()[unit_index].text
            unit_id = self.word_test.data.get_unit_catalog_id(book_id, unit_name)
            print('单元id:', unit_id)
            self.game.data.delete_student_unit_word_record(stu_id, book_id, unit_id)
            # 删除学生学习记录后, 清空错题记录文本内容
            pro_path = os.path.abspath('.')
            with open(pro_path + '\\app\\wordbook\\test_data\\wrong.json', 'w') as f:
                f.write(json.dumps({}))
            self.home.driver.refresh()
            time.sleep(3)

            # 开始学前测试, 验证提交后的页面以及单元状态
            select_unit = self.home.unit_list()[unit_index]
            select_unit.click()
            time.sleep(1)
            self.home.click_study_word_tab()
            unit_words_count = self.word_test.data.get_unit_words_count(unit_id)
            unit_translation_ids = self.word_test.data.get_unit_word_translations_ids(unit_id)
            page_word_count = self.word_test.page_words_count()[0]
            if unit_words_count != int(page_word_count):
                self.base_assert.except_error('页面单词个数与数据库查询个数不一致')

            # 学前测试流程
            print("学前测试是否做对:", test_do_right)
            self.word_test.start_test_btn().click()
            mine_input_answer, right_words, _ =\
                self.word_test.word_test_process(stu_id, unit_translation_ids, do_right=test_do_right)
            # 全部做对,弹出奖状, 未做全对,给出做题详情
            if test_do_right:
                self.word_test.test_report_page_operate(student_name, book_name, unit_name, len(right_words))
                self.home.click_study_word_tab()
            else:
                self.word_test.word_before_test_fail_operate(mine_input_answer, len(right_words), is_before_test=True)
                self.word_test.submit_btn().click()
                time.sleep(1)
                if not self.word_test.wait_check_start_study_page():
                    self.base_assert.except_error('点击继续学习, 未进入错词新学开始页面')
                else:
                    if len(right_words) != int(self.word_test.page_words_count()[1]):
                        self.base_assert.except_error('页面显示完成个数与测试正确个数不一致')

            if self.word_test.wait_check_start_study_page():
                start_content = self.home.start_text()
                print(start_content, '\n')
                content_num = re.findall(r'\d+', self.home.content_desc())
                print('content_num:', content_num)
                unit_total_words = int(content_num[0])
                if len(right_words) == unit_total_words:
                    if "重新学习" not in start_content:
                        self.base_assert.except_error("学前测试已做全对, 页面提示内容不是重新学习提示")
                if len(content_num) == 2:
                    if int(content_num[-1]) != len(right_words):
                        self.base_assert.except_error("页面显示完成个数与测试正确个数不一致")
                self.home.exit_icon().click()
コード例 #10
0
    def test_error_note(self):
        wrong_banks = self.home.read_data_from_file('wrong.json')
        wrong_answer_info = {x: wrong_banks[x][0] for x in wrong_banks}
        SelectCoursePage().select_course_operate('地理',
                                                 card_index=0,
                                                 book_index=0)
        if self.home.wait_check_home_page():
            page_wrong_num = self.home.error_num()
            if page_wrong_num != len(list(wrong_banks.keys())):
                self.base_assert.except_error('页面错题个数与记录错题个数不一致')

            # 做对一题验证错题数是否减少
            self.home.error_book().click()
            if self.home.wait_check_start_study_page():
                print(self.home.start_text())
                self.home.click_start_button()
            if self.game.wait_check_hk_wrap_page():
                attr = self.game.game_container()
                bank_id = self.game.bank_id()
                if attr == 'dx-container':
                    SingleChoiceGame().section_single_choice_operate(
                        all_do_right=True,
                        answer_info=wrong_answer_info,
                        do_one=True)
                elif attr == 'bq-container':
                    FillBlankGame().fill_blank_operate(
                        all_do_right=True,
                        answer_info=wrong_answer_info,
                        do_one=True)
                del wrong_banks[bank_id]
                self.home.exit_icon().click()
                time.sleep(2)
            if self.home.wait_check_home_page():
                after_wrong_num = self.home.error_num()
                print('做对之后的错题数:', after_wrong_num)
                print('计算错题数:', page_wrong_num - 1)
                if after_wrong_num != page_wrong_num - 1:
                    self.base_assert.except_error("已经做对一道错题,但是错题数未减少")

            # 清空错题本, 验证错题间隔
            self.home.error_book().click()
            if self.home.wait_check_start_study_page():
                self.home.click_start_button()

            dx_count = len(
                [x for x in list(wrong_banks.values()) if 'dx' in x])
            tk_count = len(
                [x for x in list(wrong_banks.values()) if 'tk' in x])
            wrong_note = {}
            interval_counter = []
            dx_wrong_counter, tk_wrong_counter = [0], [0]
            wrong_bank_info, wrong_choice_info = {}, {}
            all_do_right = False
            while self.game.wait_check_hk_wrap_page():
                attr = self.game.game_container()
                if attr == 'dx-container':
                    SingleChoiceGame().section_single_choice_operate(
                        all_do_right=all_do_right,
                        answer_info=wrong_answer_info,
                        bank_count=dx_count,
                        interval_counter=interval_counter,
                        wrong_counter=dx_wrong_counter,
                        wrong_note=wrong_note,
                        wrong_choice_info=wrong_choice_info)
                elif attr == 'bq-container':
                    FillBlankGame().fill_blank_operate(
                        all_do_right=all_do_right,
                        answer_info=wrong_answer_info,
                        bank_count=tk_count,
                        interval_counter=interval_counter,
                        wrong_note=wrong_note,
                        wrong_counter=tk_wrong_counter,
                        wrong_bank_info=wrong_bank_info)
            print(interval_counter)
            if self.home.wait_check_start_study_page():
                print(self.home.start_text())
                self.home.exit_icon().click()

            if self.home.wait_check_home_page():
                if self.home.error_num() != 1:
                    self.base_assert.except_error(
                        "清除错题本时做错一道题,退出后页面的错题个数不为1,错题未保留在错题本中")
コード例 #11
0
    def test_error_book(self):
        if self.home.wait_check_home_page():
            SelectCoursePage().select_course_operate('英语',
                                                     card_index=CARD_INDEX,
                                                     book_index=BOOK_INDEX)
        if self.home.wait_check_home_page():
            stu_id = self.game.data.get_student_id(STUDENT_ACCOUNT)
            book_id = self.home.driver.current_url.split('/')[-1]
            print('书籍id:', book_id)
            print(self.home.wordbook_tip_content())
            pro_path = os.path.abspath('.')
            with open(pro_path + '\\app\\wordbook\\test_data\\wrong.json',
                      'r') as f:
                wrong_record = json.load(f)
            self.home.click_error_book_btn()
            tip_content = self.home.start_text()
            print(tip_content)
            if len(wrong_record):
                if '易错词' not in tip_content:
                    self.base_assert.except_error('★★★ 错误列表不为空, 但是页面未提示有易错词存在')
                else:
                    self.home.click_start_button()
            else:
                if '暂无' not in tip_content:
                    self.base_assert.except_error('★★★ 错误列表为空, 但是页面未提示继续努力')
                else:
                    self.home.exit_icon().click()
            before_fluency = {
                x: self.game.data.get_explain_fluency_by_word_id(stu_id, x)
                for x in list(wrong_record.keys())
            }
            second_wrong_words = []
            wrong_id_list = []
            wrong_count = [0, 0]
            while self.game.wait_check_container_page():
                game_container, game_mode, explain_id = self.game.game_container(
                )
                if game_container == 'hydc-container':
                    RestoreWordPage().error_note_restore_word_operate(
                        stu_id,
                        book_id,
                        wrong_id_list,
                        second_wrong_words,
                        wrong_count=wrong_count)
                elif game_container == 'dcpx-container':
                    SpellWordPage().error_note_spell_game_operate(
                        stu_id,
                        book_id,
                        second_wrong_words,
                        wrong_count=wrong_count)
            ReciteWordPage().check_recite_word_fluency_operate(
                stu_id, before_fluency)
            if wrong_count[0] != 5:
                self.base_assert.except_error('还原单词错题次数不为5')

            if any([
                    x not in list(set(wrong_id_list))
                    for x in list(wrong_record.keys())
            ]):
                self.base_assert.except_error(
                    '记录的错题不在错题再练列表中, 错题再练列表{}, 记录错题列表{}'.format(
                        str(wrong_id_list), str(list(wrong_record.keys()))))
            self.home.exit_icon().click()
コード例 #12
0
    def test_exam_operate(self, vocab_do_right, spell_do_right):
        if self.home.wait_check_home_page():
            SelectCoursePage().select_course_operate('英语',
                                                     card_index=CARD_INDEX,
                                                     book_index=BOOK_INDEX)
        if self.home.wait_check_home_page():
            stu_id = self.game.data.get_student_id(STUDENT_ACCOUNT)
            book_id = self.home.driver.current_url.split('/')[-1]
            print('书籍id:', book_id)
            print(self.home.wordbook_tip_content(), '\n')
            unit_list = self.home.unit_list()
            unit_index = 0
            unit_name = unit_list[unit_index].text
            unit_id = self.game.data.get_unit_catalog_id(book_id, unit_name)
            unit_list[unit_index].click()
            self.home.click_test_tab()
            time.sleep(2)
            print(self.exam.tab_content())
            exam_labels = self.exam.exam_labels()
            unit_translation_ids = self.game.data.get_unit_word_translations_ids(
                unit_id)
            reform_unit_ids = str(unit_translation_ids).replace('[',
                                                                '').replace(
                                                                    ']', '')
            label_info = {}
            for i in range(len(exam_labels)):
                label = self.exam.exam_labels()[i]
                label_text = label.text.strip()
                label_count = int(re.findall(r'\d+', label_text)[0])
                if '今日新学' in label_text:
                    db_data = self.game.data.get_unit_word_id_today(
                        stu_id, reform_unit_ids)
                elif '已学' in label_text:
                    db_data = self.game.data.get_unit_word_id_already(
                        stu_id, reform_unit_ids)
                else:
                    db_data = self.game.data.get_unit_all_word_id(
                        stu_id, reform_unit_ids)
                label_info[label_text.split('(')[0]] = db_data
                if len(db_data) != label_count:
                    self.base_assert.except_error(
                        '页面显示的单词数与查询单词数不一致, 查询数为%d,页面单词数%d' %
                        (len(db_data), label_count))

                label.click()
                time.sleep(1)
                if 'is-checked' not in label.get_attribute('class'):
                    self.base_assert.except_error('★★★ 点击{},但是页面显示未点中'.format(
                        label.text))

                for x in self.exam.label_buttons():
                    if label_count == 0:
                        if 'is-disabled' not in x.get_attribute('class'):
                            self.base_assert.except_error(
                                '★★★ 今日学习个数为0,{}按钮未置灰'.format(x.text))
                    else:
                        if 'is-disabled' in x.get_attribute('class'):
                            self.base_assert.except_error(
                                '★★★ 今日学习个数不为0,{}按钮置灰'.format(x.text))

            print('label_info:', label_info)
            exam_info = {}
            unit_exam_label = self.exam.exam_labels()[-1]
            db_words = label_info['单元卷']
            print('单元单词id:', db_words)
            unit_exam_label.click()
            time.sleep(1)
            self.exam.unit_listening_btn().click()
            exam_info[unit_name + '- 单元听写'] = self.exam.exam_game_operate(
                self.stu_id,
                book_id,
                db_words,
                exam_name_suffix='单元听写',
                vocab_right=vocab_do_right,
                spell_right=spell_do_right)

            if self.exam.wait_check_exam_type_page():
                select_label_index = random.choice([1, 2])
                check_ids = label_info[
                    '已学'] if select_label_index == 1 else label_info['单元卷']
                already_label = self.exam.exam_labels()[select_label_index]
                already_label.click()
                time.sleep(1)
                if self.exam.online_test_btn().is_enabled():
                    self.exam.online_test_btn().click()
                    if self.exam.wait_check_exam_bank_type_page():
                        english_to_hans_checkbox = self.exam.bank_type_checkbox(
                        )[0]
                        if 'is-checked' not in english_to_hans_checkbox.get_attribute(
                                'class'):
                            self.base_assert.except_error('测试类型没有默认选择英译汉')
                        another_bank_type = random.choice(
                            self.exam.bank_type_checkbox()[1:])
                        another_bank_type.click()
                        time.sleep(1)
                        self.exam.definite_btn().click()
                        exam_info[unit_name +
                                  '- 已学'] = self.exam.exam_game_operate(
                                      self.stu_id,
                                      book_id,
                                      check_ids,
                                      exam_name_suffix='已学',
                                      vocab_right=vocab_do_right,
                                      spell_right=spell_do_right)
            self.exam.exit_icon().click()
            time.sleep(2)
            print(exam_info)