Skip to content

Page

A WWW::Playwright::Page is a single tab. Get one from Context.new-page.

goto(Str $url --> Int)

Navigates to a URL and returns the HTTP status of the navigation response.

1
my $status = $page.goto('file:///path/to/hello.html');   # 200

url(--> Str)

The current page URL.

1
my $url = $page.url;   # 'file:///path/to/hello.html'

title(--> Str)

The document title.

1
my $title = $page.title;   # 'Hello'

locator(Str $selector --> Locator)

Returns a Locator for the selector. This is the entry point to every action and query.

1
my $heading = $page.locator('#greeting');

screenshot(Str :$path --> Buf)

Captures the page as a PNG and returns the bytes. With :path, also writes the image to that path.

1
my $bytes = $page.screenshot(path => '/tmp/page.png');

See Diagnostics.

close(--> Nil)

Closes the page.

1
$page.close;