Merge pull request #4112 from edx/ammar/youtube-video-quality-tests
Youtube Video Quality Button Tests
This commit is contained in:
@@ -17,7 +17,8 @@ VIDEO_BUTTONS = {
|
|||||||
'pause': '.video_control.pause',
|
'pause': '.video_control.pause',
|
||||||
'fullscreen': '.add-fullscreen',
|
'fullscreen': '.add-fullscreen',
|
||||||
'download_transcript': '.video-tracks > a',
|
'download_transcript': '.video-tracks > a',
|
||||||
'speed': '.speeds'
|
'speed': '.speeds',
|
||||||
|
'quality': '.quality-control',
|
||||||
}
|
}
|
||||||
|
|
||||||
CSS_CLASS_NAMES = {
|
CSS_CLASS_NAMES = {
|
||||||
@@ -852,3 +853,33 @@ class VideoPage(PageObject):
|
|||||||
lambda: self.position(video_display_name) == position,
|
lambda: self.position(video_display_name) == position,
|
||||||
'Position is {position}'.format(position=position)
|
'Position is {position}'.format(position=position)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def is_quality_button_visible(self, video_display_name=None):
|
||||||
|
"""
|
||||||
|
Get the visibility state of quality button
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
video_display_name (str or None): Display name of a Video.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: visibility status
|
||||||
|
|
||||||
|
"""
|
||||||
|
selector = self.get_element_selector(video_display_name, VIDEO_BUTTONS['quality'])
|
||||||
|
return self.q(css=selector).visible
|
||||||
|
|
||||||
|
def is_quality_button_active(self, video_display_name=None):
|
||||||
|
"""
|
||||||
|
Check if quality button is active or not.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
video_display_name (str or None): Display name of a Video.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: active status
|
||||||
|
|
||||||
|
"""
|
||||||
|
selector = self.get_element_selector(video_display_name, VIDEO_BUTTONS['quality'])
|
||||||
|
|
||||||
|
classes = self.q(css=selector).attrs('class')[0].split()
|
||||||
|
return 'active' in classes
|
||||||
|
|||||||
@@ -1,11 +1,34 @@
|
|||||||
"""
|
"""
|
||||||
Test helper functions and base classes.
|
Test helper functions and base classes.
|
||||||
"""
|
"""
|
||||||
|
import unittest
|
||||||
|
import functools
|
||||||
import requests
|
import requests
|
||||||
from path import path
|
from path import path
|
||||||
from bok_choy.web_app_test import WebAppTest
|
from bok_choy.web_app_test import WebAppTest
|
||||||
|
|
||||||
|
|
||||||
|
def skip_if_browser(browser):
|
||||||
|
"""
|
||||||
|
Method decorator that skips a test if browser is `browser`
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser (str): name of internet browser
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Decorated function
|
||||||
|
|
||||||
|
"""
|
||||||
|
def decorator(test_function):
|
||||||
|
@functools.wraps(test_function)
|
||||||
|
def wrapper(self, *args, **kwargs):
|
||||||
|
if self.browser.name == browser:
|
||||||
|
raise unittest.SkipTest('Skipping as this test will not work with {}'.format(browser))
|
||||||
|
test_function(self, *args, **kwargs)
|
||||||
|
return wrapper
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def is_youtube_available():
|
def is_youtube_available():
|
||||||
"""
|
"""
|
||||||
Check if the required youtube urls are available.
|
Check if the required youtube urls are available.
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ from ...pages.lms.course_nav import CourseNavPage
|
|||||||
from ...pages.lms.auto_auth import AutoAuthPage
|
from ...pages.lms.auto_auth import AutoAuthPage
|
||||||
from ...pages.lms.course_info import CourseInfoPage
|
from ...pages.lms.course_info import CourseInfoPage
|
||||||
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
|
from ...fixtures.course import CourseFixture, XBlockFixtureDesc
|
||||||
|
from ..helpers import skip_if_browser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VIDEO_SOURCE_PORT = 8777
|
VIDEO_SOURCE_PORT = 8777
|
||||||
@@ -917,3 +919,49 @@ class Html5VideoTest(VideoBaseTest):
|
|||||||
self.assertTrue(self.video.is_video_rendered('html5'))
|
self.assertTrue(self.video.is_video_rendered('html5'))
|
||||||
|
|
||||||
self.assertTrue(all([source in HTML5_SOURCES for source in self.video.sources()]))
|
self.assertTrue(all([source in HTML5_SOURCES for source in self.video.sources()]))
|
||||||
|
|
||||||
|
|
||||||
|
class YouTubeQualityTest(VideoBaseTest):
|
||||||
|
""" Test YouTube Video Quality Button """
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(YouTubeQualityTest, self).setUp()
|
||||||
|
|
||||||
|
@skip_if_browser('firefox')
|
||||||
|
def test_quality_button_visibility(self):
|
||||||
|
"""
|
||||||
|
Scenario: Quality button appears on play.
|
||||||
|
|
||||||
|
Given the course has a Video component in "Youtube" mode
|
||||||
|
Then I see video button "quality" is hidden
|
||||||
|
And I click video button "play"
|
||||||
|
Then I see video button "quality" is visible
|
||||||
|
"""
|
||||||
|
self.navigate_to_video()
|
||||||
|
|
||||||
|
self.assertFalse(self.video.is_quality_button_visible())
|
||||||
|
|
||||||
|
self.video.click_player_button('play')
|
||||||
|
|
||||||
|
self.assertTrue(self.video.is_quality_button_visible())
|
||||||
|
|
||||||
|
@skip_if_browser('firefox')
|
||||||
|
def test_quality_button_works_correctly(self):
|
||||||
|
"""
|
||||||
|
Scenario: Quality button works correctly.
|
||||||
|
|
||||||
|
Given the course has a Video component in "Youtube" mode
|
||||||
|
And I click video button "play"
|
||||||
|
And I see video button "quality" is inactive
|
||||||
|
And I click video button "quality"
|
||||||
|
Then I see video button "quality" is active
|
||||||
|
"""
|
||||||
|
self.navigate_to_video()
|
||||||
|
|
||||||
|
self.video.click_player_button('play')
|
||||||
|
|
||||||
|
self.assertFalse(self.video.is_quality_button_active())
|
||||||
|
|
||||||
|
self.video.click_player_button('quality')
|
||||||
|
|
||||||
|
self.assertTrue(self.video.is_quality_button_active())
|
||||||
|
|||||||
@@ -30,20 +30,3 @@ Feature: LMS.Video component
|
|||||||
When I open video "D"
|
When I open video "D"
|
||||||
Then the video has rendered in "HTML5" mode
|
Then the video has rendered in "HTML5" mode
|
||||||
And the video does not show the captions
|
And the video does not show the captions
|
||||||
|
|
||||||
# 4
|
|
||||||
@skip_firefox
|
|
||||||
Scenario: Quality button appears on play
|
|
||||||
Given the course has a Video component in "Youtube" mode
|
|
||||||
Then I see video button "quality" is hidden
|
|
||||||
And I click video button "play"
|
|
||||||
Then I see video button "quality" is visible
|
|
||||||
|
|
||||||
# 5
|
|
||||||
@skip_firefox
|
|
||||||
Scenario: Quality button works correctly
|
|
||||||
Given the course has a Video component in "Youtube" mode
|
|
||||||
And I click video button "play"
|
|
||||||
And I see video button "quality" is inactive
|
|
||||||
And I click video button "quality"
|
|
||||||
Then I see video button "quality" is active
|
|
||||||
|
|||||||
Reference in New Issue
Block a user