@vibe/testkit
Version:
Vibe e2e testing toolkit
165 lines • 6.3 kB
TypeScript
import { Page, Locator } from "@playwright/test";
/**
* Class representing a base element for Playwright tests.
*/
export declare class BaseElement {
page: Page;
locator: Locator;
elementReportName: string;
private readonly DEFAULT_TIMEOUT;
/**
* Create a BaseElement.
* @param {Page} page - The Playwright page object.
* @param {Locator} locator - The locator for the element.
* @param {string} elementReportName - The name for reporting purposes.
*/
constructor(page: Page, locator: Locator, elementReportName: string);
/**
* Get the page object.
* @returns {Page} - The page object.
*/
getPage(): Page;
/**
* Get the locator of the element.
* @returns {Locator} - The locator of the element.
*/
getLocator(): Locator;
/**
* Get the element report name.
* @returns {string} - The element report name.
*/
getElementReportName(): string;
/**
* Hover the element.
* @returns {Promise<void>}
*/
hover(): Promise<void>;
/**
* Click the element.
* @returns {Promise<void>}
*/
click(): Promise<void>;
/**
* Get the text of the element.
* @returns {Promise<string>} - The text of the element (empty string if only whitespace or empty, throws if all are null/undefined).
*/
getText(): Promise<string>;
/**
* Scroll the element into view if needed.
* @returns {Promise<void>}
*/
scrollIntoView(): Promise<void>;
/**
* Get the value of an attribute of the element.
* @param {string} attributeName - The name of the attribute.
* @param {number} timeout - The timeout for the attribute value. Defaults to 30 seconds.
* @returns {Promise<string | null>} - The value of the attribute.
*/
getAttributeValue(attributeName: string, timeout?: number): Promise<string>;
/**
* Wait for the element to be visible.
* @param {number} timeout - The timeout for the element to be visible. Defaults to 30 seconds.
* @returns {Promise<void>}
*/
waitForElementToBeVisible(timeout?: number): Promise<void>;
/**
* Wait for the element to be hidden.
* @param {number} timeout - The timeout for the element to be hidden. Defaults to 30 seconds.
* @returns {Promise<void>}
*/
waitForElementToBeHidden(timeout?: number): Promise<void>;
/**
* Wait for the element to be absent.
* @param {number} timeout - The timeout for the element to be absent. Defaults to 30 seconds.
* @returns {Promise<void>}
*/
waitForElementToBeDetached(timeout?: number): Promise<void>;
/**
* Wait for the element to be attached.
* @param {number} timeout - The timeout for the element to be attached. Defaults to 30 seconds.
* @returns {Promise<void>}
*/
waitForElementToBeAttached(timeout?: number): Promise<void>;
/**
* Count the number of elements matching the locator.
* @returns {Promise<number>} - The number of elements matching the locator.
*/
count(): Promise<number>;
/**
* Check if the element is enabled.
* @param {number} timeout - The timeout for the element to be enabled. Defaults to 30 seconds.
* @returns {Promise<boolean>} - Returns true if the element is enabled, otherwise false.
*/
isEnabled(timeout?: number): Promise<boolean>;
/**
* Check if the element is disabled.
* @param {number} timeout - The timeout for the element to be disabled. Defaults to 30 seconds.
* @returns {Promise<boolean>} - Returns true if the element is disabled, otherwise false.
*/
isDisabled(timeout?: number): Promise<boolean>;
/**
* Check if the element is visible.
* @param {number} timeout - The timeout for the element to be visible. Defaults to 30 seconds.
* @returns {Promise<boolean>} - Returns true if the element is visible, otherwise false.
*/
isVisible(timeout?: number): Promise<boolean>;
/**
* Check if the element is hidden.
* @param {number} timeout - The timeout for the element to be hidden. Defaults to 30 seconds.
* @returns {Promise<boolean>} - Returns true if the element is hidden, otherwise false.
*/
isHidden(timeout?: number): Promise<boolean>;
/**
* Remove focus from the element.
* @returns {Promise<void>}
*/
removeFocus(): Promise<void>;
/**
* Get the computed style of an element.
* @param {string} property - The property to get the computed style of.
* @returns {Promise<string>} - The computed style of the element.
*/
getComputedStyle(property: string): Promise<string>;
/**
* Check if the element is expanded.
* @returns {Promise<boolean>} True if the element is expanded, false otherwise.
*/
isExpanded(): Promise<boolean>;
/**
* Check if the element is checked.
* @returns {Promise<boolean>} True if the element is checked, false otherwise.
*/
isChecked(): Promise<boolean>;
/**
* Check if the element is selected.
* @returns {Promise<boolean>} True if the element is selected, false otherwise.
*/
isSelected(): Promise<boolean>;
/**
* Wait for the element to be in a certain state.
* @param {Object} options - The options for the wait.
* @returns {Promise<void>}
* @deprecated Use waitForElementToBeVisible, waitForElementToBeHidden, waitForElementToBeDetached, waitForElementToBeAttached instead.
*/
waitFor(options?: {}): Promise<void>;
/**
* Wait for the element to be visible.
* @returns {Promise<void>}
* @deprecated Use waitForElementToBeVisible instead.
*/
waitForVisible(): Promise<void>;
/**
* Wait for the element to be absent.
* @returns {Promise<void>}
* @deprecated Use waitForElementToBeDetached instead.
*/
waitForAbsence(): Promise<void>;
/**
* Wait for the list elements to stabilize (i.e., the count of items remains constant for a specified duration).
* @param {Locator} locator - The locator for the elements.
* @returns {Promise<void>}
* @deprecated
*/
protected waitForAndVerifyElements(locator: Locator): Promise<void>;
}
//# sourceMappingURL=BaseElement.d.ts.map