示例#1
0
class MedalPage(BasePage):
    wait = WaitElement()

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

    @teststep
    def wait_check_medal_page(self):
        """勋章页面检查点"""
        locator = (By.XPATH, '//android.widget.TextView[contains(@text,"我的勋章")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_medal_img_page(self):
        locator = (By.ID, self.id_type() + 'img')
        return self.wait.wait_check_element(locator)

    @teststep
    def medals(self):
        """奖牌"""
        locator = (By.ID, self.id_type() + 'des')
        return self.wait.wait_find_elements(locator)

    @teststep
    def medal_content(self):
        """置灰奖牌的说明"""
        locator = (By.ID, self.id_type() + 'text')
        return self.wait.wait_find_element(locator).text
class PhoneReset(BasePage):
    """修改手机号页面"""
    wait = WaitElement()

    @teststep
    def wait_check_page(self):
        """以“title:手机号码”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'手机号')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def et_phone(self):
        """以“手机号”的id为依据"""
        locator = (By.ID, self.id_type() + 'et_phone')
        return self.wait.wait_find_element(locator)

    @teststep
    def verify(self):
        """以“验证码”的id为依据"""
        locator = (By.ID, self.id_type() + 'verify_input')
        return self.wait.wait_find_element(locator)

    @teststep
    def count_time(self):
        """以“获取验证码按钮”的id为依据"""
        locator = (By.ID, self.id_type() + 'count_time')
        self.wait.wait_find_element(locator).click()

    @teststep
    def btn_certain(self):
        """以“确定按钮”的id为依据"""
        locator = (By.ID, self.id_type() + 'btn_certain')
        self.wait.wait_find_element(locator).click()
示例#3
0
class HonorPage(BasePage):
    """华为7.0"""
    wait = WaitElement()

    # 拍照 华为7.0
    @teststeps
    def wait_check_camera_page(self):
        """以 “拍照键”的resource-id为依据"""
        locator = (By.ID, "com.huawei.camera:id/shutter_button")
        return self.wait.wait_check_element(locator)

    # 第一页面
    @teststep
    def click_camera_button(self):
        """以相机拍照按钮"""
        print('点击 拍照按钮')
        locator = (By.ID, "com.huawei.camera:id/shutter_button")
        self.wait.wait_find_element(locator).click()

    # 第二页面
    @teststeps
    def wait_check_retake_page(self, var=10):
        """以 “”的resource-id为依据"""
        locator = (By.ID, "com.huawei.camera:id/btn_cancel")
        return self.wait.wait_check_element(locator)

    @teststep
    def click_done_button(self):
        """相机'完成'按钮"""
        print('点击 完成按钮')
        locator = (By.ID, "com.huawei.camera:id/btn_done")
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_retake_button(self):
        """相机'retake'按钮"""
        print('点击 重拍按钮')
        locator = (By.ID, "com.huawei.camera:id/btn_cancel")
        self.wait.wait_find_element(locator).click()

    # 相册 华为7.0
    @teststep
    def wait_check_album_page(self, var=10):
        """相册 的resource-id为依据"""
        locator = (By.ID, "com.android.gallery3d:id/album_name")
        return self.wait.wait_check_element(locator)

    @teststep
    def open_album(self):
        """打开 第二个相册"""
        print('进入相册')
        locator = (By.ID, "com.android.gallery3d:id/album_name")
        self.wait.wait_find_elements(locator)[1].click()

    @teststep
    def wait_check_picture_page(self):
        """选择图片 的为依据"""
        locator = (By.ID, "com.android.gallery3d:id/head_actionmode_title")
        return self.wait.wait_check_element(locator)
示例#4
0
class MessageCenter(BasePage):
    """消息中心页面"""
    wait = WaitElement()

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

    @teststep
    def iv_read_count(self):
        """以“未读消息数”的id为依据"""
        locator = (By.ID, self.id_type() + 'iv_read')
        ele = self.wait.wait_find_elements(locator)
        return len(ele)

    @teststep
    def message_count(self):
        """以“消息总数”的class_name为依据"""
        locator = (By.CLASS_NAME, "android.widget.RelativeLayout")
        return self.wait.wait_find_elements(locator)

    @teststep
    def click_message(self):
        """以“消息”的class_name为依据"""
        locator = (By.CLASS_NAME, "android.widget.RelativeLayout")
        self.wait.wait_find_element(locator).click()

    @teststep
    def del_message(self, size, rollsize=1):
        """以“删除消息”的class_name为依据"""
        # # 设定系数
        # a = 554.0 / 1080
        # b = 1625.0 / 1794
        elements = self.message_count()
        print('len(elements):', len(elements))
        # for i in range(len(elements))

    @teststep
    def click_negative_button(self):
        """以“取消按钮”的id为依据"""
        locator = (By.ID, self.id_type() + "md_buttonDefaultNegative")
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_positive_button(self):
        """以“确认按钮”的id为依据"""
        locator = (By.ID, self.id_type() + "md_buttonDefaultPositive")
        self.wait.wait_find_element(locator).click()

    @teststep
    def back_up_button(self):
        """以“返回按钮”的class_name为依据"""
        locator = (By.CLASS_NAME, "android.widget.ImageButton")
        self.wait.wait_find_element(locator).click()
示例#5
0
class ProtocolPage(BasePage):
    """注册协议"""
    wait = WaitElement()

    @teststep
    def wait_check_page(self):
        """以“title:注册协议”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'注册协议')]")
        return self.wait.wait_check_element(locator)
示例#6
0
class Privacy(BasePage):
    """版权申诉"""
    wait = WaitElement()

    @teststep
    def wait_check_page(self):
        """以“title:版权申诉”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'版权申诉')]")
        return self.wait.wait_check_element(locator)
示例#7
0
class SimulatorPage(BasePage):
    """夜神模拟器"""
    wait = WaitElement()

    # 模拟器 5.1
    @teststep
    def wait_check_album_page(self, var=10):
        """以相册title:“选择照片”的text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'选择照片')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def choose_album_mul(self):
        """5.1 模拟器 选择相册370,720"""
        print('选择相册')
        ClickBounds().click_bounds(560, 270)
示例#8
0
class PwdReset(BasePage):
    """修改密码页面所有控件信息"""
    wait = WaitElement()

    @teststep
    def wait_check_page(self):
        """以“title:重置密码”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'重置密码')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def pwd_origin(self):
        """以“原始密码”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_origin')
        return self.wait.wait_find_element(locator)

    @teststep
    def pwd_new(self):
        """以“新密码”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_new')
        return self.wait.wait_find_element(locator)

    @teststep
    def pwd_confirm(self):
        """以“新密码二次确认”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_confirm')
        return self.wait.wait_find_element(locator)

    @teststep
    def pwd_checkbox(self):
        """以“显示密码”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_visible')
        self.wait.wait_find_element(locator).click()

    @teststep
    def confirm_button(self):
        """以“完成按钮”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_complete')
        self.wait.wait_find_element(locator).click()
示例#9
0
 def __init__(self):
     self.common = WordDataHandlePage()
     self.wait = WaitElement()
 def __init__(self):
     super().__init__()
     self.data = WordDataHandlePage()
     self.public = WorldBookPublicPage()
     self.wait = WaitElement()
     self.data_dir = 'app/honor/student/word_book_rebuild/test_data/'
示例#11
0
 def __init__(self):
     self.home = HomePage()
     self.van = VanclassPage()
     self.wait = WaitElement()
示例#12
0
class PunchActivityPage(BasePage):
    library = LibraryGamePage()
    wait = WaitElement()

    @teststep
    def wait_check_alert_punch_tip_page(self):
        locator = (
            By.XPATH,
            '//android.widget.ImageView[contains(@content-desc, "21天打卡活动")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_home_punch_notice_page(self):
        """主页的打卡提示页面检查点"""
        locator = (
            By.XPATH,
            '//android.support.v7.widget.RecyclerView/android.view.ViewGroup[2]'
        )
        return self.wait.wait_find_element(locator)

    @teststep
    def wait_check_activity_book_item_page(self):
        """打卡页面检查点"""
        locator = (By.ID, self.id_type() + 'activitie_book_item')
        return self.wait.wait_check_element(locator, timeout=10)

    @teststep
    def wait_check_class_list_page(self):
        """班级列表页面检查点"""
        locator = (By.CLASS_NAME, 'android.widget.ListView')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_punch_lock_icon_page(self, book_id):
        """打卡锁图标检查点"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[@content-desc="{}"]/following-sibling::'
            'android.widget.ImageView[@index="3"]'.format(book_id))
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_select_checkpoint_page(self):
        """选择关卡页面检查点"""
        locator = (By.ID, self.id_type() + 'progress_topic')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_share_tip_page(self):
        """炫耀一下按钮提示页面检查点"""
        locator = (By.XPATH, '//*[contains(@text, "“炫耀一下”才算完成任务呦~")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_checkpoint_continue_tip_by_index_page(self, index):
        """关卡继续提示页面检查点"""
        locator = (
            By.XPATH,
            '//android.support.v7.widget.RecyclerView/android.view.ViewGroup[@index="{}"]/'
            'android.widget.ImageView[contains(@resource-id, "tit")]'.format(
                index))
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_page_has_continue_tip_page(self):
        """检查关卡页面是否存在继续按钮"""
        locator = (
            By.XPATH,
            '//android.support.v7.widget.RecyclerView/android.view.ViewGroup/'
            'android.widget.ImageView[contains(@resource-id, "tit")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def close_alert_tip(self):
        locator = (By.XPATH, '//android.widget.ImageView[@index=1]')
        return self.wait.wait_find_element(locator)

    @teststep
    def click_alert_tip(self):
        """点击弹出的打卡页面"""
        locator = (By.XPATH, '//*[@resource-id="android:id/content"]/'
                   'android.view.ViewGroup/android.widget.ImageView')
        self.wait.wait_find_element(locator).click()

    @teststep
    def home_page_punch_tab(self):
        """主页进入打卡页面的tab"""
        locator = (
            By.XPATH,
            '//android.support.v7.widget.RecyclerView/android.view.ViewGroup[2]'
        )
        return self.wait.wait_find_element(locator)

    @teststep
    def change_class_btn(self):
        """切换班级按钮"""
        locator = (By.ID, self.id_type() + 'spinner_bar')
        return self.wait.wait_find_element(locator)

    @teststep
    def class_list(self):
        """班级列表"""
        locator = (By.ID, self.id_type() + 'spinner_bar_item')
        return self.wait.wait_find_elements(locator)

    @teststep
    def activity_title(self):
        """活动名称"""
        locator = (By.ID, self.id_type() + 'activity_title')
        return self.wait.wait_find_element(locator)

    @teststep
    def punch_books(self):
        """打卡列表"""
        locator = (By.ID, self.id_type() + 'entry_tv')
        return self.wait.wait_find_elements(locator)

    @teststep
    def punch_book_status(self, book_id):
        """打卡书籍状态"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[@content-desc="{}"]/preceding-sibling::'
            'android.widget.ImageView[contains(@resource-id, "activitie_book_item")]'
            .format(book_id))
        ele = self.wait.wait_find_element(locator)
        return self.attr.get_cont_desc(ele)

    @teststep
    def punch_book_id(self, index):
        """获取图书id"""
        locator = (By.ID, self.id_type() + 'entry_tv')
        ele = self.wait.wait_find_elements(locator)
        return self.attr.get_cont_desc(ele[index])

    @teststep
    def punch_page_back_icon(self):
        """打卡页面退出按钮"""
        locator = (By.ID, self.id_type() + 'back_but')
        return self.wait.wait_find_element(locator)

    @teststep
    def checkpoint_list(self):
        """关卡列表"""
        locator = (By.ID, self.id_type() + 'selector_circle_tv')
        return self.wait.wait_find_elements(locator)

    @teststep
    def share_btn(self):
        """炫耀一下按钮"""
        locator = (By.ID, self.id_type() + 'progress_topic')
        return self.wait.wait_find_element(locator)

    @teststep
    def close_home_activity_tip(self):
        """关闭首页的弹窗信息"""
        if self.wait_check_alert_punch_tip_page():
            self.close_alert_tip().click()
            time.sleep(1)

    @teststep
    def checkpoint_core_process(self, stu_id, activity_class_info):
        if not self.wait_check_activity_book_item_page():
            self.base_assert.except_error("从主页点击打卡tab未进入打卡页面")
        else:
            self.change_class_btn().click()
            if self.wait_check_class_list_page():
                class_list = self.class_list()
                for x in class_list:
                    class_id = self.attr.get_cont_desc(x)
                    print('班级:', x.text, '班级id:', class_id)
                    if class_id not in list(activity_class_info.keys()):
                        self.base_assert.except_error(
                            '查询本班级不存在打卡活动, 但是该班级名称出现在打卡班级列表中')
                random_index = random.randint(0, len(class_list) - 1)
                select_class = self.class_list()[random_index]
                select_class_id = self.attr.get_cont_desc(select_class)
                class_punch_info = activity_class_info[select_class_id]
                select_activity_id = class_punch_info['活动id']
                select_class.click()
                if not self.wait_check_activity_book_item_page():
                    self.base_assert.except_error('选择班级后未进入打卡页面')
                else:
                    page_activity_name = self.activity_title()
                    if class_punch_info['活动名称'] != page_activity_name:
                        self.base_assert.except_error("页面展示的活动名称与查询名称不一致")
                    if len(self.punch_books()) != len(
                            class_punch_info['书籍信息']):
                        self.base_assert.except_error('页面展示的书籍个数与查询所得个数不一致')
                PunchSqlHandle().delete_student_activity_record(
                    stu_id, select_activity_id)
                return class_punch_info['书籍信息']

    @teststep
    def punch_page_select_book_operate(self, book_info, nickname):
        """打卡页面书籍选择"""
        punch_books = self.punch_books()
        print('书籍个数:', len(punch_books))
        book_id_info = {}
        for i, x in enumerate(punch_books):
            quoted_id = self.attr.get_cont_desc(x)
            book_id = PunchSqlHandle().get_activity_book_id_by_quoted_id(
                quoted_id)
            book_id_info[quoted_id] = book_id
            if int(book_id) not in list(book_info.keys()):
                self.base_assert.except_error('此书不应在打卡书籍列表中')
            book_status = self.punch_book_status(quoted_id)
            if book_status == '0':
                if not self.wait_check_punch_lock_icon_page(quoted_id):
                    self.base_assert.except_error('图书状态不可点击, 但未发现解锁锁图标')
                x.click()
                if not Toast().find_toast('今天的书已经读完啦'):
                    self.base_assert.except_error('点击未解锁图书, 未弹出提示')
        select_quoted_id = self.punch_book_id(index=0)
        select_book_id = book_id_info[select_quoted_id]
        book_count = book_info[select_book_id]
        self.punch_books()[0].click()
        if not self.wait_check_select_checkpoint_page():
            self.base_assert.except_error('点击已解锁书籍, 未进入通关页面')
        else:
            if len(self.checkpoint_list()) != book_count:
                self.base_assert.except_error('关卡个数与数据查询个数不一致')
            if len(self.checkpoint_list()) > 10:
                self.base_assert.except_error('关卡个数大于10个')
        return select_quoted_id

    @teststep
    def checkpoint_page_operate(self, nickname, quoted_id):
        for x in range(len(self.checkpoint_list())):
            before_progress = self.attr.get_cont_desc(self.share_btn())
            print('进入关卡前的进度:', before_progress)
            self.checkpoint_list()[x].click()
            if self.library.wait_check_game_page():
                self.library.play_book_games(fq=1, half_exit=True)
            if self.wait_check_select_checkpoint_page():
                if not self.wait_check_checkpoint_continue_tip_by_index_page(
                        x):
                    self.base_assert.except_error('关卡中途退出, 未发现继续学习图标')
            if self.attr.get_cont_desc(self.share_btn()) != before_progress:
                self.base_assert.except_error('中途退出后,书籍打卡进度发生变化')

            self.checkpoint_list()[x].click()
            if self.library.wait_check_game_page():
                HomeworkGameOperate().homework_game_operate(nickname,
                                                            judge_score=False,
                                                            is_activity=True)
                if not self.wait_check_select_checkpoint_page():
                    self.click_back_up_button()
                    self.library.result.all_game.word_spell.tips_operate()

            if self.wait_check_select_checkpoint_page():
                if self.wait_check_checkpoint_continue_tip_by_index_page(x):
                    self.base_assert.except_error('已全部做完其中之一关卡内部所有题, 依然继续学习图标')
            if self.attr.get_cont_desc(self.share_btn()) == before_progress:
                self.base_assert.except_error('已全部做其中之一完关卡内部所有题,书籍打卡进度未发生变化')

        if self.wait_check_select_checkpoint_page():
            if self.attr.get_cont_desc(self.share_btn()) != '100':
                self.base_assert.except_error('已经完成所有关卡, 进入不为100')
            self.punch_page_back_icon().click()
            if self.wait_check_activity_book_item_page():
                book_status = self.punch_book_status(quoted_id)
                if book_status == '0':
                    self.base_assert.except_error(
                        '关卡全部通过, 但是未点击分享按钮,图书状态不为未完成')
                self.punch_books()[0].click()
            if self.wait_check_select_checkpoint_page():
                self.share_btn().click()
                GameCommonEle().share_page_operate()
                if self.wait_check_select_checkpoint_page():
                    self.punch_page_back_icon().click()
            if self.wait_check_activity_book_item_page():
                book_status = self.punch_book_status(quoted_id)
                if book_status != '1':
                    self.base_assert.except_error('关卡全部通过, 已点击分享按钮,图书状态不为已完成')
