@redhat-developer/page-objects
Version:
Page Object API implementation for a VS Code editor used by ExTester framework.
126 lines (125 loc) • 5.45 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 { WebElement } from 'selenium-webdriver';
import { ContextMenu, ViewContent, ViewItem, WelcomeContentSection } from '../..';
import { AbstractElement } from '../AbstractElement';
import { ActionButtonElementDropdown } from '../ActionButtonElementDropdown';
export type ViewSectionConstructor<T extends ViewSection> = {
new (rootElement: WebElement, tree: ViewContent): T;
};
/**
* Page object representing a collapsible content section of the side bar view
*/
export declare abstract class ViewSection extends AbstractElement {
constructor(panel: WebElement, content: ViewContent);
/**
* Get the title of the section as string
* @returns Promise resolving to section title
*/
getTitle(): Promise<string>;
/**
* Expand the section if collapsed
* @returns Promise resolving when the section is expanded
*/
expand(timeout?: number): Promise<void>;
/**
* Collapse the section if expanded
* @returns Promise resolving when the section is collapsed
*/
collapse(timeout?: number): Promise<void>;
/**
* Finds whether the section is expanded
* @returns Promise resolving to true/false
*/
isExpanded(): Promise<boolean>;
/**
* Finds [Welcome Content](https://code.visualstudio.com/api/extension-guides/tree-view#welcome-content)
* present in this ViewSection and returns it. If none is found, then `undefined` is returned
*
*/
findWelcomeContent(): Promise<WelcomeContentSection | undefined>;
/**
* Retrieve all items currently visible in the view section.
* Note that any item currently beyond the visible list, i.e. not scrolled to, will not be retrieved.
* @returns Promise resolving to array of ViewItem objects
*/
abstract getVisibleItems(): Promise<ViewItem[]>;
/**
* Find an item in this view section by label. Does not perform recursive search through the whole tree.
* Does however scroll through all the expanded content. Will find items beyond the current scroll range.
* @param label Label of the item to search for.
* @param maxLevel Limit how deep the algorithm should look into any expanded items, default unlimited (0)
* @returns Promise resolving to ViewItem object is such item exists, undefined otherwise
*/
abstract findItem(label: string, maxLevel?: number): Promise<ViewItem | undefined>;
/**
* Open an item with a given path represented by a sequence of labels
*
* e.g to open 'file' inside 'folder', call
* openItem('folder', 'file')
*
* The first item is only searched for directly within the root element (depth 1).
* The label sequence is handled in order. If a leaf item (a file for example) is found in the middle
* of the sequence, the rest is ignored.
*
* If the item structure is flat, use the item's title to search by.
*
* @param path Sequence of labels that make up the path to a given item.
* @returns Promise resolving to array of ViewItem objects representing the last item's children.
* If the last item is a leaf, empty array is returned.
*/
abstract openItem(...path: string[]): Promise<ViewItem[]>;
/**
* Retrieve the action buttons on the section's header
* @returns Promise resolving to array of ViewPanelAction objects
*/
getActions(): Promise<ViewPanelAction[]>;
/**
* Retrieve an action button on the sections's header by its label
* @param label label/title of the button
* @returns ViewPanelAction object if found, undefined otherwise
*/
getAction(label: string): Promise<ViewPanelAction | undefined>;
/**
* Click on the More Actions... item if it exists
*
* @returns ContextMenu page object if the action succeeds, undefined otherwise
*/
moreActions(): Promise<ContextMenu | undefined>;
private isHeaderHidden;
}
/**
* Base class for action buttons on view sections.
* Provides shared functionality for both standard and dropdown actions.
*/
declare abstract class BaseViewPanelAction extends ActionButtonElementDropdown {
constructor(element: WebElement, viewPart: ViewSection);
/**
* Get label of the action button
*/
getLabel(): Promise<string>;
/**
* Wait for the action button to be located within a given timeout.
* @param timeout Time in milliseconds (default: 1000ms)
*/
wait(timeout?: number): Promise<this>;
}
export declare class ViewPanelAction extends BaseViewPanelAction {
}
export declare class ViewPanelActionDropdown extends BaseViewPanelAction {
}
export {};