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.
Recording a video
Section titled “Recording a video”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 folderbrowser/videoin the output directory, which is also the default.size: the size of the video, aswidthandheight. The default is 1280×720.fps: the frame rate of the video. The default is 25.showActions: shows each performed action in the video, withdurationin milliseconds,position(for exampletop-right),cursor, andstyle, which takes CSS declarations for the action’stitle, apointmarker and ahighlightbox 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 ApplicationThe 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.
ffmpeg
Section titled “ffmpeg”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.
Slow motion
Section titled “Slow motion”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=changeSet Presenter Mode FalseKeyboard 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.