示例#13
0
class BuyTipsPage(BasePage):
    """购买提示 页面"""
    wait = WaitElement()

    @teststeps
    def wait_check_buy_page(self, var=20):
        """以“提示”为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'提示')]")
        return self.wait.wait_check_element(locator)

    @teststeps
    def img_judge(self):
        """判断图片 是否存在"""
        locator = (By.CLASS_NAME, 'android.widget.ImageView')
        return self.wait.wait_find_element(locator)

    @teststeps
    def tips_title(self):
        """以“标题” 的id"""
        locator = (By.ID, self.id_type() + "head_hint")
        content = self.wait.wait_find_element(locator).text
        print(content)

    @teststeps
    def tips_content(self):
        """以“提示页面 页中文案”的xpath为依据"""
        locator = (By.XPATH, self.id_type() +
                   "//android.widget.TextView[contains(@index,2)]")
        content = self.wait.wait_find_element(locator).text
        print(content)

    @teststep
    def goto_pay_button(self):
        """去购买 按钮 """
        locator = (By.ID, self.id_type() + "goto_pay")
        self.wait.wait_find_element(locator).click()

    @teststep
    def goto_verification(self):
        """购买 验证 """
        locator = (By.ID, self.id_type() + "goto_verification")
        return self.wait.wait_find_element(locator)

    # 购买 页面
    @teststeps
    def wait_check_pay_page(self):
        """以“购买”为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'购买')]")
        return self.wait.wait_find_element(locator)

    @teststep
    def st_icon(self):
        """学生头像 """
        locator = (By.ID, self.id_type() + "avatar")
        return self.wait.wait_find_element(locator)

    @teststeps
    def st_name(self):
        """学生name """
        locator = (By.ID, self.id_type() + "name")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststeps
    def st_phone(self):
        """学生 手机号"""
        locator = (By.ID, self.id_type() + "phone")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

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

    @teststeps
    def buy_hint(self):
        """购买 提示信息"""
        locator = (By.ID, self.id_type() + "pay_hint")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststeps
    def hint_info(self):
        """提示信息"""
        locator = (By.ID, self.id_type() + "hint")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststep
    def check_button(self):
        """卡前的 单选框 """
        locator = (By.ID, self.id_type() + "check")
        return self.wait.wait_find_elements(locator)

    @teststep
    def card_name(self):
        """卡的类型:月卡、季卡、半年卡、年卡 """
        locator = (By.ID, self.id_type() + "one")
        return self.wait.wait_find_elements(locator)

    @teststep
    def card_price(self):
        """卡的 价格 """
        locator = (By.ID, self.id_type() + "two")
        return self.wait.wait_find_elements(locator)

    @teststeps
    def current_card(self):
        """目前选定的是X卡"""
        locator = (By.ID, self.id_type() + "current_vip_card_hint")
        ele = self.wait.wait_find_elements(locator)
        print('目前选中的卡为:', ele.text)

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

    @teststep
    def direct_buy_button(self):
        """直接购买"""
        locator = (By.ID, self.id_type() + "pay")
        return self.wait.wait_find_element(locator)

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

    # 在线客服
    @teststeps
    def wait_check_help_page(self):
        """以“帮助中心”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'帮助中心')]")
        return self.wait.wait_check_element(locator)

    # 购买协议
    @teststeps
    def wait_check_protocol_page(self, var=20):
        """以“购买协议”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'购买协议')]")
        return self.wait.wait_check_element(locator)

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

    @teststeps
    def price_unit(self, index=1):
        """货币单位"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,0)]")
        ele = self.wait.wait_find_elements(locator)
        content = ele[index].text
        return content

    @teststeps
    def price_info(self):
        """价格"""
        locator = (By.ID, self.id_type() + 'money')
        return self.wait.wait_find_element(locator).text

    @teststeps
    def card_hint(self):
        """所购卡的 提示信息"""
        locator = (By.ID, self.id_type() + 'vip_type_hint')
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststeps
    def pay_type(self):
        """wording:支付方式"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,0)]")
        ele = self.wait.wait_find_elements(locator)
        content = ele[2].text
        print(content)

    @teststep
    def pay_icon(self):
        """微信、支付宝、代付icon """
        locator = (By.CLASS_NAME, "android.widget.ImageView")
        return self.wait.wait_find_elements(locator)

    @teststep
    def wechat_pay_check(self):
        """微信 单选框 """
        locator = (By.ID, self.id_type() + "wechat_pay_check")
        return self.wait.wait_find_element(locator)

    @teststep
    def ali_pay_check(self):
        """支付宝 单选框 """
        locator = (By.ID, self.id_type() + "ali_pay_check")
        return self.wait.wait_find_element(locator)

    @teststep
    def parent_pay_check(self):
        """家长代付 单选框 """
        locator = (By.ID, self.id_type() + "parent_pay_check")
        return self.wait.wait_find_element(locator)

    @teststeps
    def pay_mode(self, index):
        """支付方式列表 wording:微信、支付宝、代付"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,2)]")
        ele = self.wait.wait_find_elements(locator)
        print(' ', ele[index].text)

    @teststep
    def confirm_pay_button(self):
        """确认支付 按钮"""
        locator = (By.ID, self.id_type() + 'pay')
        self.wait.wait_find_element(locator).click()

    @teststeps
    def pay_delay_tips(self):
        """支付延迟 说明"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,4)]")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    # 微信支付 页面

    # 支付宝支付 页面

    # 家长代付 页面
    @teststeps
    def wait_check_replace_page(self, var=20):
        """以“家长代付”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'家长代付')]")
        return self.wait.wait_check_element(locator)

    @teststeps
    def wechat_replace_pay(self):
        """微信代付 tab"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,0)]")
        return self.wait.wait_find_element(locator)

    @teststeps
    def ali_replace_pay(self):
        """支付宝代付 tab"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,0)]")
        return self.wait.wait_find_elements(locator)[1]

    @teststeps
    def card_type(self):
        """卡的类型"""
        locator = (By.ID, self.id_type() + 'card_type')
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststeps
    def qr_code_hint(self):
        """wording:微信扫描二维码付款"""
        locator = (By.ID, self.id_type() + 'pay_type_hint')
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststeps
    def qr_code_judge(self):
        """微信二维码"""
        locator = (By.ID, self.id_type() + 'qr_code')
        return self.wait.wait_check_element(locator)

    @teststeps
    def pay_finish_tips(self):
        """支付完成 提示"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,3)]")
        return self.wait.wait_check_element(locator)

    @teststep
    def pay_finish_button(self):
        """支付完成 按钮"""
        locator = (By.ID, self.id_type() + 'pay_complete')
        self.wait.wait_find_element(locator).click()

    @teststeps
    def pay_statement(self):
        """收款公司 声明"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,5)]")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    # 支付结果 页面  -支付失败
    @teststeps
    def wait_check_pay_result_page(self):
        """以“支付结果”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'支付结果')]")
        return self.wait.wait_check_element(locator)

    @teststeps
    def pay_result_img_judge(self):
        """支付结果页 图片"""
        locator = (By.ID, self.id_type() + 'pay_result_img')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststeps
    def pay_result(self):
        """付款结果"""
        locator = (By.ID, self.id_type() + 'pay_result')
        ele = self.wait.wait_find_element(locator, timeout=5)
        print(ele.text)

    @teststeps
    def contact_services_tips(self):
        """联系客服 的提示"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,0)]")
        ele = self.wait.wait_find_element(locator, timeout=5)
        print(ele.text)

    @teststeps
    def qr_code_tips(self):
        """wording:"在线助教"客服二维码"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@index,2)]")
        return self.wait.wait_check_element(locator, timeout=5)

    # 支付结果 页面  -支付成功

    @teststeps
    def tips_goto_pay_operate(self):
        """去购买"""
        if self.wait_check_buy_page(10):
            if self.img_judge():  # 判断图片 是否存在
                print('------------------------------')
                print('购买提示页:')
                self.tips_title()
                self.tips_content()
                self.goto_pay_button()  # 去购买 按钮

                self.buy_page_direct_operate()
                HomePage().click_back_up_button()  # 返回 购买提示页
                if self.wait_check_buy_page(10):
                    self.goto_verification().click()  # 已有【提分版】, 去验证
                    Toast().find_toast('已更新账户信息')

    @teststeps
    def buy_page_direct_operate(self):
        """购买页 操作 -- 直接购买"""
        if self.wait_check_pay_page():  # 购买页 检查点
            print('------------------------------')
            print('购买页:')
            self.st_icon()  # 学生头像
            self.st_name()  # 学生name
            self.st_phone()  # 手机号

            self.buy_hint()  # 购买提示
            self.hint_info()  # 提分版 权力

            self.online_services_operate()  # 在线客服

            if self.wait_check_pay_page():
                check = self.check_button()  # 单选框
                for i in range(len(check)):
                    if GetAttribute().get_checked(check[i]) == 'true':
                        if i != 3:
                            print('❌❌❌ Error - 未默认选中 年卡')
                        else:
                            check[0].click()  # 选择季卡
                            if GetAttribute().get_checked(
                                    self.check_button()[0]) == 'true':
                                self.current_card()  # 左下角 目前选中的卡
                            else:
                                print('❌❌❌ Error - 未选中 月卡')

                card = self.card_name()  # 卡的类型
                price = self.card_price()  # 卡的价格

                if len(check) != len(card) != len(price) != 4:
                    print('❌❌❌ Error - 卡的个数有误', len(check), len(card),
                          len(price))
                else:
                    print('--------------------')
                    for j in range(len(card)):
                        print(card[j].text, price[j].text)
                    print('--------------------')

                self.buy_agreement()  # 购买协议

                self.pay_confirm_operate()  # 支付确认页

    @teststeps
    def pay_confirm_operate(self):
        """支付确认页 操作"""
        direct = self.direct_buy_button()  # 直接购买 按钮
        if GetAttribute().get_enabled(direct) == 'true':
            direct.click()  # 点击 直接购买 按钮

            if self.wait_check_pay_confirm_page():  # 支付确认 页面检查点
                print('------------------------------')
                print('支付确认页:')
                self.st_icon()  # 学生头像
                self.st_name()  # 学生name
                self.st_phone()  # 手机号

                self.online_services_operate()  # 在线客服

                unit = self.price_unit()  # 货币单位
                print(unit, self.price_info())  # 价格
                self.card_hint()  # 卡的类型说明

                print('-----------------')
                self.pay_type()  # 支付方式
                icon = self.pay_icon()  # icon

                wechat_check = self.wechat_pay_check()  # 微信单选框
                if GetAttribute().get_checked(wechat_check) == 'false':
                    print('❌❌❌ Error - 未默认选中 微信支付')

                for k in range(1, len(icon)):
                    self.pay_mode(k)  # 支付方式
                print('-----------------')

                self.pay_delay_tips()  # 支付延迟 说明
                self.parent_replace_operate()  # 家长代付

    @teststeps
    def parent_replace_operate(self):
        """家长代付页 操作"""
        parent = self.parent_pay_check()  # 家长代付 单选框
        parent.click()
        self.confirm_pay_button()  # 确认支付 按钮
        if self.wait_check_replace_page():  # 家长代付页 检查点
            print('------------------------------')
            print('家长代付页:')

            wechat_tab = self.wechat_replace_pay()  # 微信代付
            if GetAttribute().get_selected(wechat_tab) == 'false':
                print('❌❌❌ Error - 未默认选中 微信代付')
            else:
                ali_tab = self.ali_replace_pay()  # 支付宝代付
                print(ali_tab.text)
                ali_tab.click()  # 切换到 支付宝代付
                if GetAttribute().get_selected(
                        self.ali_replace_pay()) == 'false':
                    print('❌❌❌ Error - 未选中 支付宝代付')

            self.card_type()  # 卡的类型
            unit = self.price_unit(2)  # 货币单位
            print(unit, self.price_info())  # 价格

            if self.qr_code_judge():
                self.qr_code_hint()  # xx扫描二维码付款

            if not self.pay_finish_tips():  # 支付完成 提示
                print("❌❌❌ Error - 无支付完成 提示")
            self.pay_statement()  # 收款公司说明

            self.pay_finish_operate()  # 支付结果页

    @teststeps
    def pay_finish_operate(self):
        """支付结果页 操作"""
        self.pay_finish_button()  # 支付完成 按钮
        if self.wait_check_pay_result_page():  # 支付结果页 检查点
            print('------------------------------')
            print('支付结果页:')
            if self.pay_result_img_judge():
                self.pay_result()  # 支付结果
                self.contact_services_tips()  # 联系客服的提示
                if self.img_judge():
                    if not self.qr_code_tips():  # "在线助教"客服二维码
                        print('❌❌❌ Error - 无文案:"在线助教"客服二维码')

    @teststeps
    def online_services_operate(self):
        """在线客服"""
        self.online_service()  # 点击在线客服
        if self.wait_check_help_page():
            HomePage().click_back_up_button()
