Rand Stats

WWW::Playwright

zef:gdonald

WWW::Playwright

A Raku driver for Playwright. Raku spawns a long-lived Node sidecar that imports the official playwright package, and talks to it over newline-delimited JSON-RPC on stdio. Raku owns the API surface and lifecycle. Node owns the browser.

Install

zef install WWW::Playwright
install              # the bin/install script: npm install + playwright install chromium

bin/install fetches the pinned playwright npm package and the Chromium binary next to the sidecar script. Node 18 or newer must be on PATH (or pointed at by PLAYWRIGHT_NODE).

Usage

use WWW::Playwright;

my $playwright = WWW::Playwright.start;
my $browser    = $playwright.launch;          # headless Chromium
my $context    = $browser.new-context;
my $page       = $context.new-page;

$page.goto('file:///path/to/page.html');

$page.locator('#name').fill('Ada');
$page.locator('#go').click;

say $page.locator('#result').text-content;

$page.close;
$context.close;
$browser.close;
$playwright.stop;

API

Environment

Documentation

Full docs are built from docs-src with mkdocs.

License

Artistic-2.0