Video - test subject

The video test subject represents a video playing object inside the application and allows for testing things around video playback.

Basic usage

In the Test Editor this subject is called Video:

Video with properties expanded assertion
Video with properties expanded assertion

In the Suitest JavaScript API use the video subject:

        name: PROP.VIDEO_POSITION,
        val: 27876,
        name: PROP.VIDEO_LENGTH,
        val: 137811,
        name: PROP.VIDEO_URL,
        val: '',
        name: PROP.VIDEO_STATE,
        val: 'playing',

Available properties

The video test subject allows for inspecting the following properties:

  • Video length - the reported length of the video file (in seconds).

  • Video position - the reported position of the play head (in seconds).

  • Video state - the playback state of the video object. One of the following (based on platform): stopped, error, playing, paused, connecting, buffering, finished, idle, preparing, prepared, playback completed, unknown.

  • Video URL - the URL of the video file currently being played.

Suitest reads out the video properties directly from the platforms video object bypassing all upper layers like your application framework.

Suitest supports the following video objects: HTML 5 video tag, HbbTV broadcast video object, LG Netcast video object, Xbox MediaElement and MediaPlayerElement. There is a great chance that it will work for other video objects as well.

Dealing with multiple videos

In the rare event when the application is internally using several video objects the Suitest video subject may not recognize which from which video object to collect the playback information. In this case store the correct video object in the Element repository and use the View element subject instead.

JavaScript video adapter

Suitest automatically collects all video properties on most of the supported platforms. However, there are lots of custom video player implementations in the HTML world, so Suitest can't possibly provide support for all of them.

JavaScript video adapter is a simple API, that allows application developers to provide Suitest with video playback parameters for custom video players.

To allow Suitest to access some of the video object properties, you can register a callback function as follows in your application's code:

 * @param {HTMLElement} [elementFoundBySuitest] - Suitest will provide
 *        video element if it finds one on the page
 * @return {Object}
function suitestVideoAdapter (elementFoundBySuitest) {
    const element = elementFoundBySuitest || getMyVideoElementSomehow();

    return {
        element: element,
        url: getMyVideoUrlSomehow(element),
        state: getMyVideoStateSomehow(element),
        pos: getMyVideoPositionSomehow(element),
        length: getMyVideoLengthSomehow(element),

window.suitest && window.suitest.setVideoAdapter(suitestVideoAdapter);

You will need to implement all the get* functions above to extract the values from your video object. All returned fields are optional.

  • element - Represents the video object, could be the HTMLElement or any other truthy value. Suitest will use it to determine if the element exists and will further provide it to the JavaScript callback in matchJS lines if used. If the element is an HTMLElement, Suitest would also fetch non-video properties (e.g. element's width, height, class name etc.) as well.

  • url - Current playback URL of the video.

  • state - Current playback state of the video. Suitest recognizes the following values: stopped, playing, paused, connecting, buffering, finished, error. Suitest will throw an error if any other value is provided.

  • pos - Current playback position of the video in milliseconds.

  • length - Length of the video being played in milliseconds.

Your callback function should be as lightweight as possible, as Suitest will call it sequentially in interval during "Wait until video ..." operations. We recommend that you cache a reference to the video element and it's static properties whenever possible.

Our functional example for the Samsung Tizen platform is available in gist.