AC-571 updating video download/transcript area
This commit is contained in:
@@ -57,7 +57,10 @@ VIDEO_MENUS = {
|
||||
'language': '.lang .menu',
|
||||
'speed': '.speed .menu',
|
||||
'download_transcript': '.video-tracks .a11y-menu-list',
|
||||
'transcript-format': '.video-tracks .a11y-menu-button',
|
||||
'transcript-format': {
|
||||
'srt': '.wrapper-download-transcripts .list-download-transcripts .btn-link[data-value="srt"]',
|
||||
'txt': '.wrapper-download-transcripts .list-download-transcripts .btn-link[data-value="txt"]'
|
||||
},
|
||||
'transcript-skip': '.sr-is-focusable.transcript-start',
|
||||
}
|
||||
|
||||
@@ -584,7 +587,7 @@ class VideoPage(PageObject):
|
||||
bool: Transcript download result.
|
||||
|
||||
"""
|
||||
transcript_selector = self.get_element_selector(VIDEO_MENUS['transcript-format'])
|
||||
transcript_selector = self.get_element_selector(VIDEO_MENUS['transcript-format'][transcript_format])
|
||||
|
||||
# check if we have a transcript with correct format
|
||||
if '.' + transcript_format not in self.q(css=transcript_selector).text[0]:
|
||||
@@ -595,16 +598,15 @@ class VideoPage(PageObject):
|
||||
'txt': 'text/plain',
|
||||
}
|
||||
|
||||
transcript_url_selector = self.get_element_selector(VIDEO_BUTTONS['download_transcript'])
|
||||
url = self.q(css=transcript_url_selector).attrs('href')[0]
|
||||
link = self.q(css=transcript_selector)
|
||||
url = link.attrs('href')[0]
|
||||
link.click()
|
||||
|
||||
result, headers, content = self._get_transcript(url)
|
||||
|
||||
if result is False:
|
||||
return False
|
||||
|
||||
if formats[transcript_format] not in headers.get('content-type', ''):
|
||||
return False
|
||||
|
||||
if text_to_search not in content.decode('utf-8'):
|
||||
return False
|
||||
|
||||
@@ -674,45 +676,6 @@ class VideoPage(PageObject):
|
||||
selector = self.get_element_selector(VIDEO_MENUS[menu_name])
|
||||
return self.q(css=selector).present
|
||||
|
||||
def select_transcript_format(self, transcript_format):
|
||||
"""
|
||||
Select transcript with format `transcript_format`.
|
||||
|
||||
Arguments:
|
||||
transcript_format (st): Transcript file format `srt` or `txt`.
|
||||
|
||||
Returns:
|
||||
bool: Selection Result.
|
||||
|
||||
"""
|
||||
button_selector = self.get_element_selector(VIDEO_MENUS['transcript-format'])
|
||||
|
||||
button = self.q(css=button_selector).results[0]
|
||||
|
||||
hover = ActionChains(self.browser).move_to_element(button)
|
||||
hover.perform()
|
||||
|
||||
if '...' not in self.q(css=button_selector).text[0]:
|
||||
return False
|
||||
|
||||
menu_selector = self.get_element_selector(VIDEO_MENUS['download_transcript'])
|
||||
menu_items = self.q(css=menu_selector + ' a').results
|
||||
for item in menu_items:
|
||||
if item.get_attribute('data-value') == transcript_format:
|
||||
ActionChains(self.browser).move_to_element(item).click().perform()
|
||||
self.wait_for_ajax()
|
||||
break
|
||||
|
||||
self.browser.execute_script("window.scrollTo(0, 0);")
|
||||
|
||||
if self.q(css=menu_selector + ' .active a').attrs('data-value')[0] != transcript_format:
|
||||
return False
|
||||
|
||||
if '.' + transcript_format not in self.q(css=button_selector).text[0]:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def sources(self):
|
||||
"""
|
||||
|
||||
@@ -32,7 +32,7 @@ CLASS_SELECTORS = {
|
||||
|
||||
BUTTON_SELECTORS = {
|
||||
'create_video': 'button[data-category="video"]',
|
||||
'handout_download': '.video-handout.video-download-button a',
|
||||
'handout_download': '.wrapper-handouts .btn-link',
|
||||
'handout_download_editor': '.wrapper-comp-setting.file-uploader .download-action',
|
||||
'upload_asset': '.upload-action',
|
||||
'asset_submit': '.action-upload',
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Acceptance tests for Video.
|
||||
"""
|
||||
import os
|
||||
from ddt import ddt, unpack, data
|
||||
|
||||
from mock import patch
|
||||
from nose.plugins.attrib import attr
|
||||
@@ -199,6 +200,7 @@ class VideoBaseTest(UniqueCourseTest):
|
||||
|
||||
|
||||
@attr(shard=4)
|
||||
@ddt
|
||||
class YouTubeVideoTest(VideoBaseTest):
|
||||
""" Test YouTube Video Player """
|
||||
|
||||
@@ -491,15 +493,16 @@ class YouTubeVideoTest(VideoBaseTest):
|
||||
self.assertTrue(self.video.is_button_shown('transcript_button'))
|
||||
self._verify_caption_text('Welcome to edX.')
|
||||
|
||||
def test_download_transcript_button_works_correctly(self):
|
||||
@data(('srt', '00:00:00,260'), ('txt', 'Welcome to edX.'))
|
||||
@unpack
|
||||
def test_download_transcript_links_work_correctly(self, file_type, search_text):
|
||||
"""
|
||||
Scenario: Download Transcript button works correctly
|
||||
Scenario: Download 'srt' transcript link works correctly.
|
||||
Download 'txt' transcript link works correctly.
|
||||
Given the course has Video components A and B in "Youtube" mode
|
||||
And Video component C in "HTML5" mode
|
||||
And I have defined downloadable transcripts for the videos
|
||||
Then I can download a transcript for Video A in "srt" format
|
||||
And I can download a transcript for Video A in "txt" format
|
||||
And I can download a transcript for Video B in "txt" format
|
||||
And the Download Transcript menu does not exist for Video C
|
||||
"""
|
||||
|
||||
@@ -524,19 +527,7 @@ class YouTubeVideoTest(VideoBaseTest):
|
||||
self.navigate_to_video()
|
||||
|
||||
# check if we can download transcript in "srt" format that has text "00:00:00,260"
|
||||
self.assertTrue(self.video.downloaded_transcript_contains_text('srt', '00:00:00,260'))
|
||||
|
||||
# select the transcript format "txt"
|
||||
self.assertTrue(self.video.select_transcript_format('txt'))
|
||||
|
||||
# check if we can download transcript in "txt" format that has text "Welcome to edX."
|
||||
self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Welcome to edX.'))
|
||||
|
||||
# open vertical containing video "B"
|
||||
self.course_nav.go_to_vertical('Test Vertical-1')
|
||||
|
||||
# check if we can download transcript in "txt" format that has text "Equal transcripts"
|
||||
self.assertTrue(self.video.downloaded_transcript_contains_text('txt', 'Equal transcripts'))
|
||||
self.assertTrue(self.video.downloaded_transcript_contains_text(file_type, search_text))
|
||||
|
||||
# open vertical containing video "C"
|
||||
self.course_nav.go_to_vertical('Test Vertical-2')
|
||||
|
||||
Reference in New Issue
Block a user