CheckBox
The Checkbox class simplifies checkbox interactions in Spartify tests, offering checking, assertion, and scrolling functionalities. These methods improve test maintainability and execution efficiency, ensuring a robust test framework.
The CheckBox class is designed to interact with the checkbox element.
import { spartiUI } from "@spartify.io/spartify-engine";SpartiUI.checkbox(this.chkBox_element).check();
Methods & Usage
Check Actions
check(): void
Checks the checkbox.
@return void
spartiUI.checkbox(this.btn_element).check();
uncheck(): void
Unchecks the checkbox.
@return void
spartiUI.checkbox(this.btn_element).uncheck();
toggleCheck(): void
Toggles the checkbox state.
@return void
spartiUI.checkbox(this.btn_element).toggleCheck();
checkAll(): void
Checks all checkboxes.
@return void
spartiUI.checkAll(this.btn_elements).checkAll();
uncheckAll(): void
Unchecks all checkboxes.
@return void
spartiUI.checkbox(this.btn_elements).uncheckAll();
checkByIndex(index: number): void
Checks the checkbox at the specified index.
@param index - the index of the checkbox to check.
@return void
spartiUI.checkbox(this.btn_elements).checkByIndex(2);
uncheckByIndex(index: number): void
Unchecks the checkbox at the specified index.
@param index - the index of the checkbox to uncheck.
@return void
spartiUI.checkbox(this.btn_elements).uncheckByIndex(2);
checkByText(text: string): void
Checks the checkbox with the specified text.
@param text - The text of the checkbox to check.
@return void
spartiUI.checkbox(this.btn_elements).checkByText(“false”);
uncheckByText(text: string): void
Unchecks the checkbox with the specified text.
@param text - the text of the checkbox to uncheck.
@return void
spartiUI.checkbox(this.btn_elements).uncheckByText(“true”);
clickWithOffset(x: number, y: number,forceClick:boolean): void;
Clicks the checkbox with an offset.
@param x - The x offset.
@param y - The y offset.
@return void
SpartiUI.checkbox(this.chkBox_element).clickWithOffset(34, 23);
Assertions
isChecked(): void
Asserts that the checkbox is checked.
@return void
spartiUI.checkbox(this.input_element).isChecked();
isNotChecked(): void
Asserts that the checkbox is not checked.
@return void
spartiUI.checkbox(this.input_element).isNotChecked();
assertIsIndeterminate(): void
Asserts that the checkbox is in an indeterminate state.
@return void
SpartiUI.checkbox(this.chkBox_element).assertIsIndeterminate();
assertCheckedCount(count: number): void
Asserts that the number of checked checkboxes matches the specified count.
@param count - the expected number of checked checkboxes.
@return void
spartiUI.checkbox(this.input_element).assertCheckedCount(2);
assertUncheckedCount(count: number): void
Asserts that the number of unchecked checkboxes matches the specified count.
@param count - the expected number of unchecked checkboxes.
@return void
spartiUI.checkbox(this.input_element).assertUncheckedCount(2);
assertIsDisabled(): void
Asserts that the checkbox is disabled.
@return void
spartiUI.checkbox(this.input_element).assertIsDisabled();
assertIsEnabled(): void
Asserts that the checkbox is enabled.
@return void
spartiUI.checkbox(this.input_element).assertIsEnabled();
isContained(text: string): void
Asserts that the checkbox contains the specified text.
@param text - the text to check for containment.
@return void
spartiUI.checkbox(this.input_element).isContained('Accept Terms');
isEqual(text: string): void
Asserts that the checkbox text is equal to the specified text.
@param text - the text to compare.
@return void
spartiUI.checkbox(this.input_element).isEqual();checkbox.isEqual("Accept Terms & Conditions");
isNotEqual(text: string): void
Asserts that the checkbox text is not equal to the specified text.
@param text - the text to compare.
@return void
spartiUI.checkbox(this.input_element).isNotEqual();
Scrolling
scrollToElement(): void
Scrolls to the checkbox element.
@return void
spartiUI.checkbox(this.input_element).scrollToElement();