PHP code example of playwright-php / playwright-symfony

1. Go to this page and download the library: Download playwright-php/playwright-symfony library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

playwright-php / playwright-symfony example snippets


// config/bundles.php
return [
    // ...
    Playwright\Symfony\PlaywrightSymfonyBundle::class => ['test' => true],
];



namespace App\Tests\E2E;

use Playwright\Symfony\Test\PlaywrightTestCase;

final class HomepageTest extends PlaywrightTestCase
{
    public function testNavigation(): void
    {
        $page = $this->visit('/');

        self::assertResponseIsSuccessful();
        $page->getByRole('link', ['name' => 'About'])->click();

        $this->assertPageContains('About');
    }
}

$this->visit('/admin');

self::assertSame(200, $this->getLastResponse()?->getStatusCode());
$service = static::getContainer()->get(App\Service\AuditLog::class);

$alice = static::getPlaywrightClient();
$bob = static::createPlaywrightClient();

$this->loginUser($user);

$page = $this->visit('/account');
$this->assertPageContains($user->getUserIdentifier());
bash
composer laywright-install --browsers