Skip to content

Videos and traces of VS Code

Start VS Code records videos, traces and HAR files as Start Electron Application does. Videos and slow motion and Traces and HAR files describe the options, presenter mode and how to open a trace. This page adds what is specific to VS Code, with the tests of the example project.

VS Code does not fill the screen by itself; its window keeps its default size. With the setting window.newWindowDimensions set to maximized and a window manager, it fills the screen, and screenshots and videos show the whole screen size. Maximize Window maximises a window during a test as well. The display profiles xvfb and xephyr start a window manager, see CI and the Linux display.

In a video, a window keeps its own size: a larger window is scaled down to fit, and a smaller one is shown at its own size with a grey margin. For a full frame, open VS Code maximised and record in the size of the screen.

The example project’s video.robot does this. Its keyword reads the screen size from SCREEN_SIZE, which the display profiles use as well, and opens VS Code, which the example opens maximised, with record_video in that size and with the action overlay. The tests do not close VS Code themselves: Browser closes it at the end of each test, which finishes the video.

  • With presenter mode: the first two tests switch on presenter mode, which slows them down and highlights what they act on, so the videos are easy to follow. In presenter mode, Browser also waits five seconds before it closes VS Code, so the video shows the result. The second test creates a Python script, saves it through VS Code’s own dialog and runs it with the run button above the editor.
  • Without presenter mode: the third test runs at full speed and creates the script in the explorer. Presenter mode could not reach the explorer’s actions reliably, because VS Code redraws them while the mouse moves over the explorer. Browser does not wait before closing VS Code then, so the test pauses at the end.
  • Scope: presenter mode has no scope and stays on after a test, so each test sets it, and the suite switches it off when it ends.
tests/video.robot
*** Settings ***
Documentation Records videos of VS Code while the tests demonstrate the extension
... and create and run a Python script.
...
... The videos have the size of the screen, which the display profiles set with
... SCREEN_SIZE, so that the maximised VS Code fills them, and Playwright shows each
... action in the video. The log embeds the videos. Browser closes VS Code at the end
... of each test, which finishes the video.
...
... The first two tests use presenter mode, which slows the steps down and highlights
... what they act on; Browser then also waits five seconds before it closes VS Code,
... so that the video shows the result. The last test records without presenter mode.
...
... The Python tests need network access for the Marketplace; leave them out with
... `--exclude network`.
Library String
Resource resources/vscode.resource
Resource resources/command_palette.resource
Resource resources/quick_pick.resource
Resource resources/notifications.resource
Resource resources/webview.resource
Resource resources/editor.resource
Resource resources/explorer.resource
Resource resources/extensions.resource
Resource resources/file_dialog.resource
Resource resources/python.resource
Resource resources/terminal.resource
# Presenter mode stays on after a test, so the suite switches it off when it ends.
Suite Teardown Set Presenter Mode False
*** Test Cases ***
Demonstration Of The Extension
Set Presenter Mode ${{ {"duration": "1s"} }}
Start Example VS Code With Video
Run Command Robot Example: Say Hello
Notification Should Be Shown Hello Robot
Run Command Robot Example: Pick
Select Quick Pick Item Banana
Notification Should Be Shown You picked Banana
Run Command Robot Example: Open Webview
${previous} = Enter Webview robot.example-extension
Click id=click-me
Get Text id=status == Clicked
Leave Webview ${previous}
Python Script Created And Run
[Tags] network
Set Presenter Mode ${{ {"duration": "1s"} }}
${extensions} = Prepared Extensions ms-python.python
Start Example VS Code With Video extensions_dir=${extensions}
New File
Keyboard Input type print("Hello Robot Framework")
${workspace} = Example Workspace
Save File With Dialog ${workspace}/greeting.py
Active Editor Should Be greeting.py
Run Python File
Terminal Should Show Hello Robot Framework
Python Script Created In The Explorer Without Presenter Mode
[Documentation] Without presenter mode, the steps run at full speed, and the explorer's
... actions, which VS Code redraws while the mouse moves over the explorer, work reliably.
... Browser does not wait before it closes VS Code, so the test pauses at the end.
[Tags] network
Set Presenter Mode False
${extensions} = Prepared Extensions ms-python.python
Start Example VS Code With Video extensions_dir=${extensions}
Create File In Explorer greeting.py
Active Editor Should Be greeting.py
Keyboard Input type print("Hello Robot Framework")
Save File
Run Python File
Terminal Should Show Hello Robot Framework
Sleep 2s Let the video show the result before Browser closes VS Code.
*** Keywords ***
Start Example VS Code With Video
[Documentation] Starts VS Code and records a video in the size of the screen.
... Further named arguments, such as `extensions_dir`, are passed on.
[Arguments] &{options}
${width} ${height} = Split String %{SCREEN_SIZE=1920x1080} x
VAR &{size} width=${width} height=${height}
VAR &{show_actions} duration=${800} position=top-right
VAR &{record_video} size=${size} showActions=${show_actions}
Start Example VS Code record_video=${record_video} &{options}

Without a window manager, Set Viewport Size 1920 1080 after Start VS Code makes the workbench fill the frame instead. It emulates the size inside the page and leaves the window as it is.

Set Window Size sizes the window itself, also without a window manager. It sets the size of the window’s page, which the video shows. Without a window manager, a window stays at least one pixel smaller than the screen, so give the window and the video a size below the screen size:

Start VS Code ${VSCODE_EXECUTABLE} record_video={'size': {'width': 1600, 'height': 900}}
Set Window Size 1600 900

The example project’s tracing.robot traces two tests. The second one also records the network traffic of a webview:

tests/tracing.robot
*** Settings ***
Documentation Records a Playwright trace of each test and a HAR file of the workbench's network traffic.
...
... The traces are saved in `browser/traces` in the output directory when VS Code
... closes at the end of a test. Open one with `rfbrowser show-trace <file>`.
Resource resources/vscode.resource
Resource resources/command_palette.resource
Resource resources/notifications.resource
Resource resources/webview.resource
*** Test Cases ***
Trace Of A Command
Start Example VS Code tracing=${True}
Run Command Robot Example: Say Hello
Notification Should Be Shown Hello Robot
Trace Of A Webview With The Network Traffic
Start Example VS Code tracing=${True} record_har=${{ {"path": "har/webview.har"} }}
Run Command Robot Example: Open Webview
${previous} = Enter Webview robot.example-extension
Click id=click-me
Get Text id=status == Clicked
Leave Webview ${previous}

The tests leave closing VS Code to Browser, which saves the traces at the end of each test.