예제 #1
0
 def test_ke_course_NoListenButton(self):
     """未报名,点击未有试听章节"""
     adBase.adBase(self)
     # 切换到课堂
     self.driver.find_element_by_name('课堂').click()
     Ads.test_ketang_ad(self)
     kePlay.ke_course_NoListenButton(self)
예제 #2
0
파일: adRun.py 프로젝트: Mbasushan/appTest
 def test_ketang_ad(self):
     """app课堂首页广告"""
     adBase.adBase(self)
     # 切换到课堂
     self.driver.find_element_by_name('课堂').click()
     sleep(5)
     ad.test_ketang_ad(self)
예제 #3
0
 def test_ke_course_play_myCourse(self):
     """从【我的课程】进入课程详情页进行播放"""
     adBase.adBase(self)
     # 切换到课堂
     self.driver.find_element_by_name('课堂').click()
     Ads.test_ketang_ad(self)
     kePlay.ke_course_play_myCourse(self)
예제 #4
0
 def test_kePlay_packPage(self):
     """课程包选择课程进入播放页"""
     adBase.adBase(self)
     # 切换到课堂
     self.driver.find_element_by_name('课堂').click()
     Ads.test_ketang_ad(self)
     kePlay.ke_packPage(self)
예제 #5
0
 def test_ke_course_auditionBut_noBuy(self):
     """未报名,点击【试听】按钮"""
     adBase.adBase(self)
     # 切换到课堂
     self.driver.find_element_by_name('课堂').click()
     Ads.test_ketang_ad(self)
     kePlay.ke_course_auditionBut_noBuy(self)
예제 #6
0
파일: allKe.py 프로젝트: Mbasushan/appTest
def allKe(self):
    Ads.test_ketang_ad(self)
    screen = swipe.get_size(self)

    list = isElement.find_Element(self,'id',"recycler_list")
    if list:
        print("看到了全部课程")
        return True
    else:
        size=0

    while size==0:
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 7000)
        list = isElement.find_Element(self, 'id', "recycler_list")
        if list:
            print("看到了全部课程")
            try:
                llParent = self.driver.find_elements_by_id('recycler_list')[0].find_element_by_id("tv_num").is_displayed()
                if llParent:
                    return True
                else:
                    self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 6000)
            except:
                print("2")
        else:
            size = 0
    print("看到了全部课程")
    return True
예제 #7
0
def ke_course_audition_noBuy(self):
    """未报名点击章节试听"""
    # 切换到课堂
    self.driver.find_element_by_name('课堂').click()
    sleep(5)
    ad.test_ketang_ad(self)
    sleep(3)
    isMini = isMiniPlays.isMiniPlay(self)
    if isMini:
        self.driver.find_element_by_id('iv_close').click()
    flag = isElement.find_Element(self, "id", 'com.mbalib.android.wiki:id/recycler_list')
    while not flag:
        screen = swipe.get_size(self)
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 6000)
        flag = isElement.find_Element(self, "id", 'com.mbalib.android.wiki:id/recycler_list')
    # 点击全部课程的第一个课程
    list = self.driver.find_element_by_id("com.mbalib.android.wiki:id/recycler_list").find_elements_by_id("llParent")
    list[0].click()
    sleep(5)
    # 判断课程是否报名
    tvBuy = isElement.find_Element(self, 'id', 'tv_buy')
    if tvBuy:
        # 未报名
        print("该课程未报名")
        tabTitle = isElement.find_Element(self, 'id', 'tv_tab_title')
        while not tabTitle:
            screen = swipe.get_size(self)
            self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 3000)
            tabTitle = isElement.find_Element(self, 'id', 'tv_tab_title')
        self.driver.find_elements_by_id("com.mbalib.android.wiki:id/tv_tab_title")[1].click()
        sleep(3)
        #判断该课程是否有试听章节
        listen=isElement.find_Element(self,'id','tv_try_listen')
        while not listen:
            screen = swipe.get_size(self)
            self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 6000)
            listen = isElement.find_Element(self, 'id', 'tv_try_listen')
        self.driver.find_elements_by_id('com.mbalib.android.wiki:id/recycler')[0].find_elements_by_id('note_iv_title')[0].click()
        sleep(5)
        # 进入播放页
        thumb = isElement.find_Element(self, 'id', 'com.mbalib.android.wiki:id/layout_play_view')
        sleep(5)
        if thumb:
            print("成功进入播放页")
            self.driver.find_element_by_id('play_view').click()
            self.driver.find_element_by_id('iv_back').click()
            playState = isElement.find_Element(self, 'id', 'iv_close')
            if playState:
                print("课程未自动播放")
            else:
                print("课程有自动播放")
    else:
        #已报名
        print("该课程已报名")
