effect-playwright
    Preparing search index...

    Interface PlaywrightLocatorService

    Interface for a Playwright locator.

    interface PlaywrightLocatorService {
        click: (
            options?: {
                button?: "left" | "right" | "middle";
                clickCount?: number;
                delay?: number;
                force?: boolean;
                modifiers?: ("Alt" | "Control" | "ControlOrMeta" | "Meta" | "Shift")[];
                noWaitAfter?: boolean;
                position?: { x: number; y: number };
                steps?: number;
                timeout?: number;
                trial?: boolean;
            },
        ) => Effect<void, PlaywrightError>;
        count: Effect<number, PlaywrightError>;
        evaluate: <
            R,
            Arg = void,
            E extends SVGElement | HTMLElement = SVGElement | HTMLElement,
        >(
            pageFunction: (element: E, arg: Unboxed<Arg>) => R | Promise<R>,
            arg?: Arg,
            options?: { timeout?: number },
        ) => Effect<R, PlaywrightError>;
        fill: (
            value: string,
            options?: { force?: boolean; noWaitAfter?: boolean; timeout?: number },
        ) => Effect<void, PlaywrightError>;
        first: () => PlaywrightLocatorService;
        getAttribute: (
            name: string,
            options?: { timeout?: number },
        ) => Effect<string | null, PlaywrightError>;
        innerHTML: (
            options?: { timeout?: number },
        ) => Effect<string, PlaywrightError>;
        innerText: (
            options?: { timeout?: number },
        ) => Effect<string, PlaywrightError>;
        inputValue: (
            options?: { timeout?: number },
        ) => Effect<string, PlaywrightError>;
        last: () => PlaywrightLocatorService;
        nth: (index: number) => PlaywrightLocatorService;
        textContent: (
            options?: { timeout?: number },
        ) => Effect<string | null, PlaywrightError>;
        use: <T>(f: (locator: Locator) => Promise<T>) => Effect<T, PlaywrightError>;
    }
    Index

    Properties

    click: (
        options?: {
            button?: "left" | "right" | "middle";
            clickCount?: number;
            delay?: number;
            force?: boolean;
            modifiers?: ("Alt" | "Control" | "ControlOrMeta" | "Meta" | "Shift")[];
            noWaitAfter?: boolean;
            position?: { x: number; y: number };
            steps?: number;
            timeout?: number;
            trial?: boolean;
        },
    ) => Effect<void, PlaywrightError>

    Clicks the element.

    0.1.0

    count: Effect<number, PlaywrightError>

    Counts the number of matched elements.

    0.1.0

    evaluate: <
        R,
        Arg = void,
        E extends SVGElement | HTMLElement = SVGElement | HTMLElement,
    >(
        pageFunction: (element: E, arg: Unboxed<Arg>) => R | Promise<R>,
        arg?: Arg,
        options?: { timeout?: number },
    ) => Effect<R, PlaywrightError>

    Evaluates a function on the matched element.

    import { PlaywrightBrowser } from "effect-playwright";
    import { PlaywrightEnvironment } from "effect-playwright/experimental";
    import { chromium } from "@playwright/test";
    import { Effect } from "effect";

    const program = Effect.gen(function* () {
    const browser = yield* PlaywrightBrowser;
    const page = yield* browser.newPage();
    const locator = yield* page.locator("button");
    const buttonContent = yield* locator.evaluate((button) => button.textContent());
    }).pipe(PlaywrightEnvironment.provideBrowser, Effect.provide(PlaywrightEnvironment.layer(chromium)));

    0.1.0

    fill: (
        value: string,
        options?: { force?: boolean; noWaitAfter?: boolean; timeout?: number },
    ) => Effect<void, PlaywrightError>

    Fills the input field.

    0.1.0

    Returns a locator that points to the first matched element.

    0.1.0

    getAttribute: (
        name: string,
        options?: { timeout?: number },
    ) => Effect<string | null, PlaywrightError>

    Gets an attribute value.

    0.1.0

    innerHTML: (options?: { timeout?: number }) => Effect<string, PlaywrightError>

    Gets the inner HTML.

    0.1.0

    innerText: (options?: { timeout?: number }) => Effect<string, PlaywrightError>

    Gets the inner text.

    0.1.0

    inputValue: (options?: { timeout?: number }) => Effect<string, PlaywrightError>

    Gets the input value.

    0.1.0

    Returns a locator that points to the last matched element.

    0.1.0

    nth: (index: number) => PlaywrightLocatorService

    Returns a locator that points to the nth matched element.

    0.1.0

    textContent: (
        options?: { timeout?: number },
    ) => Effect<string | null, PlaywrightError>

    Gets the text content.

    0.1.0

    use: <T>(f: (locator: Locator) => Promise<T>) => Effect<T, PlaywrightError>

    A generic utility to execute any promise-based method on the underlying Playwright Locator. Can be used to access any Locator functionality not directly exposed by this service.

    Type Declaration

      • <T>(f: (locator: Locator) => Promise<T>): Effect<T, PlaywrightError>
      • Type Parameters

        • T

        Parameters

        • f: (locator: Locator) => Promise<T>

          A function that takes the Playwright Locator and returns a Promise.

        Returns Effect<T, PlaywrightError>

        An effect that wraps the promise and returns its result.

    const isVisible = yield* locator.use((l) => l.isVisible());
    

    0.1.0