Skip to content

Page Object APIs

In order to keep everyone from having to go through the VS Code DOM, which is quite complicated, the framework provides page objects to work with parts of VS Code directly.

See the individual page object pages below for a quick usage guide. Use the sidebar or the search to jump straight to a component.

AbstractElement — base class for custom page objects

Section titled “AbstractElement — base class for custom page objects”

All built-in page objects extend AbstractElement, and you can too. When your extension contributes custom UI that is not covered by a built-in, create your own class:

import { AbstractElement, By } from "vscode-extension-tester";
export class MyExtensionPanel extends AbstractElement {
constructor() {
super(MyExtensionPanel.locators.MyExtensionPanel.constructor);
}
// ... your interaction methods
}

The locator keys (MyExtensionPanel.locators.MyExtensionPanel.*) are resolved from a locator contribution file you provide at startup. See Custom Page Objects for the full setup guide.

AbstractElement.click() automatically recovers from clicks intercepted by hover overlays, so page objects do not fail when a tooltip happens to cover the target. Custom page-object authors also inherit safeClick(), safeSendKeys(), safeGetText(), safeGetAttribute(), withRecovery(fn, maxRetries) and waitForStable(timeout) for stale-element-safe interactions:

await myPanel.withRecovery(async (self) => self.getText());