Browser tests,
kept in PHP.
Use Playwright's browser engines, auto-waiting locators, retrying assertions, network control, and trace artifacts without adopting a JavaScript test runner.
Real browsers
Drive Chromium, Firefox, and WebKit through Playwright's own driver, from PHP. Test rendering, JavaScript, network, and browser behavior without moving the suite to a JavaScript test runner.
$chromium = Playwright::chromium();
$firefox = Playwright::firefox();
$webkit = Playwright::webkit();Smart Locators
Target roles, labels, text, and test ids with typed locators. Each action resolves the current page and waits for the conditions it needs.
$page
->getByRole(
'button',
['name' => 'Sign in'],
)
->click();Web-first Assertions
Assert the rendered result. Playwright retries against the page until the condition holds or the timeout is reached.
expect(
$page->getByRole('alert')
)->toContainText('Saved');Network interception
Intercept matching browser requests: mock a response, block a third party, or let it through and read what came back.
$page->route(
'**/api/orders',
function ($route) {
$route->fulfill([
'body' => '{"orders":[]}',
]);
},
);Trace-based debugging
Write a trace archive with DOM snapshots, console output, network activity, and screenshots from the run that failed.
$context->startTracing($page);
// ... the scenario ...
$context->stopTracing($page, 'trace.zip');Browser and device contexts
Chromium, Firefox, WebKit, plus emulated devices with coherent viewports, touch support, scale factors, and user agents.
$device = (new DeviceRegistry())
->get('iPhone 15 Pro');
Playwright::webkit([
'context' => $device->toArray(),
]);More browser capabilities for real application flows.
Start with one
PHP script.
Install the PHP client and browser binaries, then run a real navigation and assertion.