示例#14
0
class PixelPage(BasePage):
    """Pixel 8.1"""
    wait = WaitElement()
    # 拍照
    @teststep
    def wait_check_camera_page(self):
        """选择图片 的为依据"""
        locator = (By.ID,
                   "com.google.android.GoogleCamera:id/camera_switch_button")
        return self.wait.wait_check_element(locator)

    # 第一页面
    @teststep
    def click_retake_button(self):
        """相机'切换前置后置摄像头'按钮"""
        print('切换前置后置摄像头')
        locator = (By.ID,
                   "com.google.android.GoogleCamera:id/camera_switch_button")
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_camera_button(self):
        """以相机拍照按钮"""
        print('点击 拍照按钮')
        locator = (By.ID,
                   "com.google.android.GoogleCamera:id/center_placeholder")
        self.wait.wait_find_element(locator).click()

    @teststep
    def cancel_button(self):
        """以相机  左上角 取消按钮"""
        print('点击 取消按钮')
        locator = (By.CLASS_NAME, "android.view.View")
        self.wait.wait_find_elements(locator)[1].click()

    # 第二页面
    @teststeps
    def wait_check_retake_page(self, var=10):
        """以 “”的resource-id为依据"""
        locator = (By.ID, "com.google.android.GoogleCamera:id/retake_button")
        return self.wait.wait_check_element(locator)

    @teststep
    def click_done_button(self):
        """相机'完成'按钮"""
        print('点击 完成按钮')
        self.driver \
            .find_element_by_id("com.google.android.GoogleCamera:id/shutter_button") \
            .click()

    @teststep
    def click_retake_button(self):
        """相机'retake'按钮"""
        print('点击 重拍按钮')
        self.driver \
            .find_element_by_id("com.google.android.GoogleCamera:id/retake_button") \
            .click()

    # 相册
    @teststep
    def wait_check_album_page(self, var=10):
        """相册 的resource-id为依据"""
        locator = (By.ID, "com.google.android.apps.photos:id/title")
        try:
            WebDriverWait(self.driver, var,
                          0.5).until(lambda x: x.find_element(*locator))
            return True
        except:
            return False

    @teststep
    def open_album(self):
        """打开 第二个相册"""
        print('选择相册')
        self.driver \
            .find_elements_by_id("com.google.android.apps.photos:id/title")[2] \
            .click()

    @teststep
    def wait_check_picture_page(self):
        """图片 的class_name为依据"""
        locator = (By.CLASS_NAME, "android.view.ViewGroup")
        try:
            WebDriverWait(self.driver, 10,
                          0.5).until(lambda x: x.find_element(*locator))
            return True
        except:
            return False

    # 权限询问页面
    @teststep
    def wait_check_permission_page(self):
        """ 的id为依据"""
        locator = (By.ID, "com.android.packageinstaller:id/permission_message")
        try:
            WebDriverWait(self.driver, 5,
                          0.5).until(lambda x: x.find_element(*locator))
            return True
        except:
            return False

    @teststep
    def permission_allow_button(self):
        """允许 按钮"""
        self.driver \
            .find_element_by_id("com.android.packageinstaller:id/permission_allow_button") \
            .click()
示例#15
0
class UserInfoPage(BasePage):
    """个人信息页面"""
    wait = WaitElement()

    @teststep
    def wait_check_page(self):
        """以“title:个人信息”的xpath @text为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'个人信息')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def image(self):
        """以“头像”的id为依据
            用于判断是否有展示头像,但是具体头像内容不能判定"""
        locator = (By.ID, self.id_type() + 'avatar')
        return self.wait.wait_find_element(locator)

    @teststep
    def nickname(self):
        """以“昵称”的id为依据
            用于判断昵称修改前后是否相同,默认修改后的昵称与修改前不同"""
        locator = (By.ID, self.id_type() + 'nick')
        return self.wait.wait_find_element(locator).text

    @teststep
    def buy_page_nickname(self):
        """购买页昵称"""
        locator = (By.ID, self.id_type() + 'name')
        return self.wait.wait_find_element(locator).text

    @teststep
    def phone(self):
        """以“手机号”的id为依据
            用于判断手机号修改前后是否相同,默认修改后的手机号与修改前不同"""
        locator = (By.ID, self.id_type() + 'phone')
        return self.wait.wait_find_element(locator).text

    @teststep
    def click_image(self):
        """以“头像”的id为依据"""
        locator = (By.ID, self.id_type() + 'avatar_profile')
        self.wait.wait_find_element(locator).click()
        time.sleep(2)

    @teststep
    def click_nickname(self):
        """以“昵称”的id为依据"""
        locator = (By.ID, self.id_type() + 'nick_profile')
        self.wait.wait_find_element(locator).click()
        time.sleep(2)

    @teststep
    def click_username(self):
        """以“用户名”的id为依据"""
        locator = (By.ID, self.id_type() + 'name_profile')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_phone_number(self):
        """以“手机号”的id为依据"""
        locator = (By.ID, self.id_type() + 'phone_profile')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_password(self):
        """以“密码”的id为依据"""
        locator = (By.ID, self.id_type() + 'pwd_profile')
        self.wait.wait_find_element(locator).click()

    @teststep
    def input(self):
        """以“修改昵称/用户名/手机号的二级页面中输入框”的class_name为依据"""
        locator = (By.CLASS_NAME, 'android.widget.EditText')
        return self.wait.wait_find_element(locator)

    @teststep
    def click_negative_button(self):
        """以“取消按钮”的id为依据"""
        locator = (By.ID, self.id_type() + 'md_buttonDefaultNegative')
        self.wait.wait_find_element(locator).click()

    @teststep
    def positive_button(self):
        """以“确认按钮”的id为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'确定')]")
        ele = self.wait.wait_find_element(locator)
        value = ele.get_attribute('enabled')
        return value

    @teststep
    def click_positive_button(self):
        """以“确认按钮”的id为依据"""
        locator = (By.ID, self.id_type() + 'md_buttonDefaultPositive')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_photograph(self):
        """以“拍照”的xpath @index为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'拍照')]")
        self.wait.wait_find_element(locator).click()
        print('点击 拍照 按钮')

    @teststep
    def click_album(self):
        """以“从相册选择”的xpath @index为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'从相册选择')]")
        self.wait.wait_find_element(locator).click()
        print('点击 从相册选择 按钮')

    @teststep
    def click_block(self):
        """点击页面空白区域"""
        ClickBounds().click_bounds(540, 300)

    @teststep
    def back_up_button(self):
        """以“返回按钮”的class name为依据"""
        locator = (By.CLASS_NAME, "android.widget.ImageButton")
        self.wait.wait_find_element(locator).click()

    @teststeps
    def back_up(self):
        """从个人信息页 返回主界面"""
        if self.wait_check_page():
            self.back_up_button()  # 返回按钮
            if UserCenterPage().wait_check_user_center_page():  # 页面检查点
                HomePage().click_tab_hw()
示例#16
0
class LoginWebPage(BaseDriverPage):
    wait = WaitElement()

    @teststep
    def wait_check_login_page(self):
        """登录页面检查点"""
        locator = (By.CLASS_NAME, "login-form")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_identity_page(self):
        """身份选择页面检查点"""
        locator = (By.CLASS_NAME, "identity-form")
        return self.wait.wait_check_element(locator)

    @teststep
    def close_page_btn(self):
        """关闭页面"""
        locator = (By.CLASS_NAME, 'icon-cross')
        return self.wait.wait_find_element(locator)

    @teststep
    def username(self):
        """用户名"""
        locator = (By.CSS_SELECTOR, '.login-form input:nth-child(1)')
        return self.wait.wait_find_element(locator)

    @teststep
    def password(self):
        """密码"""
        locator = (By.CSS_SELECTOR, '.login-form input:nth-child(2)')
        return self.wait.wait_find_element(locator)

    @teststep
    def login_btn(self):
        """登录"""
        locator = (By.CSS_SELECTOR, '.login-form  .btn')
        return self.wait.wait_find_element(locator)

    @teststep
    def teacher_ele(self):
        """自由/在编教师"""
        locator = (By.CSS_SELECTOR, '.identity-form  .select img[alt$="教师"]')
        return self.wait.wait_find_element(locator)

    @teststep
    def head_pic_icon(self):
        """头像"""
        locator = (By.CSS_SELECTOR, '.menu .name')
        return self.wait.wait_find_element(locator)

    @teststep
    def logout_btn(self):
        """退出"""
        locator = (By.CSS_SELECTOR, '.menu .list a')
        return self.wait.wait_find_elements(locator)[1]

    @teststep
    def login_operate(self, teacher_account=TeacherAccount.Account[-1][0],
                      teacher_pass=TeacherAccount.Account[-1][1]):
        """登录操作"""
        if self.wait_check_login_page():
            self.username().click()
            self.username().send_keys(teacher_account)
            self.password().send_keys(teacher_pass)
            self.login_btn().click()
            time.sleep(2)
            if self.wait_check_identity_page():
                self.teacher_ele().click()
                time.sleep(2)

    @teststep
    def logout_operate(self):
        """账号退出操作"""
        self.head_pic_icon().click()
        time.sleep(0.5)
        self.logout_btn().click()
