tm-playwright-framework
Version:
Playwright Cucumber TS framework - The easiest way to learn
86 lines (85 loc) • 4.75 kB
TypeScript
/**
* DROPDOWN.TS
*
* This TypeScript file contains methods to perform actions related to the Drop Down element.
*
* @author Govindharam, Sasitharan
* @reviewer Sahoo, AshokKumar
* @version 1.0 - 1st-JUNE-2025
*
* @methods
* - `selectByValue`: Accepts an element locator as a `string` or Element and selects the option based on the given text.
* - `selectByLabel`: Accepts an element locator as a `string` or Element and selects the option based on the given label.
* - `selectByIndex`: Accepts an element locator as a `string` or Element and selects the option based on the given index.
* - `clickToExpandAndSelectOption`: Accepts an element locator as a `string`, clicks to expand the drop-down first, and then selects the option based on the given text.
* - `typeToFilterAndSelectOption`: Accepts an element locator as a `string`, types the given text, and selects the option based on the given text.
* - `pressKeyAndSelectOption`: Accepts an element locator as a `string`, presses the first character, and selects the option based on the given text.
* - `selectMultiple` : Accepts element locator as String or Element and selects the given options. Applicable only for <select> element.
*/
export default class DropdownActions {
constructor();
/**
* Selects an option in a dropdown by its value.
* @param locator - The locator of the dropdown element.
* @param value - The value of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
selectByValue(locator: string, value: string, timeOut?: number): Promise<void>;
/**
* Selects an option in a dropdown by its label.
* @param locator - The locator of the dropdown element.
* @param label - The label of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
selectByLabel(locator: string, label: string, timeOut?: number): Promise<void>;
/**
* Selects an option in a dropdown by its index.
* @param locator - The locator of the dropdown element.
* @param index - The index of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
selectByIndex(locator: string, index: Number, timeOut?: number): Promise<void>;
/**
* Expands a dropdown and selects an option by its text.
* @param dropdownValues - An object containing locators for the dropdown expand button and options.
* @drp_Expand - The locator for the dropdown expand button.
* @drp_Options - The locator for the dropdown options.
* @param option - The text of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
clickToExpandAndSelectOption(dropdownValues: {
drp_Expand: string;
drp_Options: string;
}, option: string, timeOut?: number): Promise<void>;
/**
* Filters a dropdown by typing text and selects an option by its text.
* @param dropdownValues - An object containing locators for the dropdown filter input and options.
* @drp_Filter - The locator for the dropdown filter input.
* @drp_Options - The locator for the dropdown options.
* @param option - The text of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
typeToFilterAndSelectOption(dropdownValues: {
drp_Filter: string;
drp_Options: string;
}, option: string, timeOut?: number): Promise<void>;
/**
* Presses a key to filter a dropdown and selects an option by its text.
* @param dropdownValues - An object containing locators for the dropdown filter input and options.
* @drp_Filter - The locator for the dropdown filter input.
* @drp_Options - The locator for the dropdown options.
* @param option - The text of the option to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
pressKeyAndSelectOption(dropdownValues: {
drp_Filter: string;
drp_Options: string;
}, option: string, timeOut?: number): Promise<void>;
/**
* Accepts element locator as String or Element and selects the given options. Applicable only for <Select> tag
* @param locator - An object containing locators for the dropdown.
* @param options - The array list of the options to select.
* @param timeOut - (Optional) The timeout for the operation in milliseconds (default: 30000).
*/
selectMultiple(locator: any, options: string[], timeOut?: number): Promise<void>;
}