effect-playwright
    Preparing search index...

    Interface Page

    Effect-friendly operations for a Playwright page.

    When to use

    Use this service for navigation, DOM interaction, evaluation, page state, and page event streams. Operations that can fail return Effect; safe synchronous observations remain plain functions, and nullable Playwright results are represented with Option.

    0.1.0

    interface Page {
        addInitScript: <Arg>(
            script:
                | PageFunction<Arg, unknown>
                | { content?: string; path?: string },
            arg?: Arg,
            options?: { exposeFunctions?: boolean },
        ) => Effect<void, PlaywrightError>;
        addScriptTag: (
            options:
                | { content?: string; path?: string; type?: string; url?: string }
                | undefined,
        ) => Effect<ElementHandle<Node>, PlaywrightError>;
        addStyleTag: (
            options: { content?: string; path?: string; url?: string } | undefined,
        ) => Effect<ElementHandle<Node>, PlaywrightError>;
        ariaSnapshot: (
            options?: {
                boxes?: boolean;
                depth?: number;
                mode?: "default" | "ai";
                signal?: AbortSignal;
                timeout?: number;
            },
        ) => Effect<string, PlaywrightError>;
        bringToFront: Effect<void, PlaywrightError>;
        cancelPickLocator: Effect<void, PlaywrightError>;
        clearConsoleMessages: Effect<void, PlaywrightError>;
        clearPageErrors: Effect<void, PlaywrightError>;
        click: (
            selector: string,
            options?: {
                button?: "left" | "right" | "middle";
                clickCount?: number;
                delay?: number;
                force?: boolean;
                modifiers?: ("Alt" | "Control" | "ControlOrMeta" | "Meta" | "Shift")[];
                noWaitAfter?: boolean;
                position?: { x: number; y: number };
                scroll?: "none" | "auto";
                signal?: AbortSignal;
                strict?: boolean;
                timeout?: number;
                trial?: boolean;
            },
        ) => Effect<void, PlaywrightError>;
        clock: Playwright.Clock;
        close: Effect<void, PlaywrightError>;
        consoleMessages: (
            options?: { filter?: "all" | "since-navigation" },
        ) => Effect<readonly ConsoleMessage[], PlaywrightError>;
        content: Effect<string, PlaywrightError>;
        context: () => Playwright.BrowserContext;
        dragAndDrop: (
            source: string,
            target: string,
            options?: {
                force?: boolean;
                noWaitAfter?: boolean;
                scroll?: "none" | "auto";
                signal?: AbortSignal;
                sourcePosition?: { x: number; y: number };
                steps?: number;
                strict?: boolean;
                targetPosition?: { x: number; y: number };
                timeout?: number;
                trial?: boolean;
            },
        ) => Effect<void, PlaywrightError>;
        emulateMedia: (
            options?: {
                colorScheme?: "light" | "dark" | "no-preference" | null;
                contrast?: "no-preference" | "more" | null;
                forcedColors?: "none" | "active" | null;
                media?: "screen" | "print" | null;
                reducedMotion?: "reduce" | "no-preference" | null;
            },
        ) => Effect<void, PlaywrightError>;
        evaluate: <R, Arg = void>(
            pageFunction: PageFunction<Arg, R>,
            arg?: Arg,
            options?: { exposeFunctions?: boolean },
        ) => Effect<R, PlaywrightError>;
        eventStream: <K extends keyof PageEventMap>(
            event: K,
        ) => Stream<PageEventMap[K]>;
        exposeEffect: <A, E, R>(
            name: string,
            playwrightFunction: Effect<A, E, R>,
        ) => Effect<void, PlaywrightError, R>;
        exposeFunction: <A, E, R, Args extends unknown[]>(
            name: string,
            playwrightFunction: (...args: Args) => Effect<A, E, R>,
        ) => Effect<void, PlaywrightError, R>;
        frame: (
            frameSelector:
                | string
                | {
                    name?: string;
                    url?: string
                    | RegExp
                    | URLPattern
                    | ((url: URL) => boolean);
                },
        ) => Option<Playwright.Frame>;
        frames: Effect<readonly Playwright.Frame[], PlaywrightError>;
        getByAltText: (
            text: string | RegExp,
            options?: { exact?: boolean },
        ) => Playwright.Locator;
        getByLabel: (
            label: string | RegExp,
            options?: { exact?: boolean },
        ) => Playwright.Locator;
        getByPlaceholder: (
            text: string | RegExp,
            options?: { exact?: boolean },
        ) => Playwright.Locator;
        getByRole: (
            role:
                | "alert"
                | "alertdialog"
                | "application"
                | "article"
                | "banner"
                | "blockquote"
                | "button"
                | "caption"
                | "cell"
                | "checkbox"
                | "code"
                | "columnheader"
                | "combobox"
                | "complementary"
                | "contentinfo"
                | "definition"
                | "deletion"
                | "dialog"
                | "directory"
                | "document"
                | "emphasis"
                | "feed"
                | "figure"
                | "form"
                | "generic"
                | "grid"
                | "gridcell"
                | "group"
                | "heading"
                | "img"
                | "insertion"
                | "link"
                | "list"
                | "listbox"
                | "listitem"
                | "log"
                | "main"
                | "marquee"
                | "math"
                | "meter"
                | "menu"
                | "menubar"
                | "menuitem"
                | "menuitemcheckbox"
                | "menuitemradio"
                | "navigation"
                | "none"
                | "note"
                | "option"
                | "paragraph"
                | "presentation"
                | "progressbar"
                | "radio"
                | "radiogroup"
                | "region"
                | "row"
                | "rowgroup"
                | "rowheader"
                | "scrollbar"
                | "search"
                | "searchbox"
                | "separator"
                | "slider"
                | "spinbutton"
                | "status"
                | "strong"
                | "subscript"
                | "superscript"
                | "switch"
                | "tab"
                | "table"
                | "tablist"
                | "tabpanel"
                | "term"
                | "textbox"
                | "time"
                | "timer"
                | "toolbar"
                | "tooltip"
                | "tree"
                | "treegrid"
                | "treeitem",
            options?: {
                checked?: boolean;
                description?: string | RegExp;
                disabled?: boolean;
                exact?: boolean;
                expanded?: boolean;
                includeHidden?: boolean;
                level?: number;
                name?: string | RegExp;
                pressed?: boolean;
                selected?: boolean;
            },
        ) => Playwright.Locator;
        getByTestId: (testId: string | RegExp) => Playwright.Locator;
        getByText: (
            text: string | RegExp,
            options?: { exact?: boolean },
        ) => Playwright.Locator;
        getByTitle: (
            text: string | RegExp,
            options?: { exact?: boolean },
        ) => Playwright.Locator;
        goBack: (
            options?: {
                signal?: AbortSignal;
                timeout?: number;
                waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
            },
        ) => Effect<Option<Playwright.Response>, PlaywrightError>;
        goForward: (
            options?: {
                signal?: AbortSignal;
                timeout?: number;
                waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
            },
        ) => Effect<Option<Playwright.Response>, PlaywrightError>;
        goto: (
            url: string,
            options?: {
                referer?: string;
                signal?: AbortSignal;
                timeout?: number;
                waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
            },
        ) => Effect<void, PlaywrightError>;
        hideHighlight: Effect<void, PlaywrightError>;
        isClosed: () => boolean;
        keyboard: Playwright.Keyboard;
        localStorage: Playwright.WebStorage;
        locator: (
            selector: string,
            options?: {
                has?: Locator;
                hasNot?: Locator;
                hasNotText?: string | RegExp;
                hasText?: string | RegExp;
            },
        ) => Playwright.Locator;
        mainFrame: () => Playwright.Frame;
        mouse: Playwright.Mouse;
        opener: Effect<Option<Playwright.Page>, PlaywrightError>;
        pageErrors: (
            options?: { filter?: "all" | "since-navigation" },
        ) => Effect<readonly Error[], PlaywrightError>;
        pause: Effect<void, PlaywrightError>;
        pdf: (
            options?: {
                displayHeaderFooter?: boolean;
                footerTemplate?: string;
                format?: string;
                headerTemplate?: string;
                height?: string | number;
                landscape?: boolean;
                margin?: {
                    bottom?: string | number;
                    left?: string | number;
                    right?: string | number;
                    top?: string | number;
                };
                outline?: boolean;
                pageRanges?: string;
                path?: string;
                preferCSSPageSize?: boolean;
                printBackground?: boolean;
                scale?: number;
                tagged?: boolean;
                width?: string
                | number;
            },
        ) => Effect<Buffer<ArrayBufferLike>, PlaywrightError>;
        pickLocator: Effect<Playwright.Locator, PlaywrightError>;
        reload: Effect<void, PlaywrightError>;
        requestGC: Effect<void, PlaywrightError>;
        requests: Effect<readonly Playwright.Request[], PlaywrightError>;
        screencast: Playwright.Screencast;
        screenshot: (
            options?: PageScreenshotOptions,
        ) => Effect<Buffer<ArrayBufferLike>, PlaywrightError>;
        sessionStorage: Playwright.WebStorage;
        setContent: (
            html: string,
            options?: {
                signal?: AbortSignal;
                timeout?: number;
                waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
            },
        ) => Effect<void, PlaywrightError>;
        setDefaultNavigationTimeout: (timeout: number) => void;
        setDefaultTimeout: (timeout: number) => void;
        setExtraHTTPHeaders: (
            headers: { [key: string]: string },
        ) => Effect<void, PlaywrightError>;
        setViewportSize: (
            viewportSize: { height: number; width: number },
        ) => Effect<void, PlaywrightError>;
        title: Effect<string, PlaywrightError>;
        touchscreen: Playwright.Touchscreen;
        url: () => string;
        use: <T>(f: (page: Page) => Promise<T>) => Effect<T, PlaywrightError>;
        viewportSize: () => Option<{ height: number; width: number }>;
        waitForLoadState: (
            state?: "domcontentloaded" | "load" | "networkidle",
            options?: { signal?: AbortSignal; timeout?: number },
        ) => Effect<void, PlaywrightError>;
        waitForTimeout: (timeout: number) => Effect<void, PlaywrightError>;
        waitForURL: (
            url: string | RegExp | URLPattern | ((url: URL) => boolean),
            options?: {
                signal?: AbortSignal;
                timeout?: number;
                waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
            },
        ) => Effect<void, PlaywrightError>;
        workers: () => readonly Playwright.Worker[];
    }
    Index
    eventStream: <K extends keyof PageEventMap>(event: K) => Stream<PageEventMap[K]>

    Streams page events after adapting supported payloads to wrapper values.

    Details

    Event listeners are removed when stream consumption ends. The stream also ends when the page closes.

    Example (Reading the first console event)

    import { Effect, Stream } from "effect";
    import { Playwright } from "effect-playwright";

    const firstConsoleMessage = Effect.gen(function* () {
    const page = yield* Playwright.Page;
    return yield* page.eventStream("console").pipe(Stream.runHead);
    });

    0.1.0

    addInitScript: <Arg>(
        script: PageFunction<Arg, unknown> | { content?: string; path?: string },
        arg?: Arg,
        options?: { exposeFunctions?: boolean },
    ) => Effect<void, PlaywrightError>

    Adds a script which would be evaluated in one of the following scenarios:

    • Whenever the page is navigated.
    • Whenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.

    0.3.0

    addScriptTag: (
        options:
            | { content?: string; path?: string; type?: string; url?: string }
            | undefined,
    ) => Effect<ElementHandle<Node>, PlaywrightError>

    Adds a <script> tag into the page with the desired url or content.

    0.3.0

    addStyleTag: (
        options: { content?: string; path?: string; url?: string } | undefined,
    ) => Effect<ElementHandle<Node>, PlaywrightError>

    Adds a <link rel="stylesheet"> tag into the page with the desired url or a <style type="text/css"> tag with the content.

    0.3.0

    ariaSnapshot: (
        options?: {
            boxes?: boolean;
            depth?: number;
            mode?: "default" | "ai";
            signal?: AbortSignal;
            timeout?: number;
        },
    ) => Effect<string, PlaywrightError>

    Captures the aria snapshot of the page.

    0.5.0

    bringToFront: Effect<void, PlaywrightError>

    Brings page to front (activates tab).

    0.3.0

    cancelPickLocator: Effect<void, PlaywrightError>

    Cancels the locator picking mode.

    clearConsoleMessages: Effect<void, PlaywrightError>

    Clears stored console messages.

    clearPageErrors: Effect<void, PlaywrightError>

    Clears stored page errors.

    0.5.0

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

    Clicks an element matching the given selector.

    Use Page.locator to create a locator and then call click on it instead.

    0.1.0

    Access the clock.

    0.3.0

    close: Effect<void, PlaywrightError>

    Closes the page.

    0.1.0

    consoleMessages: (
        options?: { filter?: "all" | "since-navigation" },
    ) => Effect<readonly ConsoleMessage[], PlaywrightError>

    Returns all messages that have been logged to the console.

    0.3.0

    content: Effect<string, PlaywrightError>

    Returns the full HTML contents of the page, including the doctype.

    0.3.0

    context: () => Playwright.BrowserContext

    Get the browser context that the page belongs to.

    0.3.0

    dragAndDrop: (
        source: string,
        target: string,
        options?: {
            force?: boolean;
            noWaitAfter?: boolean;
            scroll?: "none" | "auto";
            signal?: AbortSignal;
            sourcePosition?: { x: number; y: number };
            steps?: number;
            strict?: boolean;
            targetPosition?: { x: number; y: number };
            timeout?: number;
            trial?: boolean;
        },
    ) => Effect<void, PlaywrightError>

    Drags a source element to a target element and drops it.

    0.3.0

    emulateMedia: (
        options?: {
            colorScheme?: "light" | "dark" | "no-preference" | null;
            contrast?: "no-preference" | "more" | null;
            forcedColors?: "none" | "active" | null;
            media?: "screen" | "print" | null;
            reducedMotion?: "reduce" | "no-preference" | null;
        },
    ) => Effect<void, PlaywrightError>

    This method changes the CSS media type through the media argument, and/or the 'prefers-colors-scheme' media feature, using the colorScheme argument.

    0.3.0

    evaluate: <R, Arg = void>(
        pageFunction: PageFunction<Arg, R>,
        arg?: Arg,
        options?: { exposeFunctions?: boolean },
    ) => Effect<R, PlaywrightError>

    Evaluates a function in the context of the page. Example (Evaluating browser-side code)

    import { Effect } from "effect";
    import { Playwright } from "effect-playwright";

    const dimensions = Effect.gen(function* () {
    const page = yield* Playwright.Page;
    return yield* page.evaluate(() => ({
    width: document.documentElement.clientWidth,
    height: document.documentElement.clientHeight,
    }));
    });

    0.1.0

    exposeEffect: <A, E, R>(
        name: string,
        playwrightFunction: Effect<A, E, R>,
    ) => Effect<void, PlaywrightError, R>

    Identical to exposeFunction but meant to be used with a static Effect. This is useful when the exposed function does not need any arguments and just runs a pre-defined effect in the application context.

    import { Console, Effect } from "effect";
    import { Playwright } from "effect-playwright";

    const program = Effect.gen(function* () {
    const browser = yield* Playwright.Browser;
    const page = yield* browser.newPage();

    yield* page.exposeEffect("ping", Console.log("pong"));

    yield* page.evaluate(async () => {
    // @ts-expect-error
    await window.ping();
    });
    });

    0.3.0

    exposeFunction: <A, E, R, Args extends unknown[]>(
        name: string,
        playwrightFunction: (...args: Args) => Effect<A, E, R>,
    ) => Effect<void, PlaywrightError, R>

    Adds a function called name on the window object of every frame in this page.

    The provided function must return an Effect which will be executed using the current runtime when the function is called from the browser context.

    If you don't require your function to have args you can use exposeEffect instead.

    import { Console, Effect } from "effect";
    import { Playwright } from "effect-playwright";

    const program = Effect.gen(function* () {
    const browser = yield* Playwright.Browser;
    const page = yield* browser.newPage();

    // Expose an Effect-based function to the browser
    yield* page.exposeFunction("logMessage", (message: string) =>
    Console.log(`Message from browser: ${message}`),
    );

    yield* page.evaluate(() => {
    // Call the exposed function from the browser context
    // @ts-expect-error
    return window.logMessage("Hello from the other side!");
    });
    });
    import { Context, Effect } from "effect";
    import { Playwright } from "effect-playwright";

    // A custom Database service used in your Effect application
    class Database extends Context.Service<
    Database,
    { readonly insertProduct: (name: string, price: number) => Effect.Effect<void> }
    >()("Database") {}

    const program = Effect.gen(function* () {
    const browser = yield* Playwright.Browser;
    const page = yield* browser.newPage();

    // Expose a function that seamlessly accesses Effect Context using Effect.fn
    yield* page.exposeFunction(
    "saveProduct",
    Effect.fn(function* (name: string, price: number) {
    const db = yield* Database;
    yield* db.insertProduct(name, price);
    }),
    );

    yield* page.evaluate(async () => {
    // Extract data from the page and save it
    const items = document.querySelectorAll(".product");
    for (const item of items) {
    const name = item.querySelector(".name")?.textContent || "Unknown";
    const price = Number(item.querySelector(".price")?.textContent || 0);

    // Call the Effect function directly from the browser
    // @ts-expect-error
    await window.saveProduct(name, price);
    }
    });
    });

    0.3.0

    frame: (
        frameSelector:
            | string
            | {
                name?: string;
                url?: string
                | RegExp
                | URLPattern
                | ((url: URL) => boolean);
            },
    ) => Option<Playwright.Frame>

    Returns a frame matching the specified criteria.

    0.3.0

    frames: Effect<readonly Playwright.Frame[], PlaywrightError>

    Returns all frames attached to the page.

    0.2.0

    getByAltText: (
        text: string | RegExp,
        options?: { exact?: boolean },
    ) => Playwright.Locator

    Returns a locator that matches the given alt text.

    0.3.0

    getByLabel: (
        label: string | RegExp,
        options?: { exact?: boolean },
    ) => Playwright.Locator

    Returns a locator that matches the given label.

    0.1.0

    getByPlaceholder: (
        text: string | RegExp,
        options?: { exact?: boolean },
    ) => Playwright.Locator

    Returns a locator that matches the given placeholder.

    getByRole: (
        role:
            | "alert"
            | "alertdialog"
            | "application"
            | "article"
            | "banner"
            | "blockquote"
            | "button"
            | "caption"
            | "cell"
            | "checkbox"
            | "code"
            | "columnheader"
            | "combobox"
            | "complementary"
            | "contentinfo"
            | "definition"
            | "deletion"
            | "dialog"
            | "directory"
            | "document"
            | "emphasis"
            | "feed"
            | "figure"
            | "form"
            | "generic"
            | "grid"
            | "gridcell"
            | "group"
            | "heading"
            | "img"
            | "insertion"
            | "link"
            | "list"
            | "listbox"
            | "listitem"
            | "log"
            | "main"
            | "marquee"
            | "math"
            | "meter"
            | "menu"
            | "menubar"
            | "menuitem"
            | "menuitemcheckbox"
            | "menuitemradio"
            | "navigation"
            | "none"
            | "note"
            | "option"
            | "paragraph"
            | "presentation"
            | "progressbar"
            | "radio"
            | "radiogroup"
            | "region"
            | "row"
            | "rowgroup"
            | "rowheader"
            | "scrollbar"
            | "search"
            | "searchbox"
            | "separator"
            | "slider"
            | "spinbutton"
            | "status"
            | "strong"
            | "subscript"
            | "superscript"
            | "switch"
            | "tab"
            | "table"
            | "tablist"
            | "tabpanel"
            | "term"
            | "textbox"
            | "time"
            | "timer"
            | "toolbar"
            | "tooltip"
            | "tree"
            | "treegrid"
            | "treeitem",
        options?: {
            checked?: boolean;
            description?: string | RegExp;
            disabled?: boolean;
            exact?: boolean;
            expanded?: boolean;
            includeHidden?: boolean;
            level?: number;
            name?: string | RegExp;
            pressed?: boolean;
            selected?: boolean;
        },
    ) => Playwright.Locator

    Returns a locator that matches the given role.

    0.1.0

    getByTestId: (testId: string | RegExp) => Playwright.Locator

    Returns a locator that matches the given test id.

    0.1.0

    getByText: (
        text: string | RegExp,
        options?: { exact?: boolean },
    ) => Playwright.Locator

    Returns a locator that matches the given text.

    0.1.0

    getByTitle: (
        text: string | RegExp,
        options?: { exact?: boolean },
    ) => Playwright.Locator

    Returns a locator that matches the given title.

    0.3.0

    goBack: (
        options?: {
            signal?: AbortSignal;
            timeout?: number;
            waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
        },
    ) => Effect<Option<Playwright.Response>, PlaywrightError>

    Navigate to the previous page in history.

    0.3.0

    goForward: (
        options?: {
            signal?: AbortSignal;
            timeout?: number;
            waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
        },
    ) => Effect<Option<Playwright.Response>, PlaywrightError>

    Navigate to the next page in history.

    0.3.0

    goto: (
        url: string,
        options?: {
            referer?: string;
            signal?: AbortSignal;
            timeout?: number;
            waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
        },
    ) => Effect<void, PlaywrightError>

    Navigates the page to the given URL.

    0.1.0

    hideHighlight: Effect<void, PlaywrightError>

    Clears all highlights.

    0.5.0

    isClosed: () => boolean

    Indicates that the page has been closed.

    0.3.0

    Access the keyboard.

    0.3.0

    localStorage: Playwright.WebStorage

    Access local storage for the page's current origin.

    0.5.1

    locator: (
        selector: string,
        options?: {
            has?: Locator;
            hasNot?: Locator;
            hasNotText?: string | RegExp;
            hasText?: string | RegExp;
        },
    ) => Playwright.Locator

    Returns a locator for the given selector.

    NOTE: This method will cause a defect if options.has or options.hasNot are provided and belong to a different frame.

    0.1.0

    mainFrame: () => Playwright.Frame

    The page's main frame. Page is guaranteed to have a main frame which persists during navigations.

    0.3.0

    Access the mouse.

    0.3.0

    Returns the opener for popup pages and Option.none for others.

    If the opener has been closed already, returns Option.none.

    0.3.0

    pageErrors: (
        options?: { filter?: "all" | "since-navigation" },
    ) => Effect<readonly Error[], PlaywrightError>

    Returns all errors that have been thrown in the page.

    0.3.0

    pause: Effect<void, PlaywrightError>

    Pauses the script execution.

    0.3.0

    pdf: (
        options?: {
            displayHeaderFooter?: boolean;
            footerTemplate?: string;
            format?: string;
            headerTemplate?: string;
            height?: string | number;
            landscape?: boolean;
            margin?: {
                bottom?: string | number;
                left?: string | number;
                right?: string | number;
                top?: string | number;
            };
            outline?: boolean;
            pageRanges?: string;
            path?: string;
            preferCSSPageSize?: boolean;
            printBackground?: boolean;
            scale?: number;
            tagged?: boolean;
            width?: string
            | number;
        },
    ) => Effect<Buffer<ArrayBufferLike>, PlaywrightError>

    Returns the PDF buffer.

    page.pdf() generates a pdf of the page with print css media. To generate a pdf with screen media, call Page.emulateMedia before calling page.pdf().

    0.3.0

    Enters an interactive mode where hovering over elements highlights them and shows the corresponding locator.

    0.5.0

    reload: Effect<void, PlaywrightError>

    Reloads the page.

    0.1.0

    requestGC: Effect<void, PlaywrightError>

    Request the page to perform garbage collection. Note that there is no guarantee that all unreachable objects will be collected.

    0.3.0

    requests: Effect<readonly Playwright.Request[], PlaywrightError>

    Returns the most recent network requests from the page.

    0.5.0

    Access the screencast.

    0.5.0

    screenshot: (
        options?: PageScreenshotOptions,
    ) => Effect<Buffer<ArrayBufferLike>, PlaywrightError>

    Captures a screenshot of the page.

    0.3.0

    sessionStorage: Playwright.WebStorage

    Access session storage for the page's current origin.

    0.5.1

    setContent: (
        html: string,
        options?: {
            signal?: AbortSignal;
            timeout?: number;
            waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
        },
    ) => Effect<void, PlaywrightError>

    This method internally calls document.write(), inheriting all its specific characteristics and behaviors.

    0.3.0

    setDefaultNavigationTimeout: (timeout: number) => void

    This setting will change the default maximum navigation time for the following methods:

    setDefaultTimeout: (timeout: number) => void

    This setting will change the default maximum time for all the methods accepting timeout option.

    setExtraHTTPHeaders: (
        headers: { [key: string]: string },
    ) => Effect<void, PlaywrightError>

    The extra HTTP headers will be sent with every request the page initiates.

    setViewportSize: (
        viewportSize: { height: number; width: number },
    ) => Effect<void, PlaywrightError>

    Sets the viewport size for the page.

    0.3.0

    title: Effect<string, PlaywrightError>

    Returns the page title.

    0.1.0

    touchscreen: Playwright.Touchscreen

    Access the touchscreen.

    0.3.0

    url: () => string

    Returns the current URL of the page.

    0.1.0

    use: <T>(f: (page: Page) => Promise<T>) => Effect<T, PlaywrightError>

    Runs an asynchronous operation against the underlying Playwright Page.

    When to use

    Use this escape hatch only when Page does not expose the native Playwright operation you need.

    Gotchas

    The callback must return a Promise. The native page has the same lifetime as this wrapper; closing it also closes the wrapped page.

    import { Effect } from "effect";
    import { Playwright } from "effect-playwright";

    const program = Effect.gen(function* () {
    const page = yield* Playwright.Page;
    return yield* page.use((nativePage) => nativePage.title());
    });

    0.1.0

    viewportSize: () => Option<{ height: number; width: number }>

    Returns the viewport size.

    0.3.0

    waitForLoadState: (
        state?: "domcontentloaded" | "load" | "networkidle",
        options?: { signal?: AbortSignal; timeout?: number },
    ) => Effect<void, PlaywrightError>

    Waits for the page to reach the given load state.

    NOTE: Most of the time, this method is not needed because Playwright auto-waits before every action.

    waitForTimeout: (timeout: number) => Effect<void, PlaywrightError>

    Waits for the given timeout in milliseconds.

    0.4.0

    waitForURL: (
        url: string | RegExp | URLPattern | ((url: URL) => boolean),
        options?: {
            signal?: AbortSignal;
            timeout?: number;
            waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
        },
    ) => Effect<void, PlaywrightError>

    Waits for the page to navigate to the given URL.

    0.1.0

    workers: () => readonly Playwright.Worker[]

    Returns all workers.

    0.3.0