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);
The CDP URL to connect to.
Optionaloptions: ConnectOverCDPOptionsOptional options for connecting to the CDP URL.
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);
The CDP URL to connect to.
Optionaloptions: ConnectOverCDPOptionsOptional options for connecting to the CDP URL.
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);
The browser type to launch (e.g. chromium, firefox, webkit).
Optionaloptions: LaunchOptionsOptional launch options.
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);
The browser type to launch (e.g. chromium, firefox, webkit).
Optionaloptions: LaunchOptionsOptional launch options.
Since
0.1.0