VideoPuppeteer

video_puppeteer.VideoPuppeteer

class external_media_tests.media_utils.video_puppeteer.VideoPuppeteer(marionette, url, video_selector='video', interval=1, set_duration=0, stall_wait_time=0, timeout=60)[source]

Bases: object

Wrapper to control and introspect HTML5 video elements.

A note about properties like current_time and duration: These describe whatever stream is playing when the property is called. It is possible that many different streams are dynamically spliced together, so the video stream that is currently playing might be the main video or it might be something else, like an ad, for example.

Parameters:
  • marionette – The marionette instance this runs in.
  • url – the URL of the page containing the video element.
  • video_selector – the selector of the element that we want to watch. This is set by default to ‘video’, which is what most sites use, but others should work.
  • interval – The polling interval that is used to check progress.
  • set_duration – When set to >0, the polling and checking will stop at the number of seconds specified. Otherwise, this will stop at the end of the video.
  • stall_wait_time – The amount of time to wait to see if a stall has cleared. If 0, do not check for stalls.
  • timeout – The amount of time to wait until the video starts.
corrupted_frames
Returns:Number of video frames corrupted since the creation of this video element. A corrupted frame may be created or dropped.
current_time
Returns:Current time of whatever stream is playing right now.
dropped_frames
Returns:Number of video frames created and dropped since the creation of this video element.
duration
Returns:Duration in seconds of whatever stream is playing right now.
execute_video_script(script)[source]

Execute JS script in ‘content’ context with access to video element.

Parameters:script – script to be executed
Returns:value returned by script
get_debug_lines()[source]

Get Firefox internal debugging for the video element.

Returns:A text string that has Firefox-internal debugging information.
lag
Returns:The difference in time between where the video is currently playing and where it should be playing given the time we started the video.
pause()[source]

Tell the video element to Pause.

play()[source]

Tell the video element to Play.

remaining_time
Returns:How much time is remaining given the duration of the video and the duration that has been set.
total_frames
Returns:Number of video frames created and dropped since the creation of this video element.
update_expected_duration()[source]

Update the duration of the target video at self.test_url (in seconds).

expected_duration represents the following: how long do we expect playback to last before we consider the video to be ‘complete’? If we only want to play the first n seconds of the video, expected_duration is set to n.

video_src
Returns:The url of the actual video file, as opposed to the url of the page with the video element.
video_url
Returns:The URL of the video that this element is playing.

video_puppeteer.VideoException

exception external_media_tests.media_utils.video_puppeteer.VideoException[source]

Exception class to use for video-specific error processing.

video_puppeteer.playback_started

external_media_tests.media_utils.video_puppeteer.playback_started(video)[source]

Determine if video has started

Parameters:video – The VideoPuppeteer instance that we are interested in.
Returns:True if is playing; False otherwise

video_puppeteer.playback_done

external_media_tests.media_utils.video_puppeteer.playback_done(video)[source]

If we are near the end and there is still a video element, then we are essentially done. If this happens to be last time we are polled before the video ends, we won’t get another chance.

Parameters:video – The VideoPuppeteer instance that we are interested in.
Returns:True if we are close enough to the end of playback; False otherwise.