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()import { oi } from "@ordino.ai/spartify-engine";
await oi.ui(this.page).dropdown(this.ddl_element).click()Methods
openDropdown(): void Opens the dropdown.
@returns
void
oi.ui.dropdown(this.element).openDropdown()await oi.ui(this.page).dropdown(this.element).openDropdown()closeDropdown(): void Closes the dropdown..
@returns
void
oi.ui.dropdown(this.element).closeDropdown()await oi.ui(this.page).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)await oi.ui(this.page).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)await oi.ui(this.page).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)await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).dropdown(this.element).filterByValue('text')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')await oi.ui(this.page).dropdown(this.element).filterByPartialText('test')clearSelection(): void Clears the current selection in the dropdown.
@returns
void
oi.ui.dropdown(this.element).clearSelection()await oi.ui(this.page).dropdown(this.element).clearSelection()selectRandomOption(): void Selects a random option from the dropdown.
@returns
void
oi.ui.dropdown(this.element).selectRandomOption()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)await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).dropdown(this.element).assertNotContainsOption('text')assertIsDisabled(): void Asserts that the dropdown is disabled.
@returns
void
oi.ui.dropdown(this.element).assertIsDisabled()await oi.ui(this.page).dropdown(this.element).assertIsDisabled()assertIsEnabled(): void Asserts that the dropdown is enabled.
@returns
void
oi.ui.dropdown(this.element).assertIsEnabled()await oi.ui(this.page).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)await oi.ui(this.page).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)await oi.ui(this.page).dropdown(this.element).assertSelectedByIndex(1)assertIsVisible(): void Asserts that the dropdown is visible.
@returns
void
oi.ui.dropdown(this.element).assertIsVisible()await oi.ui(this.page).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')await oi.ui(this.page).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')await oi.ui(this.page).dropdown(this.element).scrollToOption('text')Custom Events
Ordino allows you to build custom actions or user journeys by directly interacting with the underlying tool’s native methods and actions.
This approach gives you full control, bypassing Ordino’s abstraction layer, and ensures you can leverage tool-specific capabilities as needed.
locator→ The element locator (e.g., XPath, CSS selector, or tool-specific reference).Returns → A tool element object on which you can invoke native actions (e.g.,
.click(),.type()).
// Generic pattern
element(locator): objectOrdino Custom Mode
Using Ordino’s direct tool method reference:
// Ordino direct-to-tool approach
oi.ui.element('@xpath').click()Here, Ordino will call the Cypress (or other tool) element object directly, rather than going through Ordino’s wrapper.
Building User Journeys
By chaining multiple oi.ui.element() calls, you can construct full user journeys while still working with native tool methods.
Example: Login Flow
// Enter username
oi.ui.element('//input[@id="username"]').type('testuser')
// Enter password
oi.ui.element('//input[@id="password"]').type('secret')
// Click login button
oi.ui.element('(//*[contains(text(),"Login")])[1]').click()Key Notes
Use this mode when you need maximum control over the test framework.
This does not abstract or transform the call – it executes directly on the tool object (e.g., Cypress, Playwright, etc.).
Perfect for custom journeys, advanced locators, or tool-specific actions not exposed by Ordino’s higher-level API.
Last updated