Button

The Button class provides a simplified interface for handling button interactions in test automation. It supports essential operations such as clicking, asserting button states, and scrolling events.

Usage : button

🧩 Code

The Button class is designed to interact with common button element

To insert a code block with syntax highlighting:

import { oi } from "@ordino.ai/spartify-engine";

oi.ui.button(this.btn_element).click()

Methods

click(): void

Simulates a click action on the button

  • @returns void

oi.ui.button(this.btn_element).click()

forceClick(): void

Forces a click action on the button, bypassing any potential blockers.

  • @returns void

oi.ui.button(this.btn_element).forceClick()

doubleClick(): void

Simulates a double-click action on the button. @param forceClick - true (optional)

  • @param {force} – true (optional)

  • @returns void

oi.ui.button(this.btn_element).doubleClick(true)

rightClick(): void

Simulates a right-click action on the button.

  • @returns void

oi.ui.button(this.btn_element).rightClick(true)

clickAt(x: number, y: number): void

Simulates a click action at the specified coordinates relative to the button.

  • @param x – The x-coordinate.

  • @param y – The y-coordinate.

  • @returns void

oi.ui.button(this.btn_element).clickAt(50,30,true)

clickCenter(): void

Simulates a click action at the center of the button.

  • @returns void

oi.ui.button(this.btn_element).clickCenter(true)

clickAll(): void

Simulates a click action on all instances of the button.

  • @returns void

oi.ui.button(this.btn_element).clickAll(true)

clickFirst(): void

Simulates a click action on the first instance of the button.

  • @returns void

oi.ui.button(this.btn_element).clickFirst(true)

clickLast(): void

Simulates a click action on the last instance of the button

  • @returns void

oi.ui.button(this.btn_element).clickLast(true)

clickAndHold(): void

Simulates a click-and-hold action on the button.

  • @returns void

oi.ui.button(this.btn_element).clickAndHold()

clickByText(text: string): void

Simulates a click action on the button identified by the specified text.

  • @param text – The text to identify the button.

  • @returns void

oi.ui.button(this.btn_element).clickByText('save',true)

clickByIndex(index: number): void

Simulates a click action on the button identified by the specified index.

  • @param index – The index to identify the button.

  • @returns void

oi.ui.button(this.btn_element).clickByIndex(2,true)

clickWithOffset(x: number, y: number): void

Simulates a click action on the button with an offset from its top-left corner.

  • @param x – The x-coordinate offset.

  • @param y – The y-coordinate offset.

  • @returns void

oi.ui.button(this.btn_element).clickWithOffset(1,2)

focusAndClick(): void

Focuses on the button and then simulates a click action

  • @returns void

oi.ui.button(this.btn_element).focusAndClick()

Assertions

assertText(text: string): void

Asserts that the button contains the specified text.

  • @param text – The expected text content of the button.

  • @returns void

oi.ui.button(this.btn_element).assertText('')

assertColor(color: string): void

Asserts that the button has the expected color.

  • @param color – The expected color of the button.

  • @returns void

oi.ui.button(this.btn_element).assertColor('rgb(0, 123, 255)')

assertCssProperty(property: string, value: string): void

Asserts that the button has the specified CSS property with the given value.

  • @param property – The CSS property to check.

  • @param value – The expected value of the CSS property.

  • @returns void

oi.ui.button(this.btn_element).assertCssProperty('font-size', '16px')

Scrolling Actions

scrollToElement(): void

Scrolls to the button element.

  • @returns void

oi.ui.button(this.btn_element).scrollToElement()

Last updated