DropDown
The Dropdown class simplifies dropdown interactions in Spartify tests, offering selecting, assertion, and scrolling functionalities. These methods improve test maintainability and execution efficiency, ensuring a robust test framework
Class : DropDown
The DropDown class is designed to interact with the drop-down element
import { SpartiUI } from "@spartify.io/spartify-engine";";
SpartiUI.dropdown(this.ddl_element).click();
Methods & Usage
DropDown Actions
openDropdown(): void
Opens the dropdown.
@return void
SpartiUI.dropdown(this.ddl_element).openDropdown();
closeDropdown(): void
Closes the dropdown.
@return void
SpartiUI.dropdown(this.ddl_element).closeDropdown();
selectByIndex(index: number, forceSelect:boolean): void
Selects an option by its index.
@param index - the index of the option to select.
@param forceSelect - { force: true } optional
@return void
SpartiUI.dropdown(this.ddl_element).selectByIndex(2, { force: true });
selectByText(text: string, forceSelect:boolean): void
Selects an option by its text.
@param index - the index of the option to select.
@param forceSelect - { force: true } optional
@return void
SpartiUI.dropdown(this.ddl_element).selectByText(2, { force: true });
selectByValue(value: string , forceSelect:boolean): void
Selects an option by its value.
@param value - the value of the option to select.
@param forceSelect - { force: true } optional
@return void
SpartiUI.dropdown(this.ddl_element).selectByValue(‘100’, { force: true });
filterByText(text: string , forceSelect:boolean): void
Filters options by text.
@param text - the text to filter options by.
@param forceSelect - { force: true } optional
@return void
SpartiUI.dropdown(this.ddl_element).filterByText(‘apple’, { force: true });
filterByValue(value: string): void
Filters options by value.
@param text - the value to filter options by
@return void
SpartiUI.dropdown(this.ddl_element).filterByValue(‘apple’);
filterByPartialText(partialText: string): void
Filters options by partial text.
@param text - the partial text to filter options by.
@return void
SpartiUI.dropdown(this.ddl_element).filterByPartialText(‘app’);
getAllOptions(): void
Retrieves all options from the dropdown.
@param text - the partial text to filter options by.
@return void
SpartiUI.dropdown(this.ddl_element).getAllOptions();
clearSelection(): void
Clears the current selection in the dropdown.
@return void
SpartiUI.dropdown(this.ddl_element).clearSelection();
selectRandomOption(): void
Selects a random option from the dropdown.
@return void
SpartiUI.dropdown(this.ddl_element).selectRandomOption();
clickOptionByText(text: string, forceSelect:boolean): void
Clicks an option by its text.
@return void
SpartiUI.dropdown(this.ddl_element).clickOptionByText(‘apple’, { force: true });
Assertions
assertSelectedText(text: string): void
Clicks an option by its text.
@param text - the text to assert against the selected option’s text
@return void
SpartiUI.dropdown(this.ddl_element).assertSelectedText(‘apple’});
assertSelectedValue(value: string): void
The value to assert against the selected option’s value.
@param value - the value to assert against the selected option’s value
@return void
SpartiUI.dropdown(this.ddl_element).assertSelectedValue(‘apple’});
assertContainsOption(value: string): void
Asserts that the dropdown contains an option with the given value.
@param value - the value of the option to check for.
@return void
SpartiUI.dropdown(this.ddl_element).assertContainsOption(‘app’});
assertNotContainsOption(value: string): void
Asserts that the dropdown does not contain an option with the given value.
@param value - The value of the option to check for.
@return void
SpartiUI.dropdown(this.ddl_element).assertNotContainsOption(‘app’});
assertIsDisabled(): void
Asserts that the dropdown is disabled.
@return void
SpartiUI.dropdown(this.ddl_element).assertIsDisabled();
assertIsEnabled(): void
Asserts that the dropdown is enabled.
@return void
SpartiUI.dropdown(this.ddl_element).assertIsEnabled();
assertOptionCount(count: number): void
Asserts that the number of options in the dropdown matches the given count
@param count - The expected number of options.
@return void
SpartiUI.dropdown(this.ddl_element).assertOptionCount(3);
assertSelectedByIndex(index: number): void
Asserts that the selected option’s index matches the given index.
@param index - the index to assert against the selected option’s index.
@return void
SpartiUI.dropdown(this.ddl_element).assertSelectedByIndex(3);
assertIsVisible(): void
Asserts that the dropdown is visible.
@return void
SpartiUI.dropdown(this.ddl_element).assertIsVisible();
assertPlaceholder(text: string): void
Asserts that the placeholder text matches the given text.
@return void
SpartiUI.dropdown(this.ddl_element).assertPlaceholder(‘enter name’);
Scrolling
scrollToOption(value: string): void;
Scrolls to an option with the given value.
@param value - the value of the option to scroll to.
@return void
SpartiUI.dropdown(this.ddl_element).scrollToOption(‘apple’);