PlaywrightManager

Playwright\Behat\PlaywrightManager

Owns the Playwright client and browser for the whole Behat run and hands
out one isolated page per scenario.
The browser is launched on first use and kept until shutdown(). Each page
lives in its own browser context, so cookies and storage never leak from
one scenario to the next.

$ composer require playwright-php/playwright-behat

Methods

__construct()

function __construct(private readonly array $config)

getConfig()

array
function getConfig(): array

getTimeout()

int

Timeout in milliseconds for browser actions and navigations.

function getTimeout(): int

getBrowser()

BrowserInterface
function getBrowser(): BrowserInterface

hasPage()

bool
function hasPage(): bool

getPage()

PageInterface

Returns the page of the current scenario, opening it on first call.

function getPage(): PageInterface

closePage()

void

Closes the current scenario page and its browser context.

function closePage(): void

saveScreenshot()

string

Saves a screenshot of the current page under the configured directory.

function saveScreenshot(string $name): string

getScreenshotDir()

string
function getScreenshotDir(): string

shutdown()

void

Closes the page, the browser and the Playwright client.

function shutdown(): void