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 and 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: This reference is useful for site-specific features such as interacting with ads, or accessing YouTube’s debug data.


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

Returns:True if MSE is being used, False if not.

Check whether playback is done. Refreshes state.

Returns:True if play back has ended, False if not.

Check whether playback has started. Refreshes state.

Returns:True if play back has started, False if not.

Pause via YouTube API.


Play via YouTube API.


Wait for this ad to finish. Refreshes state.


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.