PHP code example of playwright-php / playwright-mink

1. Go to this page and download the library: Download playwright-php/playwright-mink 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-mink example snippets




use Behat\Mink\Session;
use Playwright\Mink\Driver\PlaywrightDriver;

$driver = new PlaywrightDriver(
    browserType: 'chromium',
    headless: true,
);

$session = new Session($driver);
$session->start();

try {
    $session->visit('https://example.com');

    echo $session->getPage()->getText();
} finally {
    $session->stop();
}

$driver = new PlaywrightDriver(
    browserType: 'firefox',
    headless: false,
    launchOptions: [
        'slowMo' => 100,
    ],
    contextOptions: [
        'viewport' => ['width' => 1440, 'height' => 900],
        'locale' => 'en-US',
    ],
);
bash
composer laywright-install --browsers