Mink
A PHP browser emulator abstraction that unifies web acceptance testing across drivers.
Repository Health
Technical Analysis
Mink is a PHP library that provides a single, consistent API for controlling a web browser in acceptance tests, regardless of the underlying driver. It abstracts away the differences between fast headless browser emulators (like Goutte/BrowserKit) and real, JavaScript-capable browsers driven through Selenium or WebDriver, so the same test code can run against either.
Through its Session, Page/Element, and WebAssert objects, Mink lets you visit pages, fill and submit forms, click links, select elements with CSS or XPath, and assert on the resulting page state. It integrates tightly with Behat for BDD-style web testing but works as a standalone library in any PHP test suite.
What You Get
- A
SessionAPI to drive navigation, form interaction, and page inspection across any supported driver - Element selection via CSS or XPath through a consistent
Element/NodeElementmodel - A
WebAsserthelper for expressive assertions on page content, status, and elements - A pluggable driver architecture spanning headless emulators and real Selenium/WebDriver browsers
Common Use Cases
- Writing web acceptance tests that run the same against a headless emulator or a real browser
- Driving JavaScript-heavy pages through Selenium while keeping test code driver-agnostic
- Powering Behat scenarios that exercise a web application end to end
Under The Hood
Architecture — The core Mink.php registers named sessions, each wrapping a Session.php that pairs a Driver implementation with a SelectorsHandler. Interactions go through Element objects (DocumentElement, NodeElement) that translate CSS/XPath selectors via the Selector subsystem into driver calls, while WebAssert.php provides high-level assertions. Drivers implement a shared DriverInterface, so backends are interchangeable.
Tech Stack — Pure PHP, distributed via Composer. Concrete drivers (BrowserKit/Goutte, Selenium2/WebDriver, etc.) live in separate companion packages that plug into Mink’s driver interface.
Code Quality — The tests/ tree mirrors the source (Driver, Element, Exception, Selector) and includes a driver test-suite contract that companion driver packages run against to prove conformance — a strong pattern for keeping a multi-backend abstraction consistent.
API Design — The API reads naturally for test authors: $session->visit(), $page->fillField(), $page->pressButton(), $assert->pageTextContains(). Because every driver honors the same interface, tests written once remain portable across emulated and real browsers with no code changes.