Browser keywords in VS Code
VS Code is an Electron application, so everything in Browser keywords in applications applies to it as well: which keywords work, which ones the libraries hide and why, such as Save Page As PDF, and where Electron behaves differently from a web browser. In addition:
| Feature | Status | Notes |
|---|---|---|
Evaluate JavaScript, Wait For Function |
Works | They run in the workbench’s page, not in the extension host. |
| Copy and paste in the editor | Works | |
A second window: Switch Window with its title, Close Page |
Works | See windows.robot in the example. |
| Locator handlers for notifications | Works | See below. |
Drag And Drop in the explorer |
Needs a setting | explorer.confirmDragAndDrop: false, otherwise VS Code asks for confirmation. |
| File dialogs | Needs a setting | files.simpleDialog.enable: true makes VS Code use its own dialog instead of the native one. |
| Native message boxes | Needs the main process | Evaluate In Main Process replaces dialog.showMessageBox before VS Code opens one. |
Record Selector |
Needs an option | bypass_csp=True of Start VS Code. The workbench requires Trusted Types for scripts, and the recorder adds a script to the page. |
Maximize Window, Minimize Window |
Needs a window manager | See CI and the Linux display. Set Window Size works without one. |
The example project uses many of these features. The following snippets show the others; they assume a VS Code started with Start VS Code.
An aria snapshot of a part of the workbench lists its roles and names:
${snapshot} = Get Aria Snapshot .activitybarThe workbench’s console messages and page errors:
${messages} = Get Console Log${errors} = Get Page ErrorsA locator handler closes notifications before every Browser action. The close button of a notification is shown only when the notification is in focus, so the handler first clicks the message and then the button:
Add Locator Handler Custom .notifications-toasts .notification-toast... ${{ [{"action": "click", "selector": ".notifications-toasts .notification-list-item-message"}, {"action": "click", "selector": ".notifications-toasts .notification-toast .codicon-notifications-clear"}] }}Moving a file into a folder in the explorer, with explorer.confirmDragAndDrop set to false in the settings of Start VS Code:
Drag And Drop .explorer-folders-view >> text="notes.txt" .explorer-folders-view >> text="archive"JavaScript coverage of the workbench while a command runs:
Start CoverageRun Command Robot Example: Say Hello${report} = Stop Coverage