Interface AppwrightLocator

interface AppwrightLocator {
    fill(value: string, options?: ActionOptions): Promise<void>;
    getText(options?: ActionOptions): Promise<string>;
    isVisible(options?: ActionOptions): Promise<boolean>;
    scroll(direction: ScrollDirection): Promise<void>;
    sendKeyStrokes(value: string, options?: ActionOptions): Promise<void>;
    tap(options?: ActionOptions): Promise<void>;
    waitFor(state: "attached" | "visible", options?: ActionOptions): Promise<void>;
}

Methods

  • Fills the input element with the given value. This method waits for the element to be visible before filling it.

    Usage:

    await device.getByText("Search").fill("My query");
    

    Parameters

    • value: string

      The value to fill in the input field

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<void>

  • Returns the text content of the element. This method waits for the element to be visible before getting the text.

    Usage:

    const textContent = await device.getByText("Search").getText();
    

    Parameters

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<string>

  • Waits for the element to be visible, while attempting for the timeout duration. Returns boolean based on the visibility of the element.

    Usage:

    const isVisible = await device.getByText("Search").isVisible();
    

    Parameters

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<boolean>

  • Sends key strokes to the element. This method waits for the element to be visible before sending the key strokes.

    Usage:

    await device.getByText("Search").sendKeyStrokes("My query");
    

    Parameters

    • value: string

      The string to send as key strokes.

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<void>

  • Taps (clicks) on the element. This method waits for the element to be visible before clicking it.

    Usage:

    await device.getByText("Submit").tap();
    

    Parameters

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<void>

  • Wait for the element to be visible or attached, while attempting for the timeout duration. Throws TimeoutError if element is not found within the timeout.

    Usage:

    await device.getByText("Search").waitFor({ state: "visible" });
    

    Parameters

    • state: "attached" | "visible"

      The state to wait for

    • Optionaloptions: ActionOptions

      Use this to override the timeout for this action

    Returns Promise<void>