示例#17
0
class WebHomePage(BaseDriverPage):
    wait = WaitElement()

    @teststep
    def wait_check_home_page(self):
        """首页页面检查点"""
        locator = (By.ID, 'logo')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_test_class_page(self):
        """测试班级页面检查点 """
        locator = (By.XPATH, '//*[contains(text(),"MVP")]')
        return self.wait.wait_check_element(locator, timeout=5)


    @teststep
    def wait_check_tips_page(self):
        """首页页面检查点"""
        time.sleep(2)
        locator = (By.CSS_SELECTOR, '.el-dialog__wrapper:not([style="display: none;"]) .el-dialog__header')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_no_more_remind_page(self):
        """首页页面检查点"""
        time.sleep(2)
        locator = (By.CSS_SELECTOR, '.el-dialog__wrapper:not([style="display: none;"]) .el-checkbox__input')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_empty_blanket_page(self):
        """题筐为空页面检查点"""
        time.sleep(2)
        locator = (By.CSS_SELECTOR, '.testbank-list .empty-block')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_delete_tip_page(self):
        time.sleep(2)
        locator = (By.CLASS_NAME, 'el-message-box__content')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_class_page(self):
        """单词本页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[contains(text(), "布置日期")]')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_blanket_page(self):
        """题筐页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[contains(text(), "生成试卷")]')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_assign_homework_page(self):
        """布置试卷/作业页面检查点"""
        time.sleep(2)
        locator = (By.ID, 'homework-student-list-box')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def click_logo(self):
        """点击在线助教logo"""
        locator = (By.ID, 'logo')
        self.wait.wait_find_element(locator).click()
        time.sleep(2)

    @teststep
    def blanket_tab(self):
        """题筐tab"""
        locator = (By.CSS_SELECTOR, '.head-container a[href$=testbank-cart]')
        return self.wait.wait_find_element(locator)

    @teststep
    def blanket_bank_num(self):
        """题筐内的题数"""
        locator = (By.CSS_SELECTOR, '.head-container a[href$=testbank-cart] .highlight')
        ele = self.wait.wait_find_element(locator)
        print('题筐内题数:', ele.text)
        return int(ele.text)

    @teststep
    def no_more_remind_checkbox(self):
        """不在题型按钮"""
        locator = (By.CSS_SELECTOR, '.el-dialog__wrapper:not([style="display: none;"]) .el-checkbox__input')
        return self.wait.wait_find_element(locator)

    @teststep
    def tip_content(self):
        """提示内容"""
        locator = (By.CSS_SELECTOR, '.el-dialog__wrapper:not([style="display: none;"]) .el-dialog__body')
        return self.wait.wait_find_element(locator).text

    @teststep
    def delete_tip_content(self):
        """删除提示内容"""
        locator = (By.CSS_SELECTOR, '.el-message-box__message')
        return self.wait.wait_find_element(locator).text

    @teststep
    def click_confirm_delete_btn(self):
        """点击删除提示的确定按钮"""
        locator = (By.CSS_SELECTOR, '.el-message-box__btns .el-button--primary')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_no_more_tip(self):
        """不再提醒"""
        locator = (By.CSS_SELECTOR, '.el-checkbox__input .el-checkbox__original')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_confirm_btn(self):
        """点击确定按钮"""
        locator = (By.CSS_SELECTOR, '.el-dialog__wrapper:not([style="display: none;"]) '
                                    '.dialog-footer .el-button--primary')
        self.wait.wait_find_element(locator).click()

    @teststep
    def select_test_class(self):
        """选择测试班级"""
        locator = (By.CSS_SELECTOR, '.vanclass-list li:last-child .el-checkbox__inner')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_more_class(self):
        """更多班级"""
        locator = (By.CSS_SELECTOR, '.toggle-link')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_test_class(self):
        """点击测试班级"""
        locator = (By.CSS_SELECTOR, '#class-list a:last-child')
        self.wait.wait_find_element(locator).click()

    @teststep
    def homework_name(self):
        """作业名称"""
        locator = (By.CSS_SELECTOR, '.table-list .homework-name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def delete_btn(self):
        """删除按钮"""
        locator = (By.CSS_SELECTOR, '.controls .icon-cross')
        return self.wait.wait_find_elements(locator)

    @teststep
    def mine_bank_pool(self):
        """我的题库"""
        locator = (By.CSS_SELECTOR, '.list a[href$="myresource"]')
        return self.wait.wait_find_element(locator)

    @teststep
    def library_icon(self):
        """图书馆图标"""
        locator = (By.CSS_SELECTOR, '.list a[href$="library"]')
        return self.wait.wait_find_element(locator)

    @teststep
    def mine_pool_bank_type_tab(self):
        """我的题库上方题型tab按钮"""
        locator = (By.CSS_SELECTOR, '.tab-group .tab')
        return self.wait.wait_find_elements(locator)

    @teststep
    def mine_pool_like_or_my_tab(self):
        """我的题库中收藏或者我的tab"""
        locator = (By.CSS_SELECTOR, '.page-container a')
        return self.wait.wait_find_elements(locator)

    @teststep
    def tag_list(self):
        """标签列表"""
        locator = (By.CSS_SELECTOR, '.tag-wrapper .tag')
        return self.wait.wait_find_elements(locator)

    @teststep
    def select_all_checkbox(self):
        """全选按钮"""
        locator = (By.CSS_SELECTOR, 'thead .el-checkbox')
        return self.wait.wait_find_element(locator)

    @teststep
    def blanket_page_select_all_checkbox(self):
        """题筐页面全选按钮"""
        locator = (By.CSS_SELECTOR, '.content .el-checkbox')
        return self.wait.wait_find_element(locator)

    @teststep
    def join_blanket(self):
        """加入题筐按钮"""
        locator = (By.CSS_SELECTOR, '.head-banner-container .controls .el-button')
        return self.wait.wait_find_element(locator)

    @teststep
    def multi_like_or_delete_btn(self):
        """批量删除或者收藏按钮"""
        locator = (By.CSS_SELECTOR, '.content .item')
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_control_btn(self):
        """生成试卷/题单/作业按钮"""
        locator = (By.CSS_SELECTOR, '.controls .el-button')
        return self.wait.wait_find_elements(locator)

    @teststep
    def select_test_class_operate(self):
        """选择测试班级操作"""
        if not self.wait_check_test_class_page():
            self.click_more_class()
            time.sleep(1)
        self.click_test_class()

    @teststep
    def tips_operate(self):
        """提示信息处理"""
        if self.wait_check_tips_page():
            print(self.tip_content(), '\n')
            if self.wait_check_no_more_remind_page():
                self.no_more_remind_checkbox().click()
            self.click_confirm_btn()
            time.sleep(2)


    @teststep
    def tip_box_operate(self):
        """删除作业提示处理"""
        if self.wait_check_delete_tip_page():
            print(self.delete_tip_content(), '\n')
            self.click_confirm_delete_btn()
            time.sleep(5)
class ListenGamePage(BasePage):
    home = HomePage()
    wait = WaitElement()
    all_game = AllGameClass()

    @teststep
    def wait_check_gaming_page(self):
        """以游戏界面计时的id作为根据"""
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text,"待完成:")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_red_hint_page(self):
        """听后选择页面检查点"""
        locator = (By.ID, self.id_type() + 'tv_hint')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_image_page(self):
        """听音选图 -- 以题号的id作为根据"""
        locator = (By.ID, self.id_type() + 'num')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_rich_page(self):
        """听音连句页面检查点"""
        locator = (By.ID, self.id_type() + 'rich_text')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_result_page(self):
        """结果检查点 以打卡的id作为依据"""
        locator = (By.ID, '{}today_minute'.format(self.id_type()))
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_error_hint_page(self):
        """不达标字样提示页面检查点"""
        locator = (By.ID, '{}error_hint'.format(self.id_type()))
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def today_excise_time(self):
        """今日已练时间"""
        locator = (By.ID, self.id_type() + 'today_minute')
        return self.wait.wait_find_element(locator).text

    @teststep
    def excise_date(self):
        """练习日期"""
        locator = (By.ID, self.id_type() + 'date')
        return self.wait.wait_find_element(locator).text

    @teststep
    def excise_correct_rate(self):
        """正确率"""
        locator = (By.ID, self.id_type() + 'right_rate')
        return self.wait.wait_find_element(locator).text

    @teststep
    def error_hint(self):
        """正确率不足60%提示"""
        locator = (By.ID, self.id_type() + 'error_hint')
        return self.wait.wait_find_element(locator)

    @teststep
    def punch_button(self):
        """打卡"""
        locator = (By.ID, self.id_type() + 'share')
        return self.wait.wait_find_element(locator)

    @teststep
    def check_answer_button(self):
        """查看答案"""
        locator = (By.ID, self.id_type() + 'detail')
        return self.wait.wait_find_element(locator)

    @teststep
    def redo_button(self):
        """重练此题"""
        locator = (By.ID, self.id_type() + 'again')
        return self.wait.wait_find_element(locator)

    @teststep
    def rank_button(self):
        """排行榜"""
        locator = (By.ID, self.id_type() + 'rank')
        return self.wait.wait_find_element(locator)

    @teststep
    def audio_button(self):
        """声音按钮"""
        locator = (By.ID, self.id_type() + 'play_voice')
        return self.wait.wait_find_element(locator)

    @teststep
    def split_sentence_word(self):
        """候选单词"""
        locator = (By.ID, self.id_type() + "text")
        ele = self.wait.wait_find_element(locator)
        word_list = [i for i in ele if i.text != '']
        return word_list

    @teststep
    def correct_answer(self):
        """正确答案"""
        locator = (By.ID, self.id_type() + 'tv_right')
        return self.wait.wait_find_element(locator)

    @teststep
    def play_listen_game_process(self):
        bank_info = 0
        bank_type = 0
        if self.wait_check_image_page():
            print('===== 听音选图 =====\n')
            bank_info = self.all_game.image_choice.image_choice_lib_hw_operate(
                fq=1, half_exit=False)
            bank_type = 1

        elif self.wait_check_rich_page():
            print('===== 听音连句 =====\n')
            bank_info = self.all_game.sentence_listen_link.sentence_listen_link_lib_hw_operate(
                fq=1, half_exit=False)
            bank_type = 2

        elif self.wait_check_red_hint_page():
            print('===== 听后选择 =====\n')
            bank_info = self.all_game.listen_choice.listen_choice_lib_hw_operate(
                fq=1, half_exit=False)
            bank_type = 3

        return bank_type, bank_info

    @teststeps
    def answer_page_operate(self, bank_type, bank_info):
        if self.wait_check_result_page():
            print('----- < 结果页 > -----\n')
            today_excise = self.today_excise_time()
            date = self.excise_date()
            rate = self.excise_correct_rate()
            print(today_excise, '\n', date, '\n', rate, '\n')
            if self.wait_check_error_hint_page():
                print(self.error_hint().text, '\n')
            self.punch_button().click()
            self.all_game.listen_choice.share_page_operate()
            if self.wait_check_result_page():
                self.check_answer_button().click()

            if ResultPage().wait_check_answer_page():
                if bank_type == 1:
                    print('----- < 听音选图答案详情页 > -----', '\n')
                    self.all_game.image_choice.image_choice_result_operate(
                        bank_info)

                elif bank_type == 2:
                    print('----- < 听音连句答案详情页 > -----', '\n')
                    self.all_game.sentence_listen_link.sentence_listen_link_result_operate(
                        bank_info)

                elif bank_type == 3:
                    print('----- < 听后选择答案详情页 > -----', '\n')
                    self.all_game.single_choice.single_choice_result_operate(
                        bank_info, '听后选择')
                self.home.click_back_up_button()
 def __init__(self):
     self.home = HomePage()
     self.wait = WaitElement()
