From f1ddee0143da2c49b66200b0d44593e3dd2f1aa1 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Fri, 19 Dec 2025 19:16:32 +0100 Subject: [PATCH 1/6] Update the README and documentation --- README.md | 19 ++++++-- doc/index.md | 131 ++++++++++++++++++++++++++------------------------- 2 files changed, 84 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index fafff909..45503001 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,18 @@ -This is the fork of MinkExtension library that supports PHP `>=7.4` and supports Symfony `>=4.4`. +# Mink Extension for Behat -For the documentation, please [refer to the original repository](https://github.com/Behat/MinkExtension). +This repository provides an integration of the [Mink browser emulator abstraction library](https://github.com/minkphp/Mink) with [Behat](https://github.com/Behat/Behat). -No updates other than Symfony compatibility will be provided, but this fork _might_ be synchronised with the original repository in the future. +It started as a fork of https://github.com/Behat/MinkExtension, which has been abandoned in early 2024. + +## What does it do? + +This Behat extension is an integration layer between Behat and Mink. It enables functional and acceptance testing of web applications. That way, you can write behavior-driven tests for web applications using natural language descriptions and run them against different browsers and drivers without changing your test code. + +It provides: + +- **Context classes:** (`MinkAwareContext`, `RawMinkContext`, `MinkContext`) with convenience methods and predefined step definitions that make it easier to use Mink in your Behat scenarios and contexts +- **Mink session configuration:** You can define multiple Mink sessions and the browser drivers to be used in your `behat.yml` file. In your Behat scenarios, the session to be used can be selected based on tags (`@javascript`, `@mink:session_name`). +- **Support for multiple Mink drivers:** Including Symfony BrowserKit, Selenium2, BrowserStack and many more. Additionally, third-party extensions can register their own drivers as well. +- **Configuration options** for base URLs, file paths, browser selection, and driver-specific settings + +For detailed documentation, see [doc/index.md](doc/index.md). diff --git a/doc/index.md b/doc/index.md index 1c29f505..5fdf8fd7 100644 --- a/doc/index.md +++ b/doc/index.md @@ -1,38 +1,19 @@ # Mink Extension -You can use Behat to describe anything, that you can describe in business -logic. It's tools, gui applications, web applications. The most interesting part -is web applications. First, behavioral testing already exists in the web world - -it's called functional or acceptance testing. Almost all popular frameworks -and languages provide functional testing tools. Today we'll talk about how to -use Behat for functional testing of web applications. [Mink](http://mink.behat.org) -is a tool exactly for that and this extension provides integration for it. - -Basically, MinkExtension is an integration layer between Behat 3.0+ and Mink 1.4+ -and it provides: - -* Additional services for Behat (`Mink`, `Sessions`, `Drivers`). -* `Behat\MinkExtension\Context\MinkAwareContext` which provides a `Mink` - instance for your contexts. -* Base `Behat\MinkExtension\Context\MinkContext` context which provides base - step definitions and hooks for your contexts or subcontexts. Or it could be - even used as context on its own. +This extension allows you to use the [Mink](http://mink.behat.org) browser emulator +abstraction with [Behat](https://github.com/Behat/Behat), a BDD tool for PHP. -## Installation - -This extension requires: - -* Behat 3.0+ -* Mink 1.4+ - -### Through Composer +Together, this allows you to do functional and acceptance testing of web applications. +You can write behavior-driven tests for web applications using natural language +descriptions and run them against different browsers and drivers without changing +your test code. -The easiest way to keep your suite updated is to use [Composer](http://getcomposer.org): +## Installation -1. Install with composer: +1. Installation with Composer: ```bash - $ composer require --dev behat/mink-extension + $ composer require --dev friends-of-behat/mink-extension ``` 2. Activate the extension by specifying its class in your `behat.yml`: @@ -46,12 +27,12 @@ The easiest way to keep your suite updated is to use [Composer](http://getcompos base_url: 'http://example.com' sessions: default: - goutte: ~ + browserkit_http: ~ ``` ## Usage -After installing the extension, there are 4 usage options available: +After installing the extension, there are four usage options available: 1. Extending `Behat\MinkExtension\Context\RawMinkContext` in your feature suite. This will give you the ability to use a preconfigured `Mink` instance with some @@ -118,8 +99,8 @@ this `$mink` instance will be preconfigured based on the settings you've provide ## Configuration -MinkExtension comes with a flexible configuration system, that gives you -the ability to configure Mink inside Behat to fulfil all your needs. +MinkExtension comes with a flexible configuration system that gives you +the ability to configure Mink inside Behat from your `behat.yml` file. ### Sessions @@ -134,7 +115,7 @@ default: first_session: selenium2: ~ second_session: - goutte: ~ + browserkit_http: ~ third_session: selenium2: ~ ``` @@ -168,11 +149,20 @@ javascript). ### Drivers -First of all, there are drivers enabling configuration. MinkExtension comes -with support for 7 drivers out of the box: +Configuration settings depend on the Mink driver being used. Out of the box, MinkExtension can configure the following Mink drivers: -* `GoutteDriver` - headless driver without JavaScript support. In order to use - it, modify your `behat.yml` profile: +* **Symfony `BrowserKit` with Symfony `HttpClient`** - headless driver without JavaScript support. In order to use it, install [`behat/mink-browserkit-driver`](https://packagist.org/packages/behat/mink-browserkit-driver) through Composer. Then, modify your `behat.yml` profile: + + ```yaml + default: + extensions: + Behat\MinkExtension: + sessions: + my_session: + browserkit_http: ~ + ``` + +* **GoutteDriver** - headless driver without JavaScript support. In order to use it, install [`behat/mink-goutte-driver`](https://packagist.org/packages/behat/mink-goutte-driver) through Composer. Then, modify your `behat.yml` profile: ```yaml default: @@ -215,8 +205,7 @@ with support for 7 drivers out of the box: ssl.certificate_authority: false ``` -* `Selenium2Driver` - javascript driver. In order to use it, modify your - `behat.yml` profile: +* **Selenium2Driver** - javascript driver. In order to use it, install [`behat/mink-selenium2-driver`](https://packagist.org/packages/behat/mink-selenium2-driver) through Composer. Then, modify your `behat.yml` profile: ```yaml default: @@ -227,9 +216,8 @@ with support for 7 drivers out of the box: selenium2: ~ ``` -* `SauceLabsDriver` - special flavor of the Selenium2Driver configured to use the - selenium2 hosted installation of saucelabs.com. In order to use it, modify your - `behat.yml` profile: +* **SauceLabsDriver** - special flavor of the Selenium2Driver configured to use the + selenium2 hosted installation of saucelabs.com. This uses Selenium2Driver, so make sure you have [`behat/mink-selenium2-driver`](https://packagist.org/packages/behat/mink-selenium2-driver) installed. Then, modify your `behat.yml` profile: ```yaml default: @@ -240,9 +228,8 @@ with support for 7 drivers out of the box: sauce_labs: ~ ``` -* `BrowserStackDriver` - special flavor of the Selenium2Driver configured to use the - selenium2 hosted installation of browserstack.com. In order to use it, modify your - `behat.yml` profile: +* **BrowserStackDriver** - special flavor of the Selenium2Driver configured to use the + selenium2 hosted installation of browserstack.com. This uses Selenium2Driver, so make sure you have [`behat/mink-selenium2-driver`](https://packagist.org/packages/behat/mink-selenium2-driver) installed. Then, modify your `behat.yml` profile: ```yaml default: @@ -253,8 +240,7 @@ with support for 7 drivers out of the box: browser_stack: ~ ``` -* `SeleniumDriver` - javascript driver. In order to use it, modify your `behat.yml` - profile: +* **SeleniumDriver** - javascript driver. In order to use it, install [`behat/mink-selenium-driver`](https://packagist.org/packages/behat/mink-selenium-driver) through Composer. Then, modify your `behat.yml` profile: ```yaml default: @@ -265,8 +251,7 @@ with support for 7 drivers out of the box: selenium: ~ ``` -* `SahiDriver` - javascript driver. In order to use it, modify your `behat.yml` - profile: +* **SahiDriver** - javascript driver. In order to use it, install [`behat/mink-sahi-driver`](https://packagist.org/packages/behat/mink-sahi-driver) through Composer. Then, modify your `behat.yml` profile: ```yaml default: @@ -277,8 +262,7 @@ with support for 7 drivers out of the box: sahi: ~ ``` -* `ZombieDriver` - zombie.js javascript headless driver. In order to use it, modify - your `behat.yml` profile: +* **ZombieDriver** - zombie.js javascript headless driver. In order to use it, install [`behat/mink-zombie-driver`](https://packagist.org/packages/behat/mink-zombie-driver) through Composer. Then, modify your `behat.yml` profile: ```yaml default: @@ -291,18 +275,6 @@ with support for 7 drivers out of the box: node_modules_path: /usr/local/lib/node_modules/ ``` -> [!NOTE] -> The phar version of Mink comes bundled with all 5 drivers and you don't need to do -> anything except enabling them in order to use them. - -But if you're using Composer, you need to install drivers that you need first: - -- GoutteDriver - `behat/mink-goutte-driver` -- SeleniumDriver - `behat/mink-selenium-driver` -- Selenium2Driver (also used for SauceLabs and BrowserStack) - `behat/mink-selenium2-driver` -- SahiDriver - `behat/mink-sahi-driver` -- ZombieDriver - `behat/mink-zombie-driver` - > [!NOTE] > All drivers share the same API, which means that you could use multiple drivers > for the same suite - whichever one fits your needs for concrete scenarios. Don't @@ -336,3 +308,36 @@ There's other useful parameters, that you can use to configure your suite: name. * `mink_loader` - path to a file loaded to make Mink available (useful when using the PHAR archive for Mink, useless when using Composer) + +## Adding your own or other drivers + +If you have another Mink driver implementation that you would like to use, +you can create your own `DriverFactory` implementation. Then, create a Behat +extension class and use it to register your driver factory with this extension +here along the lines of: + +```php +getExtension('mink')) { + /* @var $minkExtension MinkExtension */ + $minkExtension->registerDriverFactory(new MyDriverFactory()); + } + } +} +``` + +Your driver factory defines the driver name, which can be used to configure +_your_ driver in the `behat.yml` file just like the other drivers shown above. From db5ab7bfc6a60477fb9f6d942b87290691f60643 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 14 Jan 2026 18:47:43 +0100 Subject: [PATCH 2/6] Revert README to the one of the original (pre-fork) repo --- README.md | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 45503001..c923d5f5 100755 --- a/README.md +++ b/README.md @@ -1,18 +1,41 @@ -# Mink Extension for Behat +# MinkExtension -This repository provides an integration of the [Mink browser emulator abstraction library](https://github.com/minkphp/Mink) with [Behat](https://github.com/Behat/Behat). +MinkExtension is an integration layer between Behat 3.0+ and Mink 1.5+ +and it provides: -It started as a fork of https://github.com/Behat/MinkExtension, which has been abandoned in early 2024. +* Additional services for Behat (``Mink``, ``Sessions``, ``Drivers``). +* ``Behat\MinkExtension\Context\MinkAwareContext`` which provides ``Mink`` + instance for your contexts. +* Base ``Behat\MinkExtension\Context\MinkContext`` context which provides base + step definitions and hooks for your contexts or subcontexts. Or it could be + even used as context on its own. -## What does it do? +## Docs -This Behat extension is an integration layer between Behat and Mink. It enables functional and acceptance testing of web applications. That way, you can write behavior-driven tests for web applications using natural language descriptions and run them against different browsers and drivers without changing your test code. +[Official documentation](doc/index.rst). -It provides: +## Translated languages -- **Context classes:** (`MinkAwareContext`, `RawMinkContext`, `MinkContext`) with convenience methods and predefined step definitions that make it easier to use Mink in your Behat scenarios and contexts -- **Mink session configuration:** You can define multiple Mink sessions and the browser drivers to be used in your `behat.yml` file. In your Behat scenarios, the session to be used can be selected based on tags (`@javascript`, `@mink:session_name`). -- **Support for multiple Mink drivers:** Including Symfony BrowserKit, Selenium2, BrowserStack and many more. Additionally, third-party extensions can register their own drivers as well. -- **Configuration options** for base URLs, file paths, browser selection, and driver-specific settings +For now exist 11 translated languages: `cs`,`de`,`es`,`fr`,`ja`,`nl`,`pl`,`pt`,`ro`,`ru`,`sv`. + +**Note:** The `ja`,`nl` and `sv` are outdated. + +#### How to add a new translated language? + +If you want to translate another language, you can use as reference the `ru` language file under +[translations folder](https://github.com/Behat/MinkExtension/tree/master/i18n). + +**Important:** The filename must match with the same translated language name in [Behat](https://github.com/Behat/Behat/blob/master/i18n.php) and [Gherkin](https://github.com/Behat/Gherkin/blob/master/i18n.php) in order to work correctly. + +If the language does not exist in [Gherkin](https://github.com/Behat/Gherkin/blob/master/i18n.php), +you should consider [contributing to Gherkin translations](https://github.com/Behat/Gherkin/blob/master/CONTRIBUTING.md#contributing-to-gherkin-translations). + +## Copyright + +Copyright (c) 2012 Konstantin Kudryashov (ever.zet). See LICENSE for details. + +## Contributors + +* Konstantin Kudryashov [everzet](http://github.com/everzet) [lead developer] +* Other [awesome developers](https://github.com/Behat/MinkExtension/graphs/contributors) -For detailed documentation, see [doc/index.md](doc/index.md). From b88bc6bf24faef2ebfed5db83ffe6118c4c077b3 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 14 Jan 2026 19:06:52 +0100 Subject: [PATCH 3/6] Update README.md Co-authored-by: Christophe Coevoet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c923d5f5..187b1d49 100755 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ and it provides: ## Docs -[Official documentation](doc/index.rst). +[Official documentation](doc/index.md). ## Translated languages From bb5d000233ca5deafb6fbf273917cb1a45a86862 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 14 Jan 2026 19:07:05 +0100 Subject: [PATCH 4/6] Update doc/index.md Co-authored-by: Christophe Coevoet --- doc/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.md b/doc/index.md index 5fdf8fd7..e32a6d65 100644 --- a/doc/index.md +++ b/doc/index.md @@ -1,6 +1,6 @@ # Mink Extension -This extension allows you to use the [Mink](http://mink.behat.org) browser emulator +This extension allows you to use the [Mink](https://mink.behat.org) browser emulator abstraction with [Behat](https://github.com/Behat/Behat), a BDD tool for PHP. Together, this allows you to do functional and acceptance testing of web applications. From 3519b09b3c0a44b75523185bb8b8d1ad2100ad5f Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 14 Jan 2026 19:08:22 +0100 Subject: [PATCH 5/6] Fix mentioned dependencies --- doc/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.md b/doc/index.md index e32a6d65..56bf03c7 100644 --- a/doc/index.md +++ b/doc/index.md @@ -151,7 +151,7 @@ javascript). Configuration settings depend on the Mink driver being used. Out of the box, MinkExtension can configure the following Mink drivers: -* **Symfony `BrowserKit` with Symfony `HttpClient`** - headless driver without JavaScript support. In order to use it, install [`behat/mink-browserkit-driver`](https://packagist.org/packages/behat/mink-browserkit-driver) through Composer. Then, modify your `behat.yml` profile: +* **Symfony `BrowserKit` with Symfony `HttpClient`** - headless driver without JavaScript support. In order to use it, install [`behat/mink-browserkit-driver`](https://packagist.org/packages/behat/mink-browserkit-driver) and [`symfony/http-client`](https://packagist.org/packages/symfony/http-client) through Composer. Then, modify your `behat.yml` profile: ```yaml default: From 753194f578a2f40202b7553869ba5b43d8f2876a Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 14 Jan 2026 19:16:17 +0100 Subject: [PATCH 6/6] Add SymfonyExtension as an example --- doc/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/index.md b/doc/index.md index 56bf03c7..059dff44 100644 --- a/doc/index.md +++ b/doc/index.md @@ -341,3 +341,10 @@ class MyMinkDriverExtension implements ExtensionInterface Your driver factory defines the driver name, which can be used to configure _your_ driver in the `behat.yml` file just like the other drivers shown above. + +> [!TIP] +> If you would like to see a real-world example, have a look at the [SymfonyExtension](https://github.com/FriendsOfBehat/SymfonyExtension). +> In its [extension class](https://github.com/FriendsOfBehat/SymfonyExtension/blob/3ed86d77923be089d67d952e7b75af48fec42e22/src/ServiceContainer/SymfonyExtension.php#L102), +> it registers a `SymfonyDriver` under the driver name `symfony`. That driver can be used +> to make requests directly against a Symfony Kernel, without the overhead of HTTP network +> requests and within the same PHP process that is running Behat.