YoutubePuppeteer

youtube_puppeteer.YouTubePuppeteer

class external_media_tests.media_utils.youtube_puppeteer.YouTubePuppeteer(marionette, url, autostart=True, **kwargs)[source]

Bases: external_media_tests.media_utils.video_puppeteer.VideoPuppeteer

Wrapper around a YouTube .html5-video-player element.

Can be used with youtube videos or youtube videos at embedded URLS. E.g. both https://www.youtube.com/watch?v=AbAACm1IQE0 and https://www.youtube.com/embed/AbAACm1IQE0 should work.

Using an embedded video has the advantage of not auto-playing more videos while a test is running.

Compared to video puppeteer, this class has the benefit of accessing the youtube player object as well as the video element. The YT player will report information for the underlying video even if an add is playing (as opposed to the video element behaviour, which will report on whatever is play at the time of query), and can also report if an ad is playing.

Partial reference: https://developers.google.com/youtube/iframe_api_reference. This reference is useful for site-specific features such as interacting with ads, or accessing YouTube’s debug data.

mse_enabled()[source]

Check if the video source indicates mse usage for current video. Refreshes state.

Returns:True if MSE is being used, False if not.
playback_done()[source]

Check whether playback is done. Refreshes state.

Returns:True if play back has ended, False if not.
playback_started()[source]

Check whether playback has started. Refreshes state.

Returns:True if play back has started, False if not.
player_pause()[source]

Pause via YouTube API.

player_play()[source]

Play via YouTube API.

process_ad()[source]

Wait for this ad to finish. Refreshes state.

wait_for_almost_done(final_piece=120)[source]

Allow the given video to play until only final_piece seconds remain, skipping ads mid-way as much as possible. final_piece should be short enough to not be interrupted by an ad.

Depending on the length of the video, check the ad status every 10-30 seconds, skip an active ad if possible.

This call refreshes state.

Parameters:final_piece – The length in seconds of the desired remaining time

to wait until.

youtube_puppeteer.playback_started

youtube_puppeteer.playback_done

youtbue_puppeteer.wait_for_almost_done