1. Go to this page and download the library: Download playwright-php/playwright 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/ */
$context->storageState(__DIR__.'/state.json');
// Later in another process
$ctx = Playwright::chromium([
'context' => ['storageState' => __DIR__.'/state.json'],
]);
use PHPUnit\Framework\TestCase;
use Playwright\Testing\PlaywrightTestCaseTrait;
final class HomePageTest extends TestCase
{
use PlaywrightTestCaseTrait;
protected function setUp(): void
{
parent::setUp();
$this->setUpPlaywright();
}
protected function tearDown(): void
{
$this->tearDownPlaywright();
parent::tearDown();
}
public function test_title_is_correct(): void
{
$this->page->goto('https://example.com');
$this->expect($this->page)->toHaveTitle('Example Domain');
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.