-
Notifications
You must be signed in to change notification settings - Fork 76
ViewSection
github-actions[bot] edited this page Feb 26, 2025
·
6 revisions
This is an abstract class for side bar view sections. Most behavior is defined here, but for specifics, check out the specific subtypes.
Get a section handle from an open side bar.
import { SideBarView } from 'vscode-extension-tester';
...
const section = await new SideBarView().getContent().getSection('workspace');
// get the section title
const title = section.getTitle();
// collapse section if possible
await section.collapse(timeout: ms);
// expand if possible
await section.expand(timeout: ms);
// find if section is expanded
const expanded = await section.isExpanded();
Section header may also contain some action buttons.
// get an action button by label
const action = (await section.getAction("New File")) as ViewPanelAction;
// get all action buttons for the section
const actions = await section.getActions();
// click an action button
await action.click();
Note: Be aware that it is not supported on macOS. For more information see Known Issues.
// find an view action button by title
const action = (await view.getAction("Hello Who...")) as ViewPanelActionDropdown;
// open the dropdown for that button
const menu = await action.open();
// select an item from an opened context menu
await menu.select("Hello a World");
// get all visible items, note that currently not shown on screen will not be retrieved
const visibleItems = await section.getVisibleItems();
// find an item with a given label, involves scrolling to items currently not showing
const item = await section.findItem("package.json");
// recursively navigate to an item and click it
// if the item has children (./src/webdriver/components folder)
const children = await section.openItem("src", "webdriver", "components");
// if the item is a leaf
await section.openItem("src", "webdriver", "components", "AbstractElement.ts");