Skip to content

VS Code versions and profiles

Your tests choose the VS Code version they run against with a variable such as ${VSCODE_VERSION}:

  • A fixed version such as 1.141.0 gives reproducible runs and is downloaded only once.
  • stable and insiders always use the newest build, which shows early when a new VS Code release breaks your tests.

The workbench’s DOM can differ between VS Code versions, so a locator that works with one version may fail with another. Because the workbench keywords take their locators from variables, a version with other locators needs no other keywords: a RobotCode profile in robot.toml sets the variables for that version.

The example project’s robot.toml has one profile, locator-override, which replaces the command palette locator with an equivalent selector to show the mechanism:

robot.toml
# Robot Framework configuration, used by RobotCode (https://robotcode.io).
# Run the tests from this folder with `robotcode robot`.
# Personal settings, such as a local VSCODE_EXECUTABLE, belong in .robot.toml, which is not committed.
paths = ["tests"]
output-dir = "results"
# The locators are variables of the resources in tests/resources. When another VS Code version,
# or a fork, needs other locators, add a profile for it that overrides them, usually together
# with VSCODE_VERSION, and select it with `robotcode -p <profile> robot`. The keywords stay the same.
#
# This profile overrides the command palette locator with an equivalent selector, to show how.
[profiles.locator-override]
description = "Find command palette rows through the quick input widget instead of its list"
extend-variables = { COMMAND_PALETTE_ROW = '.quick-input-widget .monaco-list-row[aria-label="{title}"], .quick-input-widget .monaco-list-row[aria-label^="{title}, "]' }
# Where the tests run. Without a display profile they run on the normal desktop.
# The wrappers run as shell scripts; RobotCode appends its command line, which they run as "$@".
# SCREEN_SIZE sets the screen size of xvfb and xephyr, default 1920x1080, from the shell or a profile's extend-env.
# Both start the window manager Openbox, if it is installed, so that windows can be maximised.
[profiles.xvfb]
description = "Run hidden on a Full HD Xvfb screen (Linux)"
enabled.if = "platform.system() == 'Linux'"
wrapper = ["sh", "-c", '''
env -u WAYLAND_DISPLAY XDG_SESSION_TYPE=x11 xvfb-run -a -s "-screen 0 ${SCREEN_SIZE:-1920x1080}x24" \
sh -c 'command -v openbox >/dev/null && openbox >/dev/null 2>&1 & exec "$@"' wm "$@"
''', "xvfb-run"]
[profiles.xephyr]
description = "Run in a separate Full HD Xephyr window on the desktop (Linux)"
enabled.if = "platform.system() == 'Linux'"
# Starts Xephyr on a free display, runs the tests on it, and ends it afterwards.
wrapper = ["sh", "-c", '''
fifo=$(mktemp -u) && mkfifo "$fifo" || exit 1
Xephyr -displayfd 3 -screen "${SCREEN_SIZE:-1920x1080}" -title "Robot Framework" -noreset 3>"$fifo" &
xephyr=$!
trap 'kill "$xephyr" 2>/dev/null; rm -f "$fifo"' EXIT
read -r display <"$fifo" || exit 1
command -v openbox >/dev/null && DISPLAY=":$display" openbox >/dev/null 2>&1 &
env -u WAYLAND_DISPLAY XDG_SESSION_TYPE=x11 DISPLAY=":$display" "$@"
''', "xephyr-run"]
[profiles.local]
description = "Run on the normal desktop"
# Changes the screen size of xvfb and xephyr. extend-env keeps the variables that other selected profiles set,
# where env would replace them. Combine it with xvfb or xephyr, for example `robotcode -p xvfb -p small-screen robot`.
[profiles.small-screen]
description = "Use a 1280x800 screen with xvfb or xephyr (Linux)"
enabled.if = "platform.system() == 'Linux'"
extend-env = { SCREEN_SIZE = "1280x800" }

A real project adds a profile for each VS Code version, or fork, whose locators differ, and usually sets VSCODE_VERSION in the same profile. Select a profile with -p:

Terminal window
robotcode -p locator-override robot

Profile variables override the defaults in the resources, like variables given on the command line. To test several VS Code versions, for example on CI, run the tests once per profile.

Without RobotCode, pass the variables with --variable or collect them in a variable file per version and pass it with --variablefile.

Settings that only apply to your machine, such as an installed VS Code, go into a .robot.toml next to robot.toml. RobotCode reads it after robot.toml, and it is not committed:

[variables]
VSCODE_EXECUTABLE = "/usr/share/code/code"