TextBox
The Textbox class simplifies taxtbox interactions in Spartify tests, offering typing, assertion, and scrolling functionalities. These methods improve test maintainability and execution efficiency, ensuring a robust test framework.
Class : Textbox
The Textbox class is designed to interact with the link element
import { SpartiUI } from "@spartify.io/spartify-engine";
SpartiUI.link(this.lnk_element).click():
Methods & Usage
Navigation Methods
enterText(text: string): void Enters the specified text into the textbox.
@param text - the text to enter.
@return void
SpartiUI.textbox(this.txt_element).enterText(‘hello’);
clickAndType(text: string,forceClick:boolean): void Clicks on the textbox and types the specified text.
@param text - the text to type.
@return void
SpartiUI.textbox(this.txt_element).clickAndType(‘hello’, {force:true});
clearText(): void Clears the text from the textbox.
@return void
SpartiUI.textbox(this.txt_element).clearText();
typeInAll(text: string): void Types the specified text in all instances of the textbox.
@param text - the text to type.
@return void
SpartiUI.textbox(this.txt_element).typeInAll(‘hello’);
clickAndTypeFirst(text: string,forceClick:boolean): void Clicks on the first instance of the textbox and types the specified text.
@param text - The text to type.
@return void
SpartiUI.textbox(this.txt_element).clickAndTypeFirst(‘hello’, {force : true});
clickAndTypeLast(text: string,forceClick:boolean): void Clicks on the last instance of the textbox and types the specified text.
@param text - The text to type.
@return void
SpartiUI.textbox(this.txt_element).clickAndTypeLast(‘hello’, {force : true});
typeAndPressEnter(text: string): void Types the specified text and presses Enter.
@param text - The text to type.
@return void
SpartiUI.textbox(this.txt_element).typeAndPressEnter(‘hello’);
typeSlowly(text: string): void Types the specified text slowly.
@param text - The text to type.
@return void
SpartiUI.textbox(this.txt_element).typeSlowly(‘hello’);
appendText(text: string): void Appends the specified text to the existing text in the textbox.
@param text - the text to append.
@return void
SpartiUI.textbox(this.txt_element).appendText(‘hello’);
clearAndType(text: string): void Clears the existing text and types the specified text.
@param text - The text to type.
@return void
SpartiUI.textbox(this.txt_element).clearAndType(‘hello’);
Assertions
assertPlaceholder(text: string): void Asserts that the placeholder text of the textbox matches the specified text.
@param text - The expected placeholder text.
@return void
SpartiUI.textbox(this.txt_element).assertPlaceholder(‘hello’);
assertMaxLength(length: number): void Asserts that the maximum length of the textbox is equal to the specified length.
@param text - The expected maximum length.
@return void
SpartiUI.textbox(this.txt_element).assertMaxLength(23);
assertIsEmpty(): void Asserts that the textbox is empty.
@return void
SpartiUI.textbox(this.txt_element).assertIsEmpty();
assertIsNotEmpty(): void Asserts that the textbox is not empty.
@return void
SpartiUI.textbox(this.txt_element).assertIsNotEmpty();
assertTextAlignment(alignment: string): void Asserts that the text alignment of the textbox matches the specified alignment.
@param alignment - The expected text alignment.
@return void
SpartiUI.textbox(this.txt_element).assertTextAlignment(‘left’);
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.
@param value - The expected value of the CSS property.
@return void
SpartiUI.textbox(this.txt_element).assertCssProperty(‘align’,‘left’);