TextBox
The TextBox class provides a streamlined interface for interacting with text input fields. It includes methods for typing, asserting values, and scrolling elements into view. These capabilities improv
Usage : textbox
textbox🧩 Code
The Textbox class is designed to interact with common textbox element
To insert a code block with syntax highlighting:
import { oi } from "@ordino.ai/spartify-engine";
oi.ui.textbox(this.txt_element).enterText(text)import { oi } from "@ordino.ai/spartify-engine";
await oi.ui(this.page).textbox(this.txt_element).enterText(text)Methods
enterText(text: string): void
Enters the specified text into the textbox.
@returns
void
oi.ui.textbox(this.txt_element).enterText(text)await oi.ui(this.page).textbox(this.element).enterText(text)clickAndType(text: string, forceClick:boolean): void
Clicks on the textbox and types the given text.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).clickAndType(text)await oi.ui(this.page).textbox(this.element).clickAndType(text)clearText(): void
Clears the text from the textbox.
@returns
void
oi.ui.textbox(this.txt_element).clearText()await oi.ui(this.page).textbox(this.element).clearText()typeInAll(text: string): void
Types the specified text in all instances of the textbox.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).typeInAll(text)await oi.ui(this.page).textbox(this.element).typeInAll(text)clickAndTypeFirst(text: string, forceClick:boolean): void
Clicks on the first instance of the textbox and types the given text.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).clickAndTypeFirst(text)await oi.ui(this.page).textbox(this.element).clickAndTypeFirst(text)clickAndTypeLast(text: string, forceClick:boolean): void
Clicks on the last instance of the textbox and types the given text.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).clickAndTypeLast(text)await oi.ui(this.page).textbox(this.element).clickAndTypeLast(text)typeAndPressEnter(text: string): void
Types the specified text and presses Enter.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).typeAndPressEnter(text)await oi.ui(this.page).textbox(this.element).typeAndPressEnter(text)typeSlowly(text: string): void
Types the specified text slowly.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).typeSlowly(text)await oi.ui(this.page).textbox(this.element).typeSlowly(text)appendText(text: string): void
Appends the specified text to the existing text in the textbox.
@param
text– The text to append.@returns
void
oi.ui.textbox(this.txt_element).appendText(text)await oi.ui(this.page).textbox(this.element).appendText(text)clearAndType(text: string): void
Clears the existing text and types the specified text.
@param
text– The text to type.@returns
void
oi.ui.textbox(this.txt_element).clearAndType(text)await oi.ui(this.page).textbox(this.element).clearAndType(text)Assertions
assertPlaceholder(text: string): void
Asserts that the placeholder text of the textbox matches the specified text.
@param
text– The expected placeholder text.@returns
void
oi.ui.textbox(this.txt_element).assertPlaceholder(text)await oi.ui(this.page).textbox(this.element).assertPlaceholder(text)assertMaxLength(length: number): void
Asserts that the maximum length of the textbox is equal to the specified length.
@param
length– The expected maximum length.@returns
void
oi.ui.textbox(this.txt_element).assertMaxLength(length)await oi.ui(this.page).textbox(this.element).assertMaxLength(length)assertIsEmpty(): void
Asserts that the textbox is empty.
@returns
void
oi.ui.textbox(this.txt_element).assertIsEmpty()await oi.ui(this.page).textbox(this.element).assertIsEmpty()assertIsNotEmpty(): void
Asserts that the textbox is not empty.
@returns
void
oi.ui.textbox(this.txt_element).assertIsNotEmpty()await oi.ui(this.page).textbox(this.element).assertIsNotEmpty()assertTextAlignment(alignment: string): void
Asserts that the text alignment of the textbox matches the specified alignment.
@param
alignment– The expected text alignment.@returns
void
oi.ui.textbox(this.txt_element).assertTextAlignment(alignment)await oi.ui(this.page).textbox(this.element).assertTextAlignment(alignment)assertCssProperty(property: string, value: string): void
Asserts that the specified CSS property of the textbox matches the expected value.
@param
property– The CSS property to check.@returns
void
oi.ui.textbox(this.txt_element).assertCssProperty(property, value)await oi.ui(this.page).textbox(this.element).assertCssProperty(property, value)Scrolling Actions
scrollToElement(): void
Scrolls to the textbox element.
@returns
void
oi.ui.textbox(this.btn_element).scrollToElement()await oi.ui(this.page).textbox(this.element).scrollToElement()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