Skip to content

Commit 4836d77

Browse files
committed
..
1 parent 1664463 commit 4836d77

File tree

6 files changed

+1354
-0
lines changed

6 files changed

+1354
-0
lines changed

.github/workflows/ci.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
coding-standards:
13+
name: Coding Standards (PHP 8.4)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: PHP 8.4
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.4'
22+
coverage: none
23+
tools: composer
24+
25+
- name: Composer cache
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.composer/cache
29+
key: composer-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
30+
restore-keys: composer-${{ runner.os }}-
31+
32+
- name: Install deps (no dev-scripts)
33+
run: composer install --no-interaction --prefer-dist --no-progress
34+
35+
- name: PHPStan (max level)
36+
run: vendor/bin/phpstan analyse --no-progress
37+
38+
- name: PHP-CS-Fixer (dry-run)
39+
run: |
40+
if [ -f .php-cs-fixer.php ]; then
41+
vendor/bin/php-cs-fixer fix --diff --dry-run
42+
else
43+
echo "No .php-cs-fixer.php; skipping."
44+
fi
45+
46+
tests:
47+
name: Tests (PHP ${{ matrix.php }} • ${{ matrix.browser }})
48+
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
php: ['8.3', '8.4']
53+
browser: ['chromium', 'firefox', 'webkit']
54+
55+
env:
56+
PLAYWRIGHT_BROWSER: ${{ matrix.browser }}
57+
PLAYWRIGHT_HEADLESS: '1'
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: PHP ${{ matrix.php }}
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: ${{ matrix.php }}
66+
coverage: none
67+
tools: composer, phpunit
68+
69+
- name: Composer cache
70+
uses: actions/cache@v4
71+
with:
72+
path: ~/.composer/cache
73+
key: composer-${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
74+
restore-keys: composer-${{ runner.os }}-
75+
76+
- name: Install PHP deps
77+
run: composer install --no-interaction --prefer-dist --no-progress
78+
79+
- name: Node.js (for Playwright browsers)
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: '22'
83+
cache: 'npm'
84+
85+
- name: Install Playwright (${{ matrix.browser }})
86+
run: npx playwright install --with-deps ${{ matrix.browser }}
87+
88+
- name: PHPUnit (Mink driver testsuite)
89+
run: vendor/bin/phpunit --colors=always

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<div align="center">
2+
<img src="https://github.com/playwright-php/.github/raw/main/profile/playwright-php.png" alt="Playwright PHP" />
3+
4+
&nbsp; ![PHP Version](https://img.shields.io/badge/PHP-8.3+-05971B?labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
5+
&nbsp; ![CI](https://img.shields.io/github/actions/workflow/status/playwright-php/playwright-mink-driver/CI.yaml?branch=main&label=Tests&color=1D8D23&labelColor=09161E&logoColor=FFFFFF)
6+
&nbsp; ![Release](https://img.shields.io/github/v/release/playwright-php/playwright-mink-driver?label=Stable&labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
7+
&nbsp; ![License](https://img.shields.io/github/license/playwright-php/playwright-mink-driver?label=License&labelColor=09161E&color=1D8D23&logoColor=FFFFFF)
8+
9+
</div>
10+
11+
# PlaywrightPHP - Mink Driver
12+
13+
A [Mink](https://mink.behat.org/) driver powered by **Playwright PHP**.
14+
It brings modern browser automation (Chromium, Firefox, WebKit) to the Behat/Mink ecosystem.
15+
16+
> [!IMPORTANT]
17+
> Some tests are currently skipped due to Playwright PHP limitations (drag-and-drop, window/popup handling).
18+
19+
## Features
20+
21+
- Full Mink `DriverInterface` implementation
22+
- Chromium, Firefox, WebKit support (via Playwright)
23+
- Navigation, cookies, headers, auth
24+
- DOM access (XPath, CSS, attributes, values)
25+
- Form actions (check, select, attach files)
26+
- JavaScript execution and evaluation
27+
- Window & iframe switching
28+
- Screenshots
29+
30+
## Installation
31+
32+
```bash
33+
composer require --dev smnandre/mink-playwright-driver
34+
```
35+
36+
You also need Node.js and Playwright browsers:
37+
38+
```bash
39+
npm install playwright
40+
npx playwright install chromium
41+
```
42+
43+
## Usage
44+
45+
```php
46+
use Behat\Mink\Session;
47+
use PlaywrightPHP\Mink\Driver\PlaywrightDriver;
48+
49+
$driver = new PlaywrightDriver(browserType: 'chromium', headless: true);
50+
$session = new Session($driver);
51+
52+
$session->start();
53+
$session->visit('https://example.org');
54+
echo $session->getPage()->getText();
55+
$session->stop();
56+
```
57+
58+
## Testing
59+
60+
This driver is validated against the official
61+
[`minkphp/driver-testsuite`](https://github.com/minkphp/driver-testsuite).
62+
63+
### Install dependencies
64+
65+
```bash
66+
composer install
67+
```
68+
69+
### Start the test server
70+
71+
```bash
72+
vendor/bin/mink-test-server
73+
```
74+
75+
### Run tests
76+
77+
```bash
78+
vendor/bin/phpunit
79+
```
80+
81+
## CI Matrix
82+
83+
The GitHub Actions workflow runs:
84+
85+
- PHP 8.3 & 8.4
86+
- Browsers: Chromium, Firefox, WebKit
87+
- Coding standards (PHPStan + PHP-CS-Fixer)

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "smnandre/mink-playwright-driver",
3+
"description": "A Mink driver powered by Playwright PHP (Chromium/Firefox/WebKit).",
4+
"type": "library",
5+
"license": "MIT",
6+
"repositories": [
7+
{
8+
"type": "path",
9+
"url": "../../smnandre/playwrightphp",
10+
"options": {
11+
"symlink": true
12+
}
13+
}
14+
],
15+
"require": {
16+
"php": "^8.3",
17+
"playwright-php/playwright": "dev-main",
18+
"behat/mink": "^1.10",
19+
"symfony/clock": "^7.3"
20+
},
21+
"require-dev": {
22+
"mink/driver-testsuite": "dev-master",
23+
"phpunit/phpunit": "^8.5.22 || ^9.5.11"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"PlaywrightPHP\\Mink\\": "src/"
28+
}
29+
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"PlaywrightPHP\\Mink\\Tests\\": "tests/"
33+
}
34+
}
35+
}

phpunit.xml.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit colors="true" bootstrap="vendor/autoload.php">
4+
<php>
5+
<var name="driver_config_factory" value="PlaywrightPHP\Mink\Tests\Config::getInstance" />
6+
</php>
7+
8+
<testsuites>
9+
<testsuite name="Functional tests">
10+
<directory>vendor/mink/driver-testsuite/tests</directory>
11+
</testsuite>
12+
<!-- &lt;!&ndash; if needed to add more tests &ndash;&gt;-->
13+
<!-- <testsuite name="Driver tests">-->
14+
<!-- <directory>./tests/</directory>-->
15+
<!-- </testsuite>-->
16+
</testsuites>
17+
18+
<filter>
19+
<whitelist>
20+
<directory>./src</directory>
21+
</whitelist>
22+
</filter>
23+
24+
<listeners>
25+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
26+
</listeners>
27+
</phpunit>

0 commit comments

Comments
 (0)