Skip to content

Videos and slow motion

A video shows what a test did, which helps when a test fails on CI, and it is a good way to demonstrate an extension.

Start Electron Application and Start VS Code record a video when they get record_video. The keys are those of Browser’s recordVideo for New Context:

  • dir: the folder for the videos. Relative paths are relative to Browser’s video folder browser/video in the output directory, which is also the default.
  • size: the size of the video, as width and height. The default is 1280×720.
  • fps: the frame rate of the video. The default is 25.
  • showActions: shows each performed action in the video, with duration in milliseconds, position (for example top-right), cursor, and style, which takes CSS declarations for the action’s title, a point marker and a highlight box over the element.

An empty dictionary records with the defaults:

*** Settings ***
Library Electron
*** Test Cases ***
Recorded Run
Start Electron Application /opt/my-app/my-app record_video={}
Click text=Say hello
Close Electron Application

The log embeds the video, and the page details that the keyword returns contain its path. Playwright finishes the file when the application closes, through Close Electron Application, Close VS Code or Browser’s automatic closing.

Playwright needs its own ffmpeg to record. It comes with any browser that Browser installs, but not with --skip-browsers. The smallest browser is the headless shell, see Installation. Without ffmpeg, Start Electron Application fails with Video recording has not been started.

Playwright’s slowMo is not available for Electron applications, because Playwright has no such option when it launches them. Browser’s presenter mode serves instead. Before every keyword that takes a selector, it scrolls to the element, highlights it and waits for the given duration:

Set Presenter Mode {'duration': '1s', 'color': 'red'}
Click id=change
Set Presenter Mode False

Keyboard keywords such as Keyboard Input have no selector and are not slowed down. Together with showActions in the video, presenter mode makes a demonstration easy to follow.