PlaywrightPHP

Installation

Install PlaywrightPHP and start writing tests

PlaywrightPHP PlaywrightPHP

Welcome to PlaywrightPHP! This guide will walk you through setting up PlaywrightPHP in your project. The installation process involves three simple steps:

Install PlaywrightPHP via Composer

composer require victor-teles/playwright-php

Install npm dependencies

npm install https://github.com/victor-teles/playwright-php/tarball/main

Install browser drivers (optional)

npx playwright install

Write your first test and run it 🎊

<?php
use PlaywrightPhp\Playwright;
 
class ExampleTest extends TestCase
{
    public function test_example()
    {
        $playwright = new Playwright(); // launch playwright
        $browser = $playwright->launch(); // launch browser
 
        $page = $browser->newPage(); // create new page
        $page->goto('https://example.com'); // navigate to example.com
        $page->screenshot(['path' => 'screenshot.png']); // take screenshot
    }
}

System Requirements

  • PHP 8.0+
  • Composer
  • Latest version of Node.js 18, 20 or 22
  • Windows 10+, Windows Server 2016+ or Windows Subsystem for Linux (WSL).
  • macOS 13 Ventura, or later.
  • Debian 12, Ubuntu 22.04, Ubuntu 24.04, on x86-64 and arm64 architecture.

On this page