@redhat-developer/page-objects
Version:
Page Object API implementation for a VS Code editor used by ExTester framework.
151 lines (150 loc) • 5.67 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 { AbstractElement } from '../../AbstractElement';
import { WebElement } from 'selenium-webdriver';
/**
* Abstract page object for input fields
*/
export declare abstract class Input extends AbstractElement {
/**
* Get current text of the input field
* @returns Promise resolving to text of the input field
*/
getText(): Promise<string>;
/**
* Set (by selecting all and typing) text in the input field
* @param text text to set into the input field
* @returns Promise resolving when the text is typed in
*/
setText(text: string): Promise<void>;
/**
* Get the placeholder text for the input field
* @returns Promise resolving to input placeholder
*/
getPlaceHolder(): Promise<string>;
/**
* Confirm the input field by pressing Enter
* @returns Promise resolving when the input is confirmed
*/
confirm(): Promise<void>;
/**
* Cancel the input field by pressing Escape
* @returns Promise resolving when the input is cancelled
*/
cancel(): Promise<void>;
/**
* Clear the inpur field
* @returns Promise resolving when the field is cleared
*/
clear(): Promise<void>;
/**
* Select (click) a quick pick option. Will scroll through the quick picks to find the item.
* Search for the item can be done by its text, or index in the quick pick menu.
* Note that scrolling does not affect the item's index, but it will
* replace some items in the DOM (thus they become unreachable)
*
* @param indexOrText index (number) or text (string) of the item to search by
* @returns Promise resolving when the given quick pick is selected
*/
selectQuickPick(indexOrText: string | number): Promise<void>;
/**
* Select/Deselect all quick picks using the 'select all' checkbox
* If multiple selection is disabled on the input box, no action is performed
*
* @param state true to select all, false to deselect all
* @returns Promise resolving when all quick picks have been toggled to desired state
*/
toggleAllQuickPicks(state: boolean): Promise<void>;
/**
* Scroll through the quick picks to find an item by the name or index
* @param indexOrText index (number) or text (string) of the item to search by
* @returns Promise resolvnig to QuickPickItem if found, to undefined otherwise
*/
findQuickPick(indexOrText: string | number): Promise<QuickPickItem | undefined>;
/**
* Retrieve the title of an input box if it has one
* @returns Promise resolving to title if it exists, to undefined otherwise
*/
getTitle(): Promise<string | undefined>;
/**
* Click on the back button if it exists
* @returns Promise resolving to true if a button was clicked, to false otherwise
*/
back(): Promise<boolean>;
/**
* Find whether the input box has an active progress bar
* @returns Promise resolving to true/false
*/
abstract hasProgress(): Promise<boolean>;
/**
* Retrieve the quick pick items currently available in the DOM
* (visible in the quick pick menu)
* @returns Promise resolving to array of QuickPickItem objects
*/
abstract getQuickPicks(): Promise<QuickPickItem[]>;
private resetPosition;
}
/**
* Page object representing a quick pick option in the input box
*/
export declare class QuickPickItem extends AbstractElement {
private index;
constructor(index: number, input: Input, isMultiSelect?: boolean);
/**
* Get the label of the quick pick item
*/
getLabel(): Promise<string>;
/**
* Get the description of the quick pick item
*/
getDescription(): Promise<string | undefined>;
/**
* Get the index of the quick pick item
*/
getIndex(): number;
/**
* Select (click) the quick pick item
* @returns Promise resolving when the item has been clicked
*/
select(): Promise<void>;
/**
* Checks if QuickPickItem is selected.
* @returns Promise resolving to true/false.
*/
isSelected(): Promise<boolean>;
/**
* Retrieve the actions on QuickPickItem.
* @returns Promise resolving to array of QuickInputAction objects.
*/
getActions(): Promise<QuickInputAction[]>;
/**
* Retrieve the specific action on QuickPickItem.
* @param label Name of QuickPickItem.
* @returns Promise resolving QuickInputAction if item exists or undefined.
*/
getAction(label: string): Promise<QuickInputAction | undefined>;
}
/**
* Action bound to a QuickPickItem.
*/
export declare class QuickInputAction extends AbstractElement {
constructor(element: WebElement, viewPart: QuickPickItem);
/**
* Get label of the action button.
*/
getLabel(): Promise<string>;
}