browser

Browser

A WWW::Playwright::Browser wraps a launched Chromium instance. Get one from WWW::Playwright.launch.

new-context(--> Context)

Creates an isolated browser context and returns a Context. Each context has its own cookies, storage, and pages, which makes it the right boundary for one test.

my $context = $browser.new-context;

It accepts named options that emulate a device or environment, applied to every page in the context:

my $context = $browser.new-context(
  viewport     => { width => 390, height => 844 },
  is-mobile    => True,
  has-touch    => True,
  color-scheme => 'dark',
);
OptionEffect
viewport{ width, height } of the page in pixels.
user-agentOverride the User-Agent header.
device-scale-factorDevice pixel ratio.
is-mobileEmulate a mobile device (affects the viewport meta tag).
has-touchAdvertise touch support.
reduced-motion'reduce' or 'no-preference'.
color-scheme'light', 'dark', or 'no-preference'.
localeBCP 47 locale, e.g. 'en-US'.

Only the options you pass are sent; the rest keep Playwright's defaults.

close(--> Nil)

Closes the browser and every context and page under it.

$browser.close;

WWW::Playwright v0.9.1

A Raku driver for Playwright via a long-lived Node sidecar

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.