示例#20
0
class AssignHomeworkPage(WebHomePage):
    wait = WaitElement()

    @teststep
    def wait_check_bank_pool_page(self):
        """题库页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[contains(text(),"推荐到学校")]')
        self.wait.wait_check_element(locator)

    @teststep
    def wait_check_bank_list_page(self):
        """大题列表页面检查点"""
        time.sleep(2)
        locator = (By.CLASS_NAME, 'el-cascader__label')
        self.wait.wait_check_element(locator)

    @teststep
    def nav_bars(self):
        """头部按钮"""
        locator = (By.CSS_SELECTOR, '.nav a')
        return self.wait.wait_find_elements(locator)

    @teststep
    def type_tab(self):
        """题型选项"""
        locator = (By.CSS_SELECTOR, '.tab-group .tab')
        return self.wait.wait_find_elements(locator)

    @teststep
    def all_type_selector(self):
        """所有分类下拉按钮"""
        locator = (By.CSS_SELECTOR, '.el-cascader__label')
        return self.wait.wait_find_element(locator)

    @teststep
    def type_name_list(self):
        """类型列表"""
        locator = (By.CSS_SELECTOR, '.el-cascader-menu  .el-cascader-menu__item--extensible')
        return self.wait.wait_find_elements(locator)

    @teststep
    def game_name_list(self):
        """游戏名称列表"""
        locator = (By.CSS_SELECTOR, '.el-cascader-menus > ul:nth-child(2) li')
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_list(self):
        """大题列表"""
        locator = (By.CSS_SELECTOR, '.testbank-name .title')
        return self.wait.wait_find_elements(locator)

    @teststep
    def homework_name_input_warp(self):
        """作业名称输入栏"""
        locator = (By.CSS_SELECTOR, '.el-input__inner[placeholder="请填写作业名称"]')
        return self.wait.wait_find_element(locator)

    @teststep
    def publish_homework(self):
        """发布作业"""
        locator = (By.CSS_SELECTOR, '.controls .el-button')
        self.wait.wait_find_element(locator).click()

    @teststep
    def get_bank_label(self, bank_name):
        """根据大题名称获取大题checkbox"""
        locator = (By.XPATH, '//*[contains(text(),"{}")]/../preceding-sibling::label/span/span'.format(bank_name))
        return self.wait.wait_find_element(locator)

    @teststep
    def delete_homework_operate(self, hw_name):
        self.click_test_class()
        if self.wait_check_class_page():
            print('==== 删除已存在test作业 =====\n')
            while True:
                homework_list = self.homework_name()
                test_homework_ele = [x for x in homework_list if hw_name in x.text]
                if not test_homework_ele:
                    break
                else:
                    test_homework_ele[0].click()
                    print('删除作业:', test_homework_ele[0].text)
                    time.sleep(1)
                    self.delete_btn().click()
                    self.tip_box_operate()
                    time.sleep(2)


    @teststeps
    def assign_homework_operate(self):
        LoginWebPage().login_operate()
        if self.wait_check_home_page():
            self.click_logo()
            time.sleep(2)
            self.delete_homework_operate()
            self.nav_bars()[1].click()
            if self.wait_check_bank_pool_page():
                self.type_tab()[1].click()
                time.sleep(2)
                for x in [('单词练习', '连连看'), ('口语练习', '口语跟读')]:
                    print('选择习题:', x)
                    if self.wait_check_bank_list_page():
                        self.all_type_selector().click()
                        time.sleep(2)
                        type_list = self.type_name_list()
                        for type_ele in type_list:
                            if x[0] in type_ele.text:
                                type_ele.click()
                                time.sleep(2)
                                break

                        bank_list = self.game_name_list()
                        for bank_ele in bank_list:
                            if x[1] in bank_ele.text:
                                bank_ele.click()
                                time.sleep(2)
                                break
                        time.sleep(2)

                        random_ele = random.choice(self.bank_list())
                        self.get_bank_label(random_ele.get_attribute('title')).click()
                        self.join_blanket()
                        self.tips_operate()
                        time.sleep(3)


                self.nav_bars()[-1].click()
                if self.wait_check_blanket_page():
                    time.sleep(2)
                    self.select_all_checkbox().click()
                    self.bank_control_btn()[-1].click()
                    self.tip_box_operate()
                    if self.wait_check_assign_homework_page():
                        self.homework_name_input_warp().send_keys('test')
                        self.select_test_class()
                        self.publish_homework()
                        self.tips_operate()
示例#21
0
 def __init__(self):
     self.sql_handler = WordTestSqlHandler()
     self.wait = WaitElement()
示例#22
0
class ResultPage(BasePage):
    all_game = AllGameClass()
    wait = WaitElement()

    @teststep
    def wait_check_result_page(self):
        """结果页面检查点"""
        locator = (By.ID, self.id_type() + 'detail')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_medal_page(self):
        """勋章页面检查点"""
        locator = (By.ID, self.id_type() + 'share_img')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_answer_page(self):
        """查看答案页面"""
        locator = (By.XPATH, '//*[@text="查看答案"]')
        return self.wait.wait_check_element(locator)

    @teststep
    def check_result_btn(self):
        """查看答案"""
        locator = (By.ID, self.id_type() + "detail")
        return self.wait.wait_find_element(locator)

    @teststep
    def again_btn(self):
        """错题再练 再练一次按钮"""
        locator = (By.ID, self.id_type() + "again")
        return self.wait.wait_find_element(locator)

    @teststep
    def correct_rate(self):
        """正确率"""
        locator = (By.ID, self.id_type() + "correct_rate")
        ele = self.wait.wait_find_element(locator)
        return int(re.findall(r'\d+', ele.text)[0])

    @teststep
    def score(self):
        """积分"""
        locator = (By.ID, self.id_type() + "score")
        ele = self.wait.wait_find_element(locator)
        return int(re.findall(r'\d+', ele.text)[0])

    @teststep
    def star(self):
        """星星"""
        locator = (By.ID, self.id_type() + "star")
        ele = self.wait.wait_find_element(locator)
        return int(re.findall(r'\d+', ele.text)[0])

    @teststep
    def time(self):
        """时间"""
        locator = (By.ID, self.id_type() + "time")
        return self.wait.wait_find_element(locator)

    @teststep
    def explains(self):
        locator = (By.ID, self.id_type() + "explain")
        return self.wait.wait_find_elements(locator)

    @teststep
    def result_word(self, explain):
        """单词"""
        locator = (By.XPATH, '//android.widget.TextView[@text="%s"]/'
                   'preceding-sibling::android.widget.TextView' % explain)
        return self.wait.wait_find_element(locator).text

    @teststep
    def check_bank_result(self, game_name, mine_answer, *, has_medal=False):
        """
        结果页面答案对照
        :param game_name: 游戏名称
        :param mine_answer: 我的答案
        :param has_medal: 是否有勋章出现
        :return: result_page_info 查看答案信息
        """
        if has_medal:
            if self.wait_check_medal_page():
                print('获取勋章')
                self.all_game.word_spell.share_page_operate()

        result_page_info = ()
        if self.wait_check_result_page():  # 进入结果页
            self.check_result_btn().click()  # 查看结果
            if self.wait_check_answer_page():
                print('----- 查看答案页面 ------\n')
                if game_name in ['猜词游戏', '还原单词', '单词拼写', '单词听写', '词汇选择']:
                    result_page_info = self.all_game.word_spell.word_game_result_check_operate(
                        mine_answer)

                elif game_name in ['完形填空', '单项选择', '阅读理解', '听后选择']:
                    result_page_info = self.all_game.single_choice.single_choice_result_operate(
                        mine_answer, game_name)

                elif game_name in ['连连看']:
                    result_page_info = self.all_game.word_match.word_match_result_operate(
                        mine_answer)

                elif game_name in ['强化炼句']:
                    result_page_info = self.all_game.sentence_strengthen.sentence_strengthen_result_operate(
                        mine_answer)

                elif game_name in ['听音连句']:
                    result_page_info = self.all_game.sentence_listen_link.sentence_listen_link_result_operate(
                        mine_answer)

                elif game_name in ['句型转换']:
                    result_page_info = self.all_game.sentence_change.sentence_change_result_operate(
                        mine_answer)

                elif game_name in ['连词成句']:
                    result_page_info = self.all_game.sentence_link.sentence_link_result_operate(
                        mine_answer)

                elif game_name in ['补全文章']:
                    result_page_info = self.all_game.complete_article.complete_article_result_operate(
                        mine_answer)

                elif game_name in ['选词填空']:
                    result_page_info = self.all_game.select_blank.select_bank_result_operate(
                        mine_answer)

                elif game_name in ['听音选图']:
                    result_page_info = self.all_game.image_choice.image_choice_result_operate(
                        mine_answer)

            self.click_back_up_button()
            return result_page_info

    @teststep
    def result_multi_data_check(self,
                                fq,
                                result,
                                *,
                                star_num=None,
                                score_num=None,
                                judge_score=False):
        """
        结果页数据校验
        :param fq:  做题次数
        :param result: 做题结果
        :param star_num: 星星数
        :param score_num:  得分数
        :param judge_score: 是否判断分数
        :return:
        """
        if self.wait_check_result_page():
            print('===== 结果页数据核对 =====\n')
            print('本次做的题数:', result[-1])
            print('本次做对题数:', result[1])
            right_rate = round(result[1] / result[-1] *
                               100) if fq == 1 else 100

            if right_rate != self.correct_rate():
                self.base_assert.except_error("准确率有误,应为" + str(right_rate) +
                                              "实际为" + str(self.correct_rate()))
            else:
                print('准确率核实正确')

            if judge_score:
                if score_num != self.score():
                    self.base_assert.except_error("积分有误, 应当为" +
                                                  str(score_num) + '页面为' +
                                                  str(self.score()))
                else:
                    print('积分核实正确')

            if star_num != self.star():
                self.base_assert.except_error('星星有误, 应为:' + str(star_num) +
                                              '页面为:' + str(self.star()))
            else:
                print('星星核实正确')

            print('===== 结果页数据核实完毕 =====\n')

            again_btn = self.again_btn()
            if fq == 2:
                if again_btn.text != '再练一遍':
                    self.base_assert.except_error('第二遍做题后, 错填再练按钮内容未变为再练一遍')
                print('-*' * 50, '\n')
            self.again_btn().click()
            time.sleep(2)
class VanclassPage(BasePage):
    """ 班级 页面"""
    wait = WaitElement()

    @teststeps
    def wait_check_page(self):
        """以“班级列表页面 添加班级 按钮”为依据"""
        locator = (By.ID, "{}add".format(self.id_type()))
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def wait_check_van_list_page(self):
        """班级列表页面检查点"""
        locator = (By.ID, "{}class_name".format(self.id_type()))
        return self.wait.wait_check_element(locator)

    @teststeps
    def wait_check_quit_vanclass(self, class_name):
        """退出班级页面检查点"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'{}')]".format(
                       class_name))
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_empty_tips(self):
        """暂时没有数据"""
        locator = (By.ID, self.id_type() + "load_empty")
        return self.wait.wait_check_element(locator, timeout=5)

    @teststeps
    def swp(self):
        self.screen_swipe_up(0.5, 0.8, 0.2, 1000)

    @teststep
    def vanclass_name(self):
        """班级名称"""
        locator = (By.ID, self.id_type() + "class_name")
        return self.wait.wait_find_elements(locator)

    @teststep
    def vanclass_no(self):
        """班号"""
        locator = (By.ID, self.id_type() + "class_no")
        return self.wait.wait_find_elements(locator)

    @teststep
    def st_count(self):
        """学生人数"""
        locator = (By.ID, self.id_type() + "count")
        return self.wait.wait_find_elements(locator)

    @teststep
    def add_class_button(self):
        """以“添加班级 按钮”的id为依据"""
        locator = (By.ID, self.id_type() + "add")
        self.wait.wait_find_element(locator).click()

    # 申请入班
    @teststeps
    def wait_check_apply_page(self):
        """以“title: 添加班级”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'添加班级')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_no_class_page(self):
        locator = (By.ID, self.id_type() + "status_error_hint_view")
        return self.wait.wait_check_element(locator)

    @teststeps
    def all_element(self):
        """页面内所有class name为android.widget.TextView的元素"""
        ele = self.driver.find_elements_by_class_name(
            "android.widget.TextView")
        content = []
        for i in range(len(ele)):
            # print(ele[i].text)
            content.append(ele[i].text)
        # print('++++++++++++++++')
        return ele, content

    @teststep
    def apply_teacher_name(self):
        """老师名称"""
        locator = (By.ID, self.id_type() + "tv_teacher_name")
        return self.wait.wait_find_element(locator).text

    @teststep
    def apply_vanclass_no(self):
        """班号"""
        locator = (By.ID, self.id_type() + "tv_class_no")
        return self.wait.wait_find_element(locator).text

    @teststep
    def remark_name_modify(self):
        """备注名称 输入框"""
        locator = (By.ID, self.id_type() + "et_remark_name")
        return self.wait.wait_find_element(locator)

    @teststep
    def apply_class_button(self):
        """以“申请入班 按钮”的id为依据"""
        locator = (By.ID, self.id_type() + "tv_apply")
        self.wait.wait_find_element(locator).click()
        time.sleep(2)

    # 班级 详情页
    @teststeps
    def wait_check_vanclass_page(self, var):
        """以“title: 班级名称”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'%s')]" % var)
        return self.wait.wait_check_element(locator)

    @teststep
    def teacher_name(self):
        """老师名称 title"""
        locator = (By.ID, self.id_type() + "tv_teacher_title")
        return self.wait.wait_find_element(locator).text

    @teststep
    def teacher_name_modify(self):
        """老师名称"""
        locator = (By.ID, self.id_type() + "tv_teacher")
        return self.wait.wait_find_element(locator).text

    @teststep
    def class_name(self):
        """班级名称 title"""
        locator = (By.ID, self.id_type() + "class_name")
        return self.wait.wait_find_elements(locator)

    @teststep
    def class_name_modify(self):
        """班级名称 编辑"""
        locator = (By.ID, self.id_type() + "tv_class_name")
        return self.wait.wait_find_element(locator).text

    @teststep
    def school_name(self):
        """学校名称"""
        locator = (By.ID, self.id_type() + "tv_school_title")
        return self.wait.wait_find_element(locator).text

    @teststep
    def school_name_modify(self):
        """学校名称 编辑"""
        locator = (By.ID, self.id_type() + "tv_school")
        return self.wait.wait_find_element(locator).text

    @teststep
    def score_ranking(self):
        """积分排行榜"""
        locator = (By.ID, self.id_type() + "rl_score_ranking")
        self.wait.wait_find_element(locator).click()

    @teststep
    def star_ranking(self):
        """星星排行榜"""
        locator = (By.ID, self.id_type() + "rl_star_ranking")
        self.wait.wait_find_element(locator).click()

    @teststep
    def vanclass_hw(self):
        """本班作业"""
        locator = (By.ID, self.id_type() + "rl_homework")
        self.wait.wait_find_element(locator).click()

    @teststep
    def quit_vanclass(self):
        """退出班级 按钮"""
        locator = (By.ID, self.id_type() + "tv_quit_class")
        self.wait.wait_find_element(locator).click()

    # 退出班级
    @teststeps
    def wait_check_quit_page(self):
        """以“title: 退出班级”为依据"""
        locator = (By.ID, self.id_type() + "quit")
        return self.wait.wait_check_element(locator)

    @teststep
    def phone_name(self):
        """手机号"""
        locator = (By.ID, self.id_type() + "tv_phone")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststep
    def code_input(self):
        """验证码 输入框"""
        locator = (By.ID, self.id_type() + "code")
        return self.wait.wait_find_element(locator)

    @teststep
    def get_code_button(self):
        """获取 验证码"""
        locator = (By.ID, self.id_type() + "count_time")
        return self.wait.wait_find_element(locator)

    @teststep
    def sonic_code_judge(self):
        """语音验证码"""
        locator = (By.ID, self.id_type() + "tv_sonic_code")
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def sonic_code(self):
        """语音验证码"""
        locator = (By.ID, self.id_type() + "tv_sonic_code")
        ele = self.wait.wait_find_element(locator)
        print(ele.text)

    @teststep
    def quit_button(self):
        """退出班级 按钮"""
        locator = (By.ID, self.id_type() + "quit")
        self.wait.wait_find_element(locator).click()

    @teststep
    def get_vanclass_id(self):
        """获取班级id"""
        vanclass_ids = []
        HomePage().click_test_vanclass()
        if self.wait_check_page():
            vanclass_ids = self.vanclass_no()
        HomePage().click_tab_hw()
        return [x.text.split(':')[1] for x in vanclass_ids]
