Real browsers.
From PHP.
Full Playwright API, native PHP DX — just real browsers and first-class assertions.
<?php
use Playwright\Playwright;
$browser = Playwright::chromium();
$page = $browser->newPage();
$page->goto('https://playwright-php.dev');
echo $page->title();
echo $page->locator('h1')->textContent();
$page->screenshot('example.png');
$browser->close();
Launch real engines
Start Chromium, Firefox, or WebKit with PHP-ready presets for desktop and mobile runs.
<?php
$browser = Playwright::chromium([
'headless' => true,
'viewport' => [
'width' => 1920,
'height' => 1080
],
'screen' => [
'width' => 3840,
'height' => 2160
]
]);
$page = $browser->newPage();
$page->goto('https://www.whatsmybrowser.org');
echo $page->title();
Headless CI
Smart Locators
Find elements with typed locators and auto-wait. No sleeps, no manual polling.
<?php
$button = $page->getByRole('button', ['name' => 'Add to cart']);
$input = $page->getByLabel('Email');
$products = $page->locator('.product');
$firstProduct = $products->first();
$recentProducts = $products->filter(['hasText' => 'new']);
$price = $products->locator('.price');
Deterministic waits
Tabs & history
Click. Type. Tap.
Drive the browser with trusted input events. Automate file uploads, drag-and-drop, and keyboard shortcuts directly from PHP to match real user behavior.
<?php
// Mouse
$page->locator('#search-input')->hover();
$page->mouse->move(220, 410);
// Keyboard
$page->locator('#search-input')->focus();
$page->keyboard->type('Hello World', ['delay' => 100]);
$page->keyboard->press('Control+A');
// Click, Type, Tap
$page->click('button#add-to-cart');
File uploads
Keyboard macros
Flaky-free Assertions
Built-in matchers with auto-wait and auto-retry so tests stay stable when the UI isn't.
<?php
// Assert on page
expect($page)->toHaveTitle('Products - Example Store');
expect($page)->not()->toHaveURL('/error');
// Assert on locators
expect($page->locator('.product-title'))->toBeVisible();
expect($page->locator('button'))->toHaveAttribute('type', 'submit');
expect($page->locator('.grid'))->toHaveCss('display', 'grid');
PHPUnit ready
Network control
Time-travel debugging
Control time with clock API. Fast-forward timers, test expiry, and time-dependent flows.
<?php
$context = Playwright::chromium();
$page = $context->newPage();
$context->startTracing($page);
$page->goto('https://example.com');
$page->click('button');
$context->stopTracing($page, 'trace.zip');
// trace.zip contains DOM snapshots, interactions, and resources loaded
Fast-forward time
Video artifacts
Get started
Go from zero to full browser automation in under 60 seconds.
# 1. Install the package
composer require playwright-php/playwright
# 2. Download browsers
vendor/bin/playwright install
Want to help?
Playwright PHP thrives on community support. Whether you write code, sponsor development, or share your knowledge, your help drives the project forward.
Contribute
Report bugs, suggest features, or submit pull requests to improve the library.
Sponsor
Support ongoing development and maintenance through GitHub Sponsors.
Feedback
Share your ideas, report issues, or request features to help shape the future of the project.
Spread the word
Write tutorials, share on social media, or tell your team about Playwright PHP.