DropDown
The DropDown class provides a clean interface for interacting with generic container elements such as <select> blocks. It includes methods for selection, assertions, and scrolling into view.
Usage : dropdown
dropdown
🧩 Code
The Dropdown class is designed to interact with common drop-down element
To insert a code block with syntax highlighting:
import { oi } from "@ordino.ai/spartify-engine";
oi.ui.dropdown(this.ddl_element).click()
Methods
openDropdown(): void Opens the dropdown.
@returns
void
oi.ui.dropdown(this.element).openDropdown()
closeDropdown(): void Closes the dropdown..
@returns
void
oi.ui.dropdown(this.element).closeDropdown()
selectByIndex(index: number, forceSelect:boolean): void Selects an option by its index.
@param
{index}
– The index of the option to select.@param
{force}
– true (optional)@returns
void
oi.ui.dropdown(this.element).selectByIndex(1,true)
selectByText(text: string, forceSelect:boolean): void Selects an option by its text.
@param
{index}
– The index of the option to select.@param
{force}
– true (optional)@returns
void
oi.ui.dropdown(this.element).selectByText('text',true)
selectByValue(value: string , forceSelect:boolean): void Selects an option by its value.
@param
{value}
– The value of the option to select.@param
{force}
– true (optional)@returns
void
oi.ui.dropdown(this.element).selectByValue('text',true)
filterByText(text: string , forceSelect:boolean): void Filters options by text.
@param
{text}
– The text to filter options by.@param
{force}
– true (optional)@returns
void
oi.ui.dropdown(this.element).filterByText('text')
filterByValue(value: string): void Filters options by value.
@param
{value}
– The value to filter options by@returns
void
oi.ui.dropdown(this.element).filterByValue('test')
filterByPartialText(partialText: string): void Filters options by partial text.
@param
{text}
– The partial text to filter options by.@returns
void
oi.ui.dropdown(this.element).filterByPartialText('test')
clearSelection(): void Clears the current selection in the dropdown.
@returns
void
oi.ui.dropdown(this.element).clearSelection()
selectRandomOption(): void Selects a random option from the dropdown.
@returns
void
oi.ui.dropdown(this.element).selectRandomOption()
clickOptionByText(text: string, forceSelect:boolean): void Clicks an option by its text.
@param
{text}
– The text to filter options by.@param
{force}
– true (optional)@returns
void
oi.ui.dropdown(this.element).clickOptionByText('text',true)
Assertions
assertSelectedText(text: string): void Clicks an option by its text.
@param
{text}
– The partial text to filter options by.@returns
void
oi.ui.dropdown(this.element).assertSelectedText('text')
assertSelectedValue(value: string): void The value to assert against the selected option’s value.
@param
{value}
– The value to filter options by.@returns
void
oi.ui.dropdown(this.element).assertSelectedValue('text')
assertContainsOption(value: string): void Asserts that the dropdown contains an option with the given value.
@param
{option}
– The value of the option to check for@returns
void
oi.ui.dropdown(this.element).assertContainsOption('text')
assertNotContainsOption(value: string): void Asserts that the dropdown does not contain an option with the given value.
@param
{text}
– The partial text to filter options by.@returns
void
oi.ui.dropdown(this.element).filterByPartialText('test')
assertNotContainsOption(value: string): void Asserts that the dropdown does not contain an option with the given value.
@param
{text}
– The value of the option to check for.@returns
void
oi.ui.dropdown(this.element).assertNotContainsOption('text')
assertIsDisabled(): void Asserts that the dropdown is disabled.
@returns
void
oi.ui.dropdown(this.element).assertIsDisabled()
assertIsEnabled(): void Asserts that the dropdown is enabled.
@returns
void
oi.ui.dropdown(this.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.@returns
void
oi.ui.dropdown(this.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.@returns
void
oi.ui.dropdown(this.element).assertSelectedByIndex(1)
assertIsVisible(): void Asserts that the dropdown is visible.
@returns
void
oi.ui.dropdown(this.element).assertIsVisible()
assertPlaceholder(text: string): void Asserts that the placeholder text matches the given text.
@param
{text}
– The placeholder to assert@returns
void
oi.ui.dropdown(this.element).assertPlaceholder('text')
Scrolling
scrollToOption(value: string): void; Scrolls to an option with the given value.
@param
{value}
– The value of the option to scroll to.@returns
void
oi.ui.dropdown(this.element).scrollToOption('text')
Last updated