示例#24
0
class LibraryGamePage(BasePage):
    result = ResultPage()
    wait = WaitElement()

    @teststep
    def wait_check_top_name_page(self, name):
        locator = (
            By.XPATH,
            '//android.view.ViewGroup[contains(@resource-id, "common_toolbar")]/'
            'android.widget.TextView[contains(@text,"{}")]'.format(name))
        return self.wait.wait_check_element(locator, timeout=10)

    @teststep
    def wait_check_share_page(self):
        """分享页面"""
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text,"图书分享")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_bank_list_page(self):
        """大题列表页面检查点"""
        locator = (By.ID, self.id_type() + 'tv_testbank_name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def wait_check_game_page(self):
        """游戏页面检查点"""
        locator = (By.ID, '{}progress'.format(self.id_type()))
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_share_area_page(self):
        """分享页面检查点"""
        locator = (By.ID, '{}share_area'.format(self.id_type()))
        return self.wait.wait_check_element(locator)

    @teststeps
    def wait_check_game_list_page(self, var):
        """以 小游戏的class_name为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text, %s)]" % var)
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_homework_list_page(self):
        """作业页面检查点"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@resource-id,"
                   "'{}tv_homework_name')]".format(self.id_type()))
        return self.wait.wait_check_element(locator)

    @teststep
    def homework_list(self):
        """作业列表"""
        locator = (By.ID, self.id_type() + 'tv_homework_name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def share_btn(self):
        """分享"""
        locator = (By.ID, self.id_type() + 'share')
        return self.wait.wait_find_element(locator)

    @teststep
    def share_page_menu_share_btn(self):
        """分享页面的分享按钮"""
        locator = (By.ID, self.id_type() + 'menu_share')
        return self.wait.wait_find_element(locator)

    @teststep
    def punch_share_btn(self):
        """立即打卡 -分享页面"""
        locator = (By.ID, self.id_type() + 'sign')
        return self.wait.wait_find_element(locator)

    @teststep
    def start_game_btn(self):
        """开始阅读 -做题页面"""
        locator = (By.ID, self.id_type() + 'sign_bottom')
        return self.wait.wait_find_element(locator)

    @teststep
    def bank_name_list(self):
        """大题列表"""
        locator = (By.ID, self.id_type() + 'tv_testbank_name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_type(self):
        """大题类型"""
        locator = (By.ID, self.id_type() + 'tv_testbank_type')
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_name_by_type(self, bank_type):
        """根据大题题型获取题目名称"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[@text="{}"]/../preceding-sibling::android.widget.RelativeLayout'
            '/android.widget.TextView[contains(@resource-id, "tv_testbank_name")]'
            .format(bank_type))
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_name(self):
        """大题名称"""
        locator = (By.ID, self.id_type() + 'tv_testbank_name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def bank_progress_by_name(self, bank_name):
        """根据大题名称获取"""
        locator = (
            By.XPATH,
            '//android.widget.TextView[@text="{}"]/../following-sibling::android.widget.RelativeLayout'
            '/android.widget.TextView[contains(@resource-id, "tv_testbank_status")]'
            .format(bank_name))
        ele = self.wait.wait_find_element(locator)
        return ele.text

    @teststep
    def click_bank_by_name(self, bank_name):
        """通过名称定为大题并点击"""
        locator = (By.XPATH,
                   '//android.widget.TextView[@text="{}"]'.format(bank_name))
        self.wait.wait_find_element(locator).click()

    @teststep
    def game_name(self):
        """游戏名称"""
        locator = (
            By.XPATH,
            '//*[@resource-id="{}common_toolbar"]/android.widget.TextView'.
            format(self.id_type()))
        return self.wait.wait_find_element(locator).text

    @teststep
    def check_process_change(self, bank_name, bank_progress):
        """检查大题进度变化"""
        print(self.wait_check_bank_list_page())
        if self.wait_check_bank_list_page():
            print(bank_name)
            if self.bank_progress_by_name(bank_name) != bank_progress:
                self.base_assert.except_error('中途返回进度却发生变化!')
            self.click_bank_by_name(bank_name)
            if self.wait_check_game_page():
                pass

    @teststep
    def enter_into_game(self, hw_name, bank_type):
        """进入游戏过程"""
        hw_name_list = 0
        if self.wait_check_homework_list_page():  # 页面检查点
            homework_name = []
            while True:
                for hw in self.homework_list():
                    if hw.text in homework_name:
                        continue
                    else:
                        homework_name.append(hw.text)
                        if hw_name == hw.text:
                            hw.click()
                            break
                if hw_name not in homework_name:
                    self.screen_swipe_up(0.5, 0.9, 0.4, 1000)
                else:
                    break
            if self.wait_check_game_list_page(hw_name):
                while True:
                    game_list = self.bank_type()
                    if bank_type not in [x.text for x in game_list]:
                        self.screen_swipe_up(0.5, 0.9, 0.5, 1000)
                    else:
                        if game_list[-1].text == bank_type:
                            self.screen_swipe_up(0.5, 0.9, 0.85, 1000)
                        break
            else:
                print('❌❌❌ 未进入大题列表')
        return hw_name_list

    @teststep
    def play_book_games(self,
                        fq,
                        second_ans=None,
                        nickname=None,
                        half_exit=False):
        """各种游戏过程
           fq:: 大题练习次数
           sec_answer :: 第二次练习的正确答案
           half_exit :: 是否中途退出 针对第三个脚本
           total_num :: 记录每道大题的总数
           bank_name :: 大题名称
           nickname: 昵称
        """
        if fq == 1:
            print('========== 第一次做错操作 ========== \n')
        else:
            print('========== 第二次做对操作 ========== \n')

        game_name = self.game_name()
        game_result = {}

        if game_name == "猜词游戏":
            game_result = self.result.all_game.word_guess.guess_word_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '还原单词':
            game_result = self.result.all_game.word_restore.restore_word_lib_hw_operate(
                fq, half_exit, second_ans)
        #
        elif game_name == '连连看':
            game_result = self.result.all_game.word_match.word_match_lib_hw_operate(
                fq, half_exit)

        elif game_name == '单词拼写':
            game_result = self.result.all_game.word_spell.word_spell_lib_hw_operate(
                fq, half_exit, second_ans)
        #
        elif game_name == '单词听写':
            game_result = self.result.all_game.listen_spell.listen_spell_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '词汇选择':
            game_result = self.result.all_game.vocab_choice.vocab_choice_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '句型转换':
            game_result = self.result.all_game.sentence_change.sentence_change_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '听音连句':
            game_result = self.result.all_game.sentence_listen_link.sentence_listen_link_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '强化炼句':
            game_result = self.result.all_game.sentence_strengthen.sentence_strengthen_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '连词成句':
            game_result = self.result.all_game.sentence_link.sentence_link_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '单项选择':
            game_result = self.result.all_game.single_choice.single_choice_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '补全文章':
            game_result = self.result.all_game.complete_article.complete_article_lib_hw_operate(
                fq, half_exit, second_ans)
        #
        elif game_name == '完形填空':
            game_result = self.result.all_game.cloze.cloze_game_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '阅读理解':
            game_result = self.result.all_game.read_understand.article_understand_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '选词填空':
            game_result = self.result.all_game.select_blank.select_blank_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '听后选择':
            game_result = self.result.all_game.listen_choice.listen_choice_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '听音选图':
            game_result = self.result.all_game.image_choice.image_choice_lib_hw_operate(
                fq, half_exit, second_ans)

        elif game_name == '闪卡练习':
            self.result.all_game.word_flash.play_flash_game(half_exit)

        elif game_name == '单词跟读':
            self.result.all_game.word_speak.word_speak_game_operate(
                nickname, half_exit)
        return game_name, game_result
示例#25
0
class ResignExamPage(WebHomePage):
    wait = WaitElement()

    @teststep
    def wait_check_home_page(self):
        """首页页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[text()=" 创建班级"]')
        self.wait.wait_check_element(locator)

    def wait_check_mine_item_pool_page(self):
        """我的题库页面检查点"""
        time.sleep(3)
        locator = (By.XPATH, '//*[text()="我的"]')
        self.wait.wait_check_element(locator)

    def wait_check_exam_tab_page(self):
        """试卷页面"""
        time.sleep(2)
        locator = (By.XPATH, '//*[text()="卷子名称"]')
        self.wait.wait_check_element(locator)

    def wait_check_mine_exam_page(self):
        """我的试卷页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[text()="我的自创"]')
        self.wait.wait_check_element(locator)

    def wait_check_exam_detail_page(self):
        """试卷详情页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[text()="开始答卷"]')
        self.wait.wait_check_element(locator)

    def wait_check_delete_tip_page(self):
        """删除作业提示页面检查点"""
        locator = (By.CLASS_NAME, 'el-message-box__content')
        self.wait.wait_check_element(locator)

    def wait_check_publish_tip_page(self):
        """删除作业提示页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[contains(text(),"试卷为【提分版】功能")]')
        self.wait.wait_check_element(locator)

    def wait_check_assign_page(self):
        """布置试卷页面检查点"""
        time.sleep(2)
        locator = (By.XPATH, '//*[contains(text(),"考试信息")]')
        self.wait.wait_check_element(locator)

    def logo(self):
        """logo"""
        locator = (By.ID, 'logo')
        return self.wait.wait_find_element(locator)

    def exam_label(self):
        """试卷"""
        locator = (By.CSS_SELECTOR, '.head-banner-container  .tab-group .tab')
        return self.wait.wait_find_elements(locator)[-1]

    def mine_label(self):
        """我的"""
        locator = (By.CSS_SELECTOR, '.head-bottom-nav .page-container  a')
        return self.wait.wait_find_elements(locator)[-1]

    def exam_list(self):
        """试卷列表"""
        locator = (By.CSS_SELECTOR,
                   '.page-content-container  .testbank-list tbody tr')
        return self.wait.wait_find_elements(locator)

    def exam_name(self, ele):
        """试卷名称"""
        name = ele.find_element_by_xpath('./td[1]/div/span')
        print('\n布置试卷:', name.text)
        return name

    def delete_btn(self):
        """删除试卷"""
        locator = (By.CSS_SELECTOR,
                   '.test-detail  .controls  button:nth-child(4)')
        return self.wait.wait_find_element(locator)

    def publish_confirm_btn(self):
        """发布试卷确定按钮"""
        locator = (By.CSS_SELECTOR, '.dialog-footer  .el-button--primary')
        return self.wait.wait_find_element(locator)

    def delete_confirm_btn(self):
        """删除提示信息确定按钮"""
        locator = (By.CSS_SELECTOR,
                   '.el-message-box__btns .el-button--primary')
        return self.wait.wait_find_element(locator)

    def assign_exam_btn(self):
        """布置试卷"""
        locator = (By.CSS_SELECTOR,
                   '.test-detail  .controls  button:nth-child(2)')
        return self.wait.wait_find_element(locator)

    def student_card(self):
        """学生列表"""
        locator = (By.CSS_SELECTOR, '.student-card')
        return self.wait.wait_find_elements(locator)

    def vanclass_label(self):
        """班级标签"""
        locator = (By.CSS_SELECTOR, '.choose-students li  span.name')
        return self.wait.wait_find_elements(locator)

    def publish_btn(self):
        """发布试卷按钮"""
        locator = (By.CSS_SELECTOR, '.head-banner-container  button')
        return self.wait.wait_find_element(locator)

    def reassign_exam_operate(self):
        LoginWebPage().login_operate(TeacherAccount.Account[-1][0],
                                     TeacherAccount.Account[-1][1])  # 登陆操作
        if self.wait_check_home_page():  # 进入我的试卷
            self.mine_bank_pool().click()
            if self.wait_check_mine_item_pool_page():
                self.mine_label().click()
                time.sleep(3)
                self.exam_label().click()
                time.sleep(3)
            while True:  # 若试题>4, 则删除多余部分, 若等于4 ,则随机布置一个试卷
                if len(self.exam_list()) <= 5:
                    random_index = random.randint(0, 3)
                    self.exam_name(random_index).click()
                    if self.wait_check_exam_detail_page():
                        self.assign_exam_btn().click()  # 布置试卷
                        if self.wait_check_assign_page():
                            vanclass_label = self.vanclass_label(
                            )  # 选择MVP班级所有学生
                            for x in vanclass_label:
                                if x.text == 'MVP':
                                    x.click()
                                    break
                            time.sleep(2)
                            self.publish_btn().click()  # 发布试卷
                            if self.wait_check_publish_tip_page():
                                self.driver.execute_script(
                                    "document.getElementsByClassName('dialog-footer').item(0)"
                                    ".getElementsByTagName('button').item(1).click()"
                                )
                                time.sleep(3)
                    break

                else:
                    delete_name = self.exam_name(self.exam_list()[0])
                    print("删除试卷:", delete_name.text)
                    delete_name.click()
                    if self.wait_check_exam_detail_page():
                        self.delete_btn().click()  # 删除试卷
                        time.sleep(2)
                        if self.wait_check_delete_tip_page():
                            self.driver.execute_script(
                                "document.getElementsByClassName('el-message-box__btns').item(0)"
                                ".getElementsByTagName('button').item(1).click()"
                            )
                            time.sleep(3)
示例#26
0
 def __init__(self):
     self.home = HomePage()
     self.user_center = UserCenterPage()
     self.wait = WaitElement()
示例#27
0
class ExamPage(BasePage):
    """试卷页面"""
    home = HomePage()
    answer = AnswerPage()
    wait = WaitElement()

    @teststep
    def wait_check_exam_title_page(self):
        """以 试卷的标题作为 页面检查点"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'试卷')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_exam_counter_page(self):
        """以 做试卷时的计时作为 页面检查点"""
        locator = (By.ID, self.id_type() + "time_container")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_exam_confirm_page(self):
        """以 试卷确认的标题作为 页面检查点"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'试卷确认')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_rank_page(self):
        """以 炫耀一下的text作为 页面检查点"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'炫耀一下')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_end_page(self):
        """等待 滑到底提示"""
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text,"到底啦 下拉刷新试试")]')
        return self.wait.wait_check_element(locator, timeout=5)

    @teststep
    def exam_names(self):
        """试卷名称"""
        locator = (By.ID, self.id_type() + 'tv_name')
        return self.wait.wait_find_elements(locator)

    @teststep
    def finish_count(self):
        """完成人数"""
        locator = (By.ID, self.id_type() + 'tv_finishcount')
        return self.wait.wait_find_elements(locator)

    @teststep
    def finish_status(self):
        """完成状态"""
        locator = (By.ID, self.id_type() + 'rtv_mode')
        return self.wait.wait_find_elements(locator)

    @teststep
    def get_all_text(self):
        """获取所有文本"""
        locator = (By.CLASS_NAME, 'android.widget.TextView')
        return self.wait.wait_find_elements(locator)

    @teststep
    def click_start_exam_button(self):
        """点击 开始考试"""
        locator = (By.ID, self.id_type() + 'start_write')
        self.wait.wait_find_element(locator).click()

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

    @teststep
    def close_answer(self):
        """关闭答题卷页面"""
        locator = (By.ID, self.id_type() + 'answerclose')
        self.wait.wait_find_element(locator).click()

    @teststep
    def exam_back_to_home(self):
        self.home.click_back_up_button()
        if self.wait_check_exam_title_page():
            self.home.click_back_up_button()
            if self.home.wait_check_home_page():
                print('返回主页面')

    @teststeps
    def select_one_exam(self):
        """随机选择一个试卷"""
        exams_info = {}  # 将试卷存入一个字典当周,以试卷名作为key,试卷描述与完成状态作为value
        while True:
            exams = self.exam_names()
            finish_status = self.finish_status()  # 试卷完成状态
            finish_count = self.finish_count()  # 试卷几人完成
            for i in range(len(exams)):
                exams_info[exams[i].text] = finish_status[
                    i].text + ' -- ' + finish_count[i].text
            if not self.wait_check_end_page():  # 没有发现滑动到底的则进行滑动
                self.home.screen_swipe_up(0.5, 0.9, 0.7, 1000)
            else:
                # exams_info[exams[-1].text] = finish_status[-1].text + ' -- ' + finish_count[-1].text
                self.home.screen_swipe_down(0.5, 0.2, 0.9, 1000)
                break

        for name in exams_info.keys():
            print(name, '   ', exams_info[name])

        exam = self.exam_names()[0]
        test_name = exam.text
        print('选择试卷:', test_name)
        exam.click()
        print('------------------------------\n')
        return test_name

    @teststeps
    def exam_confirm_ele_operate(self):
        """确认页面 文本展示"""
        ele = self.get_all_text()
        print('\n<试卷确认页面>:\n')
        self.print_exam_info(ele)
        print(ele[14].text + '\n' + ele[15].text + '\n' + ele[16].text + '\n' +
              ele[17].text)  # 说明
        print('--------------------------------\n')
        return int(ele[9].text)

    @teststep
    def print_exam_info(self, ele):
        """打印出试卷头部信息"""
        print(ele[1].text, ':', ele[2].text)  # 试卷名称
        print(ele[5].text, ':', ele[3].text + ele[4].text)  # 试卷模式
        print(ele[8].text, ':', ele[6].text + ele[7].text)  # 时间
        print(ele[11].text, ':', ele[9].text + ele[10].text)  # 题数
        print(ele[13].text, ':', ele[12].text)  # 限制

    @teststeps
    def get_ques_name(self, total):
        """获取所有题型"""
        if self.wait_check_exam_counter_page():
            self.answer.answer_check_button().click()
            if self.answer.wait_check_answers_page():
                tip_num = []
                tips = []
                while True:
                    titles = self.answer.question_titles()
                    for i, x in enumerate(titles):
                        if x.text in tips:
                            continue
                        else:
                            if i == len(titles) - 1:
                                self.home.screen_swipe_up(0.5, 0.87, 0.7, 1000)
                            ques_num = self.answer.ques_num(x.text)
                            num = int(re.findall(r'\d+', ques_num)[0])
                            tips.append(x.text)
                            print(x.text, ' ', ques_num)
                            tip_num.append(num)
                    if sum(tip_num) < total:
                        self.home.screen_swipe_up(0.5, 0.9, 0.4, 1000)
                    else:
                        break

                self.close_answer()
                print('--------------------------------\n')
                return tips

    @teststeps
    def play_examination(self, tips, exam_json):
        """做题过程"""
        if self.wait_check_exam_counter_page():
            self.answer.answer_check_button().click()  # 查看答题卷
            if self.answer.wait_check_answers_page():
                index = 0
                while index < len(tips):
                    title_list = [
                        x.text for x in self.answer.question_titles()
                    ]  # 题型数组
                    print(title_list)
                    if tips[index] in title_list:
                        first_index = self.answer.tip_index(
                            tips[index])  # 题型的第一道题
                        ques_num = self.answer.ques_num(
                            tips[index])  # 题数描述 (共*题)
                        num = int(''.join(re.findall(r'\d+',
                                                     ques_num)))  # 从描述中获取题数
                        first_index[0].click()  # 点击第一题进入习题
                        self.exam_process(tips[index], num,
                                          exam_json)  # 对应习题的游戏过程
                        self.answer.answer_check_button().click(
                        )  # 游戏结束后点击答题卷进入下一题
                        if self.answer.wait_check_answers_page():
                            pass
                        index = index + 1
                    else:
                        self.home.screen_swipe_up(0.5, 0.8, 0.4, 2000)

                if self.answer.wait_check_answers_page():
                    self.answer.submit_tip_operate()  # 交卷
                    if self.wait_check_rank_page():
                        self.exam_back_to_home()  # 返回

    @teststeps
    def exam_process(self, title, num, exam_json):
        print('\n-------%s-共%d题------\n' % (title, num))
        if '听后选择' in title:
            ListenSelect().play_listening_select_game(num, exam_json)
            self.answer.wait_result_btn_enabled()

        elif '猜词游戏' in title:
            GuessingWord().play_guessing_word_game(num, exam_json)

        elif '单项选择' in title:
            SingleChoice().play_single_choice_game(num, exam_json)

        elif '词汇选择' in title:
            VocabSelect().play_vocab_select_game(num, exam_json)

        elif '单词拼写' in title:
            WordSpell().play_word_spell_game(num, exam_json)

        elif '单词听写' in title:
            ListenSpell().play_listen_spell_game(num, exam_json)

        elif '连词成句' in title:
            Conjunctions().play_conjunctions_game(num, exam_json)

        elif '还原单词' in title:
            RestoreWord().play_restore_word_game(num, exam_json)

        elif '连连看' in title:
            WordMatch().play_word_match_game(num, exam_json)

        elif '强化炼句' in title:
            SentenceEnhance().play_sentence_enhance_game(num, exam_json)

        elif '听音连句' in title:
            ListenSentence().play_listen_sentence_game(num, exam_json)

        elif '句型转换' in title:
            ExamSentenceExchange().play_sentence_exchange_game(num, exam_json)

        elif '完形填空' in title:
            ClozeTest().play_cloze_test_game(num, exam_json)

        elif '选词填空' in title:
            BlankCloze().play_bank_cloze_game(num, exam_json)

        elif '补全文章' in title:
            CompleteText().play_complete_article_game(num, exam_json)

        elif '阅读理解' in title:
            ReadUnderstand().play_read_understand_game(num, exam_json)

        else:
            pass
