UNPKG

@redhat-developer/page-objects

Version:

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

170 lines (169 loc) 7.04 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 { WebElement } from 'selenium-webdriver'; import { AbstractElement } from '../AbstractElement'; import { ElementWithContextMenu } from '../ElementWithContextMenu'; import { Editor } from './Editor'; import { EditorAction } from './EditorAction'; export declare class EditorTabNotFound extends Error { constructor(title: string, group: number); } /** * View handling the open editors */ export declare class EditorView extends AbstractElement { constructor(); /** * Switch to an editor tab with the given title * @param title title of the tab * @param groupIndex zero based index for the editor group (0 for the left most group) * @returns Promise resolving to Editor object */ openEditor(title: string, groupIndex?: number): Promise<Editor>; /** * Close an editor tab with the given title * @param title title of the tab * @param groupIndex zero based index for the editor group (0 for the left most group) * @returns Promise resolving when the tab's close button is pressed */ closeEditor(title: string, groupIndex?: number): Promise<void>; /** * Close all open editor tabs * @param groupIndex optional index to specify an editor group * @returns Promise resolving once all tabs have had their close button pressed */ closeAllEditors(groupIndex?: number): Promise<void>; /** * Retrieve all open editor tab titles in an array * @param groupIndex optional index to specify an editor group, if left empty will search all groups * @returns Promise resolving to array of editor titles */ getOpenEditorTitles(groupIndex?: number): Promise<string[]>; /** * Retrieve an editor tab from a given group by title * @param title title of the tab * @param groupIndex zero based index of the editor group, default 0 (leftmost one) * @returns promise resolving to EditorTab object */ getTabByTitle(title: string, groupIndex?: number): Promise<EditorTab>; /** * Retrieve all open editor tabs * @param groupIndex index of group to search for tabs, if left undefined, all groups are searched * @returns promise resolving to EditorTab list */ getOpenTabs(groupIndex?: number): Promise<EditorTab[]>; /** * Retrieve the active editor tab * @returns promise resolving to EditorTab object, undefined if no tab is active */ getActiveTab(): Promise<EditorTab | undefined>; /** * Retrieve all editor groups in a list, sorted left to right * @returns promise resolving to an array of EditorGroup objects */ getEditorGroups(): Promise<EditorGroup[]>; /** * Retrieve an editor group with a given index (counting from left to right) * @param index zero based index of the editor group (leftmost group has index 0) * @returns promise resolving to an EditorGroup object */ getEditorGroup(index: number): Promise<EditorGroup>; /** * Get editor actions of a select editor group * @param groupIndex zero based index of the editor group (leftmost group has index 0), default 0 * @returns promise resolving to list of EditorAction objects */ getActions(groupIndex?: number): Promise<EditorAction[]>; /** * Get editor action of a select editor group, search by title or predicate * @param predicateOrTitle title or predicate to be used in search process * @param groupIndex zero based index of the editor group (leftmost group has index 0), default 0 * @returns promise resolving to EditorAction object if found, undefined otherwise */ getAction(predicateOrTitle: string | ((action: EditorAction) => boolean | PromiseLike<boolean>), groupIndex?: number): Promise<EditorAction | undefined>; } /** * Page object representing an editor group */ export declare class EditorGroup extends AbstractElement { private index; constructor(element: WebElement, view?: EditorView, index?: number); /** * Switch to an editor tab with the given title * @param title title of the tab * @returns Promise resolving to Editor object */ openEditor(title: string): Promise<Editor>; /** * Close an editor tab with the given title * @param title title of the tab * @returns Promise resolving when the tab's close button is pressed */ closeEditor(title: string): Promise<void>; /** * Close all open editor tabs * @returns Promise resolving once all tabs have had their close button pressed */ closeAllEditors(): Promise<void>; /** * Retrieve all open editor tab titles in an array * @returns Promise resolving to array of editor titles */ getOpenEditorTitles(): Promise<string[]>; /** * Retrieve an editor tab by title * @param title title of the tab * @returns promise resolving to EditorTab object */ getTabByTitle(title: string): Promise<EditorTab>; /** * Retrieve all open editor tabs * @returns promise resolving to EditorTab list */ getOpenTabs(): Promise<EditorTab[]>; /** * Retrieve the active editor tab * @returns promise resolving to EditorTab object, undefined if no tab is active */ getActiveTab(): Promise<EditorTab | undefined>; /** * Retrieve the editor action buttons as EditorActions * @returns promise resolving to list of EditorAction objects */ getActions(): Promise<EditorAction[]>; /** * Find an editor action button by predicate or title * @param predicateOrTitle predicate/title to be used * @returns promise resolving to EditorAction representing the button if found, undefined otherwise */ getAction(predicateOrTitle: string | ((action: EditorAction) => boolean | PromiseLike<boolean>)): Promise<EditorAction | undefined>; } /** * Page object for editor view tab */ export declare class EditorTab extends ElementWithContextMenu { constructor(element: WebElement, view: EditorView); /** * Get the tab title as string */ getTitle(): Promise<string>; /** * Select (click) the tab */ select(): Promise<void>; isSelected(): Promise<boolean>; }