vscode-extension-tester
Version:
ExTester is a package that is designed to help you run UI tests for your Visual Studio Code extensions using selenium-webdriver.
111 lines (110 loc) • 4.58 kB
TypeScript
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License", destination); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { WebDriver, logging } from '@redhat-developer/page-objects';
import { ReleaseQuality } from './util/codeUtil';
export declare class VSBrowser {
static readonly baseVersion = "1.37.0";
static readonly browserName = "vscode";
private storagePath;
private extensionsFolder;
private customSettings;
private _driver;
private codeVersion;
private releaseType;
private logLevel;
private static _instance;
private readonly _startTimestamp;
private formatTimestamp;
constructor(codeVersion: string, releaseType: ReleaseQuality, customSettings?: object, logLevel?: logging.Level);
/**
* Starts the vscode browser from a given path
* @param codePath path to code binary
*/
start(codePath: string): Promise<VSBrowser>;
/**
* Returns a reference to the underlying instance of Webdriver
*/
get driver(): WebDriver;
/**
* Returns the vscode version as string
*/
get version(): string;
/**
* Returns an instance of VSBrowser
*/
static get instance(): VSBrowser;
/**
* Waits for the VS Code workbench UI to be fully loaded and optionally performs
* an additional async or sync check after the workbench appears.
*
* This method waits for the presence of the `.monaco-workbench` element within the specified timeout.
* If a WebDriver error occurs (e.g. flaky startup), it retries after a short delay.
* Additionally, a follow-up function (`waitForFn`) can be passed to perform custom
* readiness checks (e.g. for UI elements, extensions, or custom content).
*
* @param timeout - Maximum time in milliseconds to wait for the workbench to appear (default: 30,000 ms).
* @param waitForFn - Optional function (sync or async) to be executed after the workbench is located.
*
* @throws If the workbench is not found in time and no recoverable WebDriver error occurred.
*
* @example
* // Wait for the workbench with default timeout
* await waitForWorkbench();
*
* @example
* // Wait for the workbench and ensure a custom UI element is present
* await waitForWorkbench(10000, async () => {
* await driver.wait(until.elementLocated(By.id('my-element')), 5000);
* });
*/
waitForWorkbench(timeout?: number, waitForFn?: () => void | Promise<any>): Promise<void>;
/**
* Terminates the webdriver/browser
*/
quit(): Promise<void>;
/**
* Take a screenshot of the browser
* @param name file name of the screenshot without extension
*/
takeScreenshot(name: string): Promise<void>;
/**
* Get a screenshots folder path
* @returns string path to the screenshots folder
*/
getScreenshotsDir(): string;
/**
* Opens one or more resources in the editor and optionally performs a follow-up action.
*
* This method accepts a variable number of arguments. All string arguments are interpreted
* as resource paths to be opened. Optionally, a single callback function (synchronous or asynchronous)
* can be provided as the last argument. This callback will be invoked after all resources have been opened.
*
* @param args - A list of file paths to open followed optionally by a callback function.
* The callback can be either synchronous or asynchronous.
*
* @example
* // Open two files
* await openResources('file1.ts', 'file2.ts');
*
* @example
* // Open one file and then wait for a condition
* await openResources('file1.ts', async () => {
* await waitForElementToLoad();
* });
*/
openResources(...args: (string | (() => void | Promise<any>))[]): Promise<void>;
}