示例#28
0
class ListenHomePage(BasePage):
    wait = WaitElement()

    @teststep
    def wait_check_listen_everyday_home_page(self):
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text, "每日一听")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_degrade_page(self):
        locator = (By.XPATH,
                   '//android.widget.TextView[contains(@text, "是否感觉题太难了")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_certificate_page(self):
        locator = (By.XPATH,
                   '//android.widget.Button[contains(@text, "炫耀一下")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_share_page(self):
        locator = (By.XPATH,
                   '//android.widget.Button[contains(@text, "微信好友")]')
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_today_limit_img_page(self):
        locator = (By.ID, self.id_type() + 'error_img')
        return self.wait.wait_check_element(locator)

    @teststep
    def level_button(self):
        """等级"""
        locator = (By.ID, self.id_type() + 'level')
        return self.wait.wait_find_element(locator)

    @teststep
    def history_button(self):
        """历史记录"""
        locator = (By.ID, self.id_type() + 'history')
        return self.wait.wait_find_element(locator)

    @teststep
    def rank_button(self):
        """排行榜"""
        locator = (By.ID, self.id_type() + 'rank')
        return self.wait.wait_find_element(locator)

    @teststep
    def start_button(self):
        """开始"""
        locator = (By.ID, self.id_type() + 'start')
        return self.wait.wait_find_element(locator)

    @teststep
    def excise_time(self):
        """练习时间"""
        locator = (By.ID, self.id_type() + 'time')
        return self.wait.wait_find_element(locator)

    @teststep
    def start_excise_button(self):
        """开始练习"""
        locator = (By.ID, self.id_type() + 'action_two')
        return self.wait.wait_find_element(locator)

    @teststep
    def commit_button(self):
        """确定"""
        locator = (By.ID, self.id_type() + 'confirm')
        return self.wait.wait_find_element(locator)
示例#29
0
class HomePage(BasePage):
    """app主页面元素信息"""
    wait = WaitElement()

    @teststeps
    def wait_check_home_page(self, is_raise=False):
        """以“做试卷”为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'做试卷')]")
        return self.wait.wait_check_element(locator, timeout=10)

    @teststeps
    def wait_check_expert_page(self):
        """以“做试卷”为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'通知')]")
        return self.wait.wait_check_element(locator)

    @teststeps
    def wait_check_word_title(self):
        """将'单词本'作为 单词本首页 页面检查点"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'单词本')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def click_hk_tab(self, index):
        """以“口语练习、做单词、做习题、做试卷” 的id"""
        locator = (By.ID, self.id_type() + 'notice')
        self.wait.wait_find_elements(locator)[index - 1].click()

    @teststep
    def homework(self):
        """以“口语、作业或者试卷列表内条目”的id为依据"""
        locator = (By.ID, self.id_type() + 'tv_homework_name')
        return self.wait.wait_find_elements(locator)

    @teststeps
    def end_judge(self):
        """元素:到底啦 下拉刷新试试"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text,'到底啦 下拉刷新试试')]")
        return self.wait.wait_check_element(locator)

    # 关于图书馆的定位
    @teststep
    def wait_check_recommend_more_btn_page(self):
        """推荐栏的发现更多按钮"""
        locator = (
            By.XPATH,
            "//*[@text='推荐']/following-sibling::android.widget.TextView")
        return self.wait.wait_check_element(locator)

    @teststep
    def wait_check_mine_more_btn_page(self):
        """推荐栏的发现更多按钮"""
        locator = (
            By.XPATH,
            "//*[@text='我的阅读']/following-sibling::android.widget.TextView")
        return self.wait.wait_check_element(locator)

    @teststep
    def check_more(self):
        """查看更多"""
        locator = (By.ID, self.id_type() + 'more')
        return self.wait.wait_find_elements(locator)

    @teststep
    def home_school_name(self):
        """主页学校名称"""
        ele = self.driver.find_element_by_id(self.id_type() + 'common_toolbar')
        ele_child = ele.find_elements_by_xpath('.//android.widget.TextView')
        return ele_child[0].text.split('•')[1]

    @teststep
    def tab_books(self, tab_name):
        """推荐书籍"""
        locator = (
            By.XPATH,
            '//*[@text="{}"]/../following-sibling::android.widget.FrameLayout/'
            'android.widget.LinearLayout/android.widget.LinearLayout'.format(
                tab_name))
        ele = self.wait.wait_find_elements(locator)
        text = [
            x.find_element_by_xpath('.//android.widget.TextView').text
            for x in ele
        ]
        return text

    # 公共元素- 底部四个tab元素:作业、试卷、个人中心、图书馆
    @teststep
    def click_tab_library(self):
        """下方图书馆Tab"""
        locator = (By.ID, self.id_type() + 'tab_lib_icon')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_tab_hw(self):
        """以“学习tab”的id为依据"""
        locator = (By.ID, self.id_type() + 'tab_hw_icon')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_test_vanclass(self):
        """以“班级tab”的id为依据"""
        locator = (By.ID, self.id_type() + 'tab_class_icon')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_tab_profile(self):
        """以“个人中心tab”的id为依据"""
        locator = (By.ID, self.id_type() + 'tab_profile')
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_back_up_button(self):
        """以“返回按钮”的class name为依据"""
        locator = (By.ACCESSIBILITY_ID, "转到上一层级")
        self.wait.wait_find_element(locator).click()

    @teststeps
    def all_element(self):
        """页面内所有class name为android.widget.TextView的元素"""
        locator = (By.CLASS_NAME, "android.widget.TextView")
        return self.wait.wait_find_elements(locator)

    # 温馨提示 页面
    @teststeps
    def wait_check_tips_page(self, var=10):
        """以“icon”为依据"""
        locator = (By.XPATH, "//android.widget.TextView[contains(@resource-id,"
                   "'{}md_title')]".format(self.id_type()))
        return self.wait.wait_check_element(locator)

    @teststep
    def tips_title(self):
        """温馨提示title"""
        locator = (By.ID, self.id_type() + 'md_title')
        return self.wait.wait_find_element(locator).text

    @teststep
    def tips_content(self):
        """温馨提示 具体内容"""
        locator = (By.ID, self.id_type() + 'md_content')
        return self.wait.wait_find_element(locator).text

    @teststep
    def input(self):
        """输入框"""
        locator = (By.ID, "android:id/input")
        return self.wait.wait_find_element(locator)

    @teststep
    def cancel_button(self):
        """取消 按钮"""
        locator = (By.ID, self.id_type() + "md_buttonDefaultNegative")
        self.wait.wait_find_element(locator).click()

    @teststep
    def commit_button(self):
        """确定 按钮"""
        locator = (By.ID, self.id_type() + "md_buttonDefaultPositive")
        self.wait.wait_find_element(locator).click()

    @teststep
    def commit(self):
        """确定 按钮"""
        locator = (By.ID, self.id_type() + "md_buttonDefaultPositive")
        return self.wait.wait_find_element(locator)

    @teststeps
    def wait_activity(self):
        """获取当前页面activity"""
        self.driver.implicitly_wait(2)
        activity = self.driver.current_activity
        return activity

    @teststeps
    def homework_count(self):
        """获取作业title列表第一个页面的作业 """
        homework_list = self.homework()
        homework_title = [x.text for x in homework_list]  # 获取作业title列表
        return homework_title, homework_list

    @teststeps
    def homework_count_2(self):
        """获取作业title列表非第一页的作业 及 页面内最后一个作业的title 以及 元素 '到底啦 下拉刷新试试' """
        homework_title = []
        homework_list = self.homework()
        for i in range(0, len(homework_list)):
            homework_title.append(homework_list[i].text)  # 获取作业title列表
        # print(len(homework_title), len(homework_list))
        item = homework_list[len(homework_list) - 1].text  # 最后一个作业的title
        tips = self.end_judge()  # 判断元素 '到底啦 下拉刷新试试' 是否存在
        # print('tips:', tips)

        return tips, item, homework_title, homework_list

    @teststeps
    def swipe_operate(self, var, homework, game):
        """滑屏 操作"""
        print('----------------------')
        if len(var) == 10:
            last_one = var[len(var) - 2]  # 滑动前页面内最后一个作业title
        else:
            last_one = var[len(var) - 1]  # 滑动前页面内最后一个作业title
        self.screen_swipe_up(0.5, 0.75, 0.25, 1000)

        item = self.homework_count_2()
        if item[0] is True:  # 滑到底部
            print('滑动后到底部')
            index = []
            for i in range(0, len(item[2])):
                if item[2][i] == last_one:
                    index.append(i)
                    break

            count = self.homework_exist(index[0] + 1, item[2], item[3],
                                        homework, game)
            return count
        else:
            # print('滑动后未到底部')
            if last_one in item[2]:
                index_2 = []
                for j in range(0, len(item[2])):
                    if item[2][j] == last_one:
                        index_2.append(j)
                count = self.homework_exist(index_2[0] + 1, item[2], item[3],
                                            homework, game)
            else:
                count = self.homework_exist(0, item[2], item[3], homework,
                                            game)

            if len(count) == 0:
                return self.swipe_operate(item[2], homework, game)
            else:
                return count

    @teststeps
    def homework_exist(self, index, title, homework, item, game):
        """判断该作业是否存在 -- 若存在,统计小游戏的个数"""
        homework_count = []
        result = []
        for ind in range(index, len(title)):
            if title[ind] == item:
                homework_count.append(ind)
                break
        # print('homework_count:', homework_count)
        if len(homework_count) != 0:
            for i in homework_count:
                homework[i].click()
                result.append(Homework().games_count(0, game, item)[0])
        else:
            print('no have该作业')
        return result

    @teststeps
    def tips_operate_commit(self):
        """温馨提示 页面信息  -- 确定"""
        if self.wait_check_tips_page():  # 温馨提示 页面
            print('--------------------------')
            self.tips_title()
            self.tips_content()
            self.commit_button()  # 确定按钮
            print('--------------------------')

    @teststeps
    def tips_operate_cancel(self):
        """温馨提示 页面信息  -- 取消"""
        if self.wait_check_tips_page():  # 温馨提示 页面
            print('--------------------------')
            self.tips_title()
            self.tips_content()
            self.cancel_button()  # 取消按钮
            print('--------------------------')
示例#30
0
class MeizuPage(BasePage):
    """魅族5.1"""
    wait = WaitElement()

    # 拍照 魅族5.1
    @teststeps
    def wait_check_camera_page(self):
        """以 “拍照键”的resource-id为依据"""
        locator = (By.ID, "com.meizu.media.camera:id/shutter_btn")
        return self.wait.wait_check_element(locator)

    # 第一页面
    @teststep
    def click_camera_button(self):
        """以相机拍照按钮"""
        time.sleep(2)
        print('点击 拍照按钮')
        locator = (By.ID, "com.meizu.media.camera:id/shutter_btn")
        return self.wait.wait_find_element(locator).click()

    # 第二页面
    @teststeps
    def wait_check_retake_page(self):
        """以 “”的resource-id为依据"""
        locator = (By.ID, "com.meizu.media.camera:id/btn_retake")
        return self.wait.wait_check_element(locator)

    @teststep
    def click_done_button(self):
        """相机'完成'按钮"""
        print('点击 保存按钮')
        locator = (By.ID, "com.meizu.media.camera:id/btn_done")
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_retake_button(self):
        """相机'retake'按钮"""
        print('点击 重拍按钮')
        locator = (By.ID, "com.meizu.media.camera:id/btn_retake")
        self.wait.wait_find_element(locator).click()

    # 第三页面
    @teststep
    def wait_check_save_page(self):
        """取消 按钮 的为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text, '取消')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def click_save_button(self):
        """相机保存按钮"""
        print('点击 完成按钮')
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'完成')]")
        self.wait.wait_find_element(locator).click()

    @teststep
    def click_cancel_button(self):
        """相机取消按钮"""
        print('点击 取消按钮')
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'取消')]")
        self.wait.wait_find_element(locator).click()

    # 相册 魅族5.1
    @teststep
    def wait_check_album_page(self):
        """最新tab 的单个内容 的resource-id为依据"""
        locator = (By.ID, "com.meizu.media.gallery:id/thumbnail")
        return self.wait.wait_check_element(locator)

    @teststeps
    def wait_check_album_list_page(self):
        """相册列表页面检查点"""
        locator = (By.ID, "com.meizu.media.gallery:id/album_cover")
        return self.wait.wait_check_element(locator)

    # 第一页面
    @teststep
    def click_album(self):
        """进入相册tab"""
        print('进入相册列表页')
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'相册')]")
        self.wait.wait_find_element(locator).click()

    @teststep
    def wait_check_all_picture_page(self):
        """所有图片 的为依据"""
        locator = (By.XPATH,
                   "//android.widget.TextView[contains(@text, '所有图片')]")
        return self.wait.wait_check_element(locator)

    @teststep
    def open_album(self):
        """打开 第一个相册"""
        print('选择相册')
        locator = (By.XPATH, "com.meizu.media.gallery:id/album_name")
        self.wait.wait_find_elements(locator)[0].click()

    # 第二页面  检查点用 wait_check_album_list_page()
    @teststep
    def choose_image(self):
        """选择相册图片"""
        print('选择照片')
        locator = (By.ID, "com.meizu.media.gallery:id/thumbnail")
        self.wait.wait_find_elements(locator)[0].click()

    # 第三页面
    @teststep
    def wait_check_photo_page(self):
        """ 确定 按钮 的resource-id为依据"""
        locator = (By.ID, "com.meizu.media.gallery:id/fragment_container")
        return self.wait.wait_check_element(locator)

    @teststep
    def commit_button(self):
        """相册确定按钮"""
        print('点击 确定按钮')
        locator = (By.XPATH, "//android.widget.TextView[contains(@text,'确定')]")
        self.wait.wait_find_element(locator).click()

    @teststep
    def back_up_button(self):
        """相册返回按钮"""
        locator = (By.ID, "android:id/home")
        self.wait.wait_find_element(locator).click()