UNPKG

@redhat-developer/page-objects

Version:

Page Object API implementation for a VS Code editor used by ExTester framework.

219 lines (218 loc) 7.13 kB
/** * 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 { Editor } from './Editor'; import { ContextMenu } from '../menu/ContextMenu'; import { WebElement, By } from 'selenium-webdriver'; import { AbstractElement } from '../AbstractElement'; import { EditorView, EditorGroup } from '../..'; /** * Page object representing the internal VS Code settings editor */ export declare class SettingsEditor extends Editor { private divider; constructor(view?: EditorView | EditorGroup); /** * Search for a setting with a particular title and category. * Returns an appropriate Setting object if the label is found, * undefined otherwise. * * If your setting has nested categories (i.e `example.general.test`), * pass in each category as a separate string. * * @param title title of the setting * @param categories category of the setting * @returns Promise resolving to a Setting object if found, undefined otherwise */ findSetting(title: string, ...categories: string[]): Promise<Setting>; /** * Search for a setting with a precise ID. * Returns an appropriate Setting object if it exists, * undefined otherwise. * * @param id of the setting * @returns Promise resolving to a Setting object if found, undefined otherwise */ findSettingByID(id: string): Promise<Setting>; private _getSettingItem; /** * Switch between settings perspectives * Works only if your vscode instance has both user and workspace settings available * * @param perspective User or Workspace * @returns Promise that resolves when the appropriate button is clicked */ switchToPerspective(perspective: 'User' | 'Workspace'): Promise<void>; /** * Context menu is disabled in this editor, throw an error */ openContextMenu(): Promise<ContextMenu>; private createSetting; } /** * Abstract item representing a Setting with title, description and * an input element (combo/textbox/checkbox/link/array) */ export declare abstract class Setting extends AbstractElement { constructor(settingsConstructor: By, settings: SettingsEditor); /** * Get the value of the setting based on its input type * * @returns promise that resolves to the current value of the setting */ abstract getValue(): Promise<string | boolean>; /** * Set the value of the setting based on its input type * * @param value boolean for checkboxes, string otherwise */ abstract setValue(value: string | boolean): Promise<void>; /** * Get the category of the setting * All settings are labeled as Category: Title */ getCategory(): Promise<string>; /** * Get description of the setting * @returns Promise resolving to setting description */ getDescription(): Promise<string>; /** * Get title of the setting */ getTitle(): Promise<string>; } /** * Setting with a combo box */ export declare class ComboSetting extends Setting { getValue(): Promise<string>; setValue(value: string): Promise<void>; /** * Get the labels of all options from the combo * @returns Promise resolving to array of string values */ getValues(): Promise<string[]>; private getOptions; } /** * Setting with a text box input */ export declare class TextSetting extends Setting { getValue(): Promise<string>; setValue(value: string): Promise<void>; } /** * Setting with a checkbox */ export declare class CheckboxSetting extends Setting { getValue(): Promise<boolean>; setValue(value: boolean): Promise<void>; } /** * Setting with no value, with a link to settings.json instead */ export declare class LinkSetting extends Setting { getValue(): Promise<string>; setValue(value: string | boolean): Promise<void>; /** * Open the link that leads to the value in settings.json * @returns Promise resolving when the link has been clicked */ openLink(): Promise<void>; } /** * Setting with an array of string values (rows) */ export declare class ArraySetting extends Setting { /** * @deprecated Method 'getValue' is not available for ArraySetting! */ getValue(): Promise<string | boolean>; /** * @deprecated Method 'setValue' is not available for ArraySetting! */ setValue(value: string | boolean): Promise<void>; /** * Select a row of a setting array of string values * @param item label | index */ select(item: string | number): Promise<void>; /** * Get a row as new ArraySettingItem object * @param item label or index * @returns ArraySettingItem | undefined */ getItem(item: string | number): Promise<ArraySettingItem | undefined>; /** * Get a list of all rows as ArraySettingItem objects * @returns ArraySettingItem[] */ getItems(): Promise<ArraySettingItem[]>; /** * Get a list of all rows values * @returns string[] */ getValues(): Promise<string[]>; /** * Click 'Add Item' and get row as ArraySettingItem in edit mode * @returns ArraySettingItem */ add(): Promise<ArraySettingItem>; /** * Select a row, then click 'Edit Item' and get row as ArraySettingItem in edit mode * @param item label | index * @returns ArraySettingItem | undefined */ edit(item: string | number): Promise<ArraySettingItem | undefined>; private getListRootElement; private getRows; private findRow; } /** * Represents each row of an ArraySetting array of strings */ export declare class ArraySettingItem extends AbstractElement { constructor(element: WebElement, setting: ArraySetting); /** * Select an item */ select(): Promise<void>; /** * Get item text value * @returns string */ getValue(): Promise<string>; /** * Set item text value * @param value string */ setValue(value: string): Promise<void>; /** * Click 'Remove Item' button */ remove(): Promise<void>; /** * Click 'OK' button * @description Only when the item is in edit mode */ ok(): Promise<void>; /** * Click 'Cancel' button * @description Only when the item is in edit mode */ cancel(): Promise<void>; }