/** * QA360 Smart Wait Module * * P0: Smart element waiting strategies * - Wait for element visibility * - Wait for element to be hidden/removed * - Wait for element state changes * - Wait for network idle * - Wait for content stability * - Polling with smart intervals */ import type { Page, Locator } from '@playwright/test'; /** * Wait options */ export interface SmartWaitOptions { /** Maximum time to wait in ms (default: 30000) */ timeout?: number; /** Polling interval in ms (default: 100) */ interval?: number; /** Whether to throw error on timeout (default: true) */ throwOnTimeout?: boolean; } /** * Element state for waiting */ export type ElementState = 'attached' | 'detached' | 'visible' | 'hidden'; /** * Stability wait result */ export interface StabilityResult { /** Whether content was stable */ stable: boolean; /** Number of checks performed */ checks: number; /** Total time waited in ms */ elapsed: number; /** Stability percentage (0-100) */ stability: number; } /** * Smart Wait Helper */ export declare class SmartWait { private page; constructor(page: Page); /** * Wait for element to be visible */ visible(locator: Locator, options?: SmartWaitOptions): Promise; /** * Wait for element to be hidden */ hidden(locator: Locator, options?: SmartWaitOptions): Promise; /** * Wait for element to be attached to DOM */ attached(locator: Locator, options?: SmartWaitOptions): Promise; /** * Wait for element to be detached from DOM */ detached(locator: Locator, options?: SmartWaitOptions): Promise; /** * Wait for element to reach a specific state */ state(locator: Locator, state: ElementState, options?: SmartWaitOptions): Promise; /** * Wait for multiple elements to be visible */ allVisible(locators: Locator[], options?: SmartWaitOptions): Promise; /** * Wait for at least one of multiple elements to be visible */ anyVisible(locators: Locator[], options?: SmartWaitOptions): Promise; /** * Wait for element text content to match */ text(locator: Locator, text: string | RegExp, options?: SmartWaitOptions): Promise; /** * Wait for element text content to change */ textChange(locator: Locator, options?: SmartWaitOptions): Promise; /** * Wait for element attribute to have a value */ attribute(locator: Locator, name: string, value: string | RegExp, options?: SmartWaitOptions): Promise; /** * Wait for element to have a specific CSS class */ hasClass(locator: Locator, className: string, options?: SmartWaitOptions): Promise; /** * Wait for element count to match expected */ count(locator: Locator, expected: number, options?: SmartWaitOptions): Promise; /** * Wait for content to stabilize (no changes for specified duration) */ stable(locator: Locator, stableDuration?: number, options?: SmartWaitOptions): Promise; /** * Wait for network idle (no network requests for specified duration) */ networkIdle(idleTime?: number, options?: SmartWaitOptions): Promise; /** * Wait for URL to match */ url(match: string | RegExp | ((url: URL) => boolean), options?: SmartWaitOptions): Promise; /** * Wait for selector to exist in page */ selector(selector: string, options?: SmartWaitOptions): Promise; /** * Wait for multiple conditions to be met */ all(conditions: Array<() => Promise>, options?: SmartWaitOptions): Promise; /** * Wait for at least one condition to be met */ any(conditions: Array<() => Promise>, options?: SmartWaitOptions): Promise; /** * Sleep utility */ private sleep; } /** * Convenience function to create smart wait helper */ export declare function smartWait(page: Page): SmartWait; /** * Convenience functions for common waits */ export declare function waitForVisible(locator: Locator, options?: SmartWaitOptions): Promise; export declare function waitForHidden(locator: Locator, options?: SmartWaitOptions): Promise; export declare function waitForText(locator: Locator, text: string | RegExp, options?: SmartWaitOptions): Promise;