Example #1
0
    def finish_check(self,article):
        step = 1

        #进入音频页并拖動進度條等待音頻播放完成
        get_to_article_by_search(self.driver,article,self.mode)
        sleep(WAIT_TIME)
        all_time = get_time_total(get_alltime(self.driver))
        seekbar_sendkey(self.driver,0.99)
        wait = all_time*0.01+5
        sleep(wait)
        assert get_played_time(self.driver)  == '00:00'
        assert element_exsist(self.driver,'id',AUDIO_START)

        #
        open_notifications(self.driver)
        sleep(WAIT_TIME)
        assert notification_status_judge(self.driver,'play')
        print u'Step %s:音频播放完成后通知按钮变为播放测试:OK' % (str(step))
        step+=1

        self.driver.find_element_by_id(NOTIFICATION_AUDIO_PLAY).click()
        close_notification(self.driver)
        sleep(WAIT_TIME)
        assert get_played_time(self.driver) != '00:00'
        print u'Step %s:点击通知栏播放可重新播放测试:OK' % (str(step))
        step+=1
Example #2
0
    def common_check(self,article):
        step = 1

        #退出到其他页面后播放器持续播放
        get_to_article_by_search(self.driver,article,self.mode)
        sleep(WAIT_TIME)
        all_time = get_time_total(get_alltime(self.driver))
        play_time = self.driver.find_element_by_id(AUDIO_PLAY_TIME)
        while play_time.text == '00:00':
            sleep(WAIT_TIME)
        play_time_old = play_time.text
        #print play_time_old
        back(self.driver)
        sleep(5)
        self.driver.find_element_by_class_name('android.widget.RelativeLayout')\
            .find_element_by_class_name('android.widget.TextView').click()
        sleep(2)
        play_time_new = play_time.text
        #print play_time_new
        time_range = time_range_for_audio(play_time_old,play_time_new)
        assert time_range >= 7
        print u'Step %s:切换到客户端其他页面时音频继续播放测试:OK' % (str(step))
        step +=1

        #退出详情页等待音频播放完成再次进入,验证播放完成效果
        seekbar_sendkey(self.driver,0.95)
        wait = all_time*0.05
        back(self.driver)
        sleep(wait+10)
        self.driver.find_element_by_class_name('android.widget.RelativeLayout')\
            .find_element_by_class_name('android.widget.TextView').click()
        assert element_exsist(self.driver,'id',AUDIO_START)
        assert get_played_time(self.driver) == '00:00'
        print u'Step %s:音频播放完成效果测试:OK' % (str(step))
        step +=1

        #手动触发重新播放
        self.driver.find_element_by_id(AUDIO_START).click()
        sleep(10)
        assert get_time_total(get_played_time(self.driver))>0
        print u'Step %s:手动触发重新播放测试:OK' % (str(step))
        # step+=1

        return True
Example #3
0
    def back_check(self, article):
        step = 1

        #进入含音频的正文页
        get_to_article_by_search(self.driver, article, self.mode)
        sleep(8)

        #切换到webview并打开音频
        # self.driver.switch_to.context(self.driver.contexts[-1])
        # self.driver.find_element_by_class_name('audio-start').click()
        # sleep(WAIT_TIME)
        # self.driver.switch_to.context(self.driver.contexts[0])
        #由於不同手機webview機制不同,此處採取坐標點擊方式實現
        click_audio_in_webview(self.driver)

        #切换回NATIVE

        start_play_time = get_played_time(self.driver)
        start_time = time.time()

        #退出当前页
        search_article_to_index(self.driver)
        sleep(10)

        #回到文章页验证音频是否持续播放
        get_to_article_by_search(self.driver, article, self.mode)
        sleep(WAIT_TIME)

        end_play_time = get_played_time(self.driver)
        end_time = time.time()
        print time_range_for_audio(end_play_time,
                                   start_play_time), end_time - start_time
        assert abs(
            time_range_for_audio(start_play_time, end_play_time) -
            (end_time - start_time)) <= 5
        assert element_exsist(self.driver, 'id', AUDIO_PAUSE)
        print u'Step %s:正文页音频播放时退出详情页,播放未完成时返回详情页测试:OK' % (str(step))
        step += 1

        #等待音频播放完成进入详情页
        seekbar_sendkey(self.driver, 0.9)
        wait = get_time_total(get_alltime(self.driver)) * 0.1
        search_article_to_index(self.driver)
        sleep(wait + 5)
        get_to_article_by_search(self.driver, article, self.mode)
        sleep(WAIT_TIME)
        #验证音频框仍然展示,且为初始状态
        assert element_exsist(self.driver, 'id', AUDIO_START)
        assert get_played_time(self.driver) == '00:00'
        #点击播放可重新播放
        self.driver.find_element_by_id(AUDIO_START).click()
        sleep(WAIT_TIME)
        assert get_played_time(self.driver) != '00:00'
        print u'Step %s:正文页音频播放时退出详情页,播放完成返回详情页测试:OK' % (str(step))
        step += 1