effect-playwright
    Preparing search index...

    Interface PlaywrightService

    0.1.0

    interface PlaywrightService {
        connectCDP: (
            cdpUrl: string,
            options?: ConnectOverCDPOptions,
        ) => Effect<PlaywrightBrowserService, PlaywrightError>;
        connectCDPScoped: (
            cdpUrl: string,
            options?: ConnectOverCDPOptions,
        ) => Effect<PlaywrightBrowserService, PlaywrightError, Scope>;
        launch: (
            browserType: BrowserType,
            options?: LaunchOptions,
        ) => Effect<PlaywrightBrowserService, PlaywrightError>;
        launchScoped: (
            browserType: BrowserType,
            options?: LaunchOptions,
        ) => Effect<PlaywrightBrowserService, PlaywrightError, Scope>;
    }
    Index

    Properties

    connectCDP: (
        cdpUrl: string,
        options?: ConnectOverCDPOptions,
    ) => Effect<PlaywrightBrowserService, PlaywrightError>

    Connects to a browser instance via Chrome DevTools Protocol (CDP).

    Unlike connectCDPScoped, this method does not close the connection when the scope is closed. It is the caller's responsibility to manage the connection's lifecycle.

    If you want to close the connection using a scope simply add a finalizer:

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

    const program = Effect.gen(function* () {
    const playwright = yield* Playwright;
    const browser = yield* playwright.connectCDP(cdpUrl);
    yield* Effect.addFinalizer(() => browser.close.pipe(Effect.ignore));
    });

    await Effect.runPromise(program);

    Type Declaration

    0.1.0

    connectCDPScoped: (
        cdpUrl: string,
        options?: ConnectOverCDPOptions,
    ) => Effect<PlaywrightBrowserService, PlaywrightError, Scope>

    Connects to a browser instance via Chrome DevTools Protocol (CDP) managed by a Scope.

    This method automatically closes the connection when the scope is closed.

    Note that closing a CDP connection does not close the browser instance itself, only the CDP connection.

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

    const program = Effect.gen(function* () {
    const playwright = yield* Playwright;
    const browser = yield* playwright.connectCDPScoped(cdpUrl);
    // Connection will be closed automatically when scope closes
    });

    await Effect.runPromise(program);

    Type Declaration

    0.1.1

    launch: (
        browserType: BrowserType,
        options?: LaunchOptions,
    ) => Effect<PlaywrightBrowserService, PlaywrightError>

    Launches a new browser instance.

    It is the caller's responsibility to manage the browser's lifecycle and close it when no longer needed. For automatic scope-based management, use launchScoped instead.

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

    const program = Effect.gen(function* () {
    const browser = yield* Playwright.launch(chromium);
    // ... use browser ...
    yield* browser.close;
    });

    await Effect.runPromise(program);

    Type Declaration

    0.1.0

    launchScoped: (
        browserType: BrowserType,
        options?: LaunchOptions,
    ) => Effect<PlaywrightBrowserService, PlaywrightError, Scope>

    Launches a new browser instance managed by a Scope.

    This method automatically closes the browser when the scope is closed.

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

    const program = Effect.gen(function* () {
    const browser = yield* Playwright.launchScoped(chromium);
    // Browser will be closed automatically when scope closes
    });

    await Effect.runPromise(program);

    Type Declaration

    0.1.0