예제 #8
0
def ke_packPage(self):
    # 切换到课堂
    self.driver.find_element_by_name('课堂').click()
    sleep(5)
    ad.test_ketang_ad(self)
    sleep(3)
    isMini=isMiniPlays.isMiniPlay(self)
    if isMini:
        self.driver.find_element_by_id('iv_close').click()
    flag=isElement.find_Element(self,"id",'com.mbalib.android.wiki:id/recycler_package')
    if  not flag:
        screen = swipe.get_size(self)
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 6000)
    #点击系统班的第一个课程包
    list = self.driver.find_elements_by_id("com.mbalib.android.wiki:id/recycler_package")[0].find_elements_by_class_name("android.widget.LinearLayout")
    list[0].click()
    sleep(5)
    #判断课程包是否报名
    tvBuy = isElement.find_Element(self, 'id', 'tv_buy')
    if tvBuy:
        #未报名
        print("该课程包未报名")
        return
    else:
        tabTitle=isElement.find_Element(self,'id','tv_tab_title')
        while not tabTitle:
            screen = swipe.get_size(self)
            self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 3000)
            tabTitle = isElement.find_Element(self, 'id', 'tv_tab_title')
    self.driver.find_elements_by_id("com.mbalib.android.wiki:id/tv_tab_title")[1].click()
    sleep(3)
    self.driver.find_elements_by_id("com.mbalib.android.wiki:id/llParent")[0].click()
    #进入课程的介绍页
    sleep(5)
    self.driver.find_element_by_id("tv_study").click()
    sleep(5)
    #进入播放页
    thumb=isElement.find_Element(self,'id','com.mbalib.android.wiki:id/layout_play_view')
    sleep(5)
    if thumb:
        print("成功进入播放页")
        self.driver.find_element_by_id('play_view').click()
        self.driver.find_element_by_id('iv_back').click()
        playState=isElement.find_Element(self,'id','iv_close')
        if playState:
            print("课程未自动播放")
        else:
            print("课程有自动播放")
    else:
        print("未进入播放页")
예제 #9
0
def no_apply(self):
    self.driver.find_element_by_name('课堂').click()
    print("课程未报名,有试听章节,进入试听点击【下载】")
    Ads.test_ketang_ad(self)
    screen = swipe.get_size(self)
    self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 10000)
    list = self.driver.find_elements_by_id("com.mbalib.android.wiki:id/recycler_list")
    if not list:
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 10000)
        list = self.driver.find_elements_by_id("com.mbalib.android.wiki:id/recycler_list")
    list[0].find_elements_by_class_name("android.widget.LinearLayout")[0].click()
    sleep(5)
    isBuy=isElement.find_Element(self,'id','tv_buy')
    if isBuy:
        print("该课程未报名")
        #判断该课程是否有试听章节
        course=isElement.find_Element(self,'id','tv_tab_title')
        if not course:
            self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 10000)
        self.driver.find_element_by_name('课程').click()
        sleep(3)
        isListen=isElement.find_Element(self,"id","tv_try_listen")
        if isListen:
            print("该课程有试听章节")
            self.driver.find_elements_by_id('com.mbalib.android.wiki:id/llparent')[0].find_elements_by_id("com.mbalib.android.wiki:id/recycler")[0].click()
            sleep(5)
            self.driver.find_element_by_id("imageDownload").click()
            sleep(3)
            #触发【报名后可下载课程】弹窗
            popuWind=isElement.find_Element(self,'name','报名后可下载课程')
            if popuWind:
                print("触发【报名后可下载课程】弹窗")
                #点击【马上报名】
                self.driver.find_element_by_id("tvSignUp").click()
                sleep(5)
                title=self.driver.find_element_by_id('toolbar_tv_title').text
                if title=='课程详情':
                    print("点击【马上报名】返回到课程详情页,该测试用例成功")
                else:
                    print("点击【马上报名】跳转不是返回到了课程详情页")
            else:
                print("未触发【报名后可下载课程】弹窗")

        else:
            print("该课程无试听章节")
    else:
        print("该课程已报名")
예제 #10
0
def ke_course_NoListenButton(self):
    """未报名,点击未有试听章节"""
    sleep(5)
    ad.test_ketang_ad(self)
    sleep(3)
    isMini = isMiniPlays.isMiniPlay(self)
    if isMini:
        self.driver.find_element_by_id('iv_close').click()
    flag = isElement.find_Element(self, "id", 'com.mbalib.android.wiki:id/recycler_list')
    while not flag:
        screen = swipe.get_size(self)
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 6000)
        flag = isElement.find_Element(self, "id", 'com.mbalib.android.wiki:id/recycler_list')
    # 点击全部课程的第一个课程
    list = self.driver.find_element_by_id("com.mbalib.android.wiki:id/recycler_list").find_elements_by_id("llParent")
    list[0].click()
    sleep(5)
    # 判断课程是否报名
    tvBuy = isElement.find_Element(self, 'id', 'tv_buy')
    if tvBuy:
        # 未报名
        print("该课程未报名")
        tabTitle = isElement.find_Element(self, 'id', 'tv_tab_title')
        while not tabTitle:
            screen = swipe.get_size(self)
            self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5, screen[1] * 0.25, 3000)
            tabTitle = isElement.find_Element(self, 'id', 'tv_tab_title')
        self.driver.find_elements_by_id("com.mbalib.android.wiki:id/tv_tab_title")[1].click()
        sleep(3)
        # 判断该课程是否有试听章节
        listen = isElement.find_Element(self, 'id', 'tv_try_listen')
        if not listen:
            self.driver.find_elements_by_id('com.mbalib.android.wiki:id/recycler')[0].find_elements_by_id('note_iv_title')[0].click()
            sleep(5)
            print("触发支付弹层")
        else:
            print("有试听章节")
    else:
        # 已报名
        print("该课程已报名")
예제 #11
0
 def test_signUp_vipFreeCourse(self):
     """课程vip免费听"""
     adBase.adBase(self)
     self.driver.find_element_by_name('课堂').click()
     Ads.test_ketang_ad(self)
     signUp.vip_free_course(self)
예제 #12
0
def vip_buy_packPage(self):
    # 判断用户是否为vip
    vipText = vip.isKeVip(self)
    ll_taps = self.driver.find_elements_by_id('ll_tap')
    ll_taps[3].click()
    # 判断是否有课堂广告
    ad.test_ketang_ad(self)
    ivFold = isElement.find_Element(self, 'id', 'ivFold')
    # flag=isElement.find_Element(self,"id",'com.mbalib.android.wiki:id/recycler_package')
    if not ivFold:
        screen = swipe.get_size(self)
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5,
                          screen[1] * 0.25, 6000)
    # 点击系统班的第一个课程包
    list = self.driver.find_elements_by_id(
        "com.mbalib.android.wiki:id/recycler_package"
    )[0].find_elements_by_class_name("android.widget.LinearLayout")
    self.driver.find_element_by_id('ivFold').click()
    flowLayout = list[0].find_elements_by_id('textview')
    siz = len(flowLayout)
    index = 0
    flowText = flowLayout[index].text
    while flowText == 'VIP折扣价':
        index = +1
        if index < siz:
            flowText = flowLayout[index].text
        else:
            print("未有VIP折扣价")
            return

    list[0].click()
    sleep(5)
    #该课程的价格
    tv_prive = self.driver.find_element_by_id('tv_prive').text
    #判断该课程是否已报名
    isbuy = isElement.find_Element(self, 'id', 'll_bottom_pay')
    if isbuy:
        print("该课程包还未报名")
        if vipText == "vip":
            isFree = isElement.find_Element(self, 'id', 'll_ke_vip_listen')
            if isFree:
                print("该课程包是vip免费听")
                return
            else:
                print("该课程包是vip折扣")
                # 点击报名
                self.driver.find_element_by_id('tv_buy').click()
                sleep(5)
                # 实际支付金额为tv_prive
                tv_money = self.driver.find_element_by_id('tv_money').text[1:]
                money = tv_money[1:]
                tv_prive = float(tv_prive) * 0.8
                tv_prive = ("%.2f" % tv_prive)
                print(tv_prive)
                if money == tv_prive:
                    print("vip折扣")
                    # 选择M币支付
                    payType.m_pay_cancle(self, money)
                else:
                    print("金额不符合")
                    return
        else:
            print("该用户不是vip用户")
            # 点击报名
            self.driver.find_element_by_id('tv_buy').click()
            sleep(5)
            #实际支付金额为tv_prive
            tv_money = self.driver.find_element_by_id('tv_money').text[1:]
            money = tv_money[1:]
            if money == tv_prive:
                print("未打折扣")
                #选择M币支付
                payType.m_pay_cancle(self, money)
            else:
                print("金额不符合")
                return
    else:
        print("该课程包已报名")
예제 #13
0
def vip_free_course(self):
    # 判断用户是否为vip
    vipText = vip.isKeVip(self)
    ll_taps = self.driver.find_elements_by_id('ll_tap')
    ll_taps[3].click()
    # 判断是否有课堂广告
    ad.test_ketang_ad(self)
    flag = isElement.find_Element(self, "id",
                                  'com.mbalib.android.wiki:id/recycler_list')
    while not flag:
        screen = swipe.get_size(self)
        self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5,
                          screen[1] * 0.25, 6000)
        flag = isElement.find_Element(
            self, "id", 'com.mbalib.android.wiki:id/recycler_list')
    #点击全部课程的第一个课程
    list = self.driver.find_elements_by_id(
        "com.mbalib.android.wiki:id/recycler_list"
    )[0].find_elements_by_class_name("android.widget.LinearLayout")
    self.driver.find_element_by_id('ivFold').click()
    flowLayout = list[0].find_elements_by_id('textview')
    siz = len(flowLayout)
    index = 0
    flowText = flowLayout[index].text
    while flowText != 'VIP免费听':
        index = index + 1
        if index < siz:
            flowText = flowLayout[index].text
        else:
            print("未有vip免费听")
            return
    self.driver.find_element_by_id('ivFold').click()
    self.driver.find_elements_by_id(
        "com.mbalib.android.wiki:id/recycler_list"
    )[0].find_elements_by_class_name("android.widget.LinearLayout")[0].click()
    sleep(5)
    vipListen = isElement.find_Element(self, 'id', 'll_ke_vip_listen')
    if vipListen:
        print("该课程未报名")
        #判断用户是否为vip
        if vipText == 'vip':
            payBottom = self.driver.find_elements_by_id('ll_bottom_pay')
            if len(payBottom) == 1:
                print("用户是vip用户")
                self.driver.find_element_by_id('ll_ke_vip_listen').click()
                sleep(5)
                flag = isElement.find_Element(self, 'id', 'll_ke_vip_listen')
                if not flag:
                    print("vip免费听激活课程成功")
                else:
                    print("vip免费听激活课程失败")
                    return
                #我的课程中显示出该课程,有【vip免费听】标签
                title = self.driver.find_element_by_id('tv_ke_title').text
                back.ivBack(self)
                isbuyKe = buyKe.is_buy_ke(self, title)
                if isbuyKe:
                    print("vip免费听有加入我的课程列表")
                    list1 = self.driver.find_elements_by_id(
                        'com.mbalib.android.wiki:id/layout_recycler'
                    )[0].find_elements_by_class_name(
                        'android.widget.RelativeLayout')
                    tv_titles = self.driver.find_elements_by_id(
                        'com.mbalib.android.wiki:id/layout_recycler'
                    )[0].find_elements_by_id(
                        'com.mbalib.android.wiki:id/tv_title')
                    for index in range(len(tv_titles)):
                        if title == tv_titles[index].text:
                            print("title:", tv_titles[index].text)
                            #判断是否有vip免费听按钮
                            vipLogo = isElement.find_Element(
                                self, 'id', 'iv_item_my_course_vip')
                            if vipLogo:
                                print("有显示【vip免费听】标签")
                            else:
                                print("未显示【vip免费听】标签")
                else:
                    print("vip免费听未加入我的课程列表")
            else:
                print("用户不是vip用户")
                self.driver.find_element_by_id('ll_ke_vip_listen').click()
                sleep(5)
                tvTitle = self.driver.find_element_by_id('tvTitle').click()
                if tvTitle == '课堂VIP ':
                    print("点击vip免费听,跳转到课堂vip开通页")
                    return
        else:
            print("用户不是vip用户")

    else:
        buy = isElement.find_Element(self, 'id', 'tv_buy')
        if buy:
            print("该课程未报名且该课程不是vip免费听课程")
        else:
            print("该课程已报名")
예제 #14
0
def test_buyKe(self):
    """进入课程详情页,判断用户是否报名,未报名则报名"""
    # 判断是否登录
    isLogin = IsLogin.isLogin(self)
    if not isLogin:
        self.driver.find_element_by_id('tv_my_fragment_login_no_login').click()
        sleep(5)
        login.login_userName(self)
        #判断是否绑定手机
        bind = self.driver.find_element_by_xpath(
            "//android.view.View[@content-desc='绑定 绑定']").is_enabled()
        print("bind:", bind)
        if bind:
            back.ivBack(self)
    # 当前账号的M币金额
    money = mbi.Mbi(self)
    #返回到【我的】页面
    back.ivBack(self)
    sleep(5)
    #切换到课堂
    self.driver.find_elements_by_id('tv_tab_title')[3].click()
    #判断是否有课堂广告
    ad.test_ketang_ad(self)
    sleep(5)
    screen = swipe.get_size(self)
    self.driver.swipe(screen[0] * 0.5, screen[1] * 0.75, screen[0] * 0.5,
                      screen[1] * 0.25, 6000)
    list = self.driver.find_elements_by_id(
        "com.mbalib.android.wiki:id/recycler_package"
    )[0].find_elements_by_class_name("android.widget.LinearLayout")
    list[0].click()
    sleep(5)
    #判断是否进入的是微信绑定页,如果是点击【取消】
    flag = isElement.find_Element(self, 'id', 'tv_popu_course_bind_wx_bind')
    if flag:
        self.driver.find_element_by_id('tv_popu_course_bind_wx_cancel').click()
    sleep(5)
    print("进入课程详情页,是否有报名按钮")
    keTitle = self.driver.find_element_by_id('tv_ke_title').text
    print("keTitle:", keTitle)
    tvBuy = isElement.find_Element(self, 'id', 'tv_buy')
    if tvBuy:
        print("存在报名按钮")
        self.driver.find_element_by_id("tv_buy").click()
        sleep(5)
        #使用M币支付报名
        flag = payType.m_pay_cancle(self, money)
        if not flag:
            return
        else:
            back.ivBack(self)
            #判断是否有补充弹窗,有则提交数据
            contet = isElement.find_Element(self, 'id', 'layoutContent')
            if contet:
                print("信息补充弹窗开启")
                #填写信息点击【保存】
                sInfo.filled(self)
            sleep(5)
            back.ivBack(self)
            isBuyKe.is_buy_ke(self, keTitle)
    else:
        print("不存在报名按钮")
        back.ivBack(self)
        isBuyKe.is_buy_ke(self, keTitle)