behat/mink
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
symfony/css-selector | v6.4.7 | - | MIT | prod |
Behat/Mink is an incredible PHP package that has been designed to act as a browser emulator and a browser controller abstraction. Its unique purpose is to bring an API to the table that would enable developers to systematically and declaratively control and test web application scenarios. This special package would essentially behave as a mediator between your test codes and the native browser driver or emulator of your choice.
To utilize Behat/Mink, start by initializing Mink and registering sessions. You then set the desired default session name. To visit a page, use the 'visit' function for the specific session (getSession). You can also interact with page elements like links or buttons. You can select sessions by their names, enabling the capability of mixing sessions in your tests.
Here is a basic usage example:
<?php
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\GoutteDriver,
Behat\Mink\Driver\Goutte\Client as GoutteClient;
$startUrl = 'http://example.com';
// Initialize Mink and register sessions
$mink = new Mink(array(
'goutte1' => new Session(new GoutteDriver(new GoutteClient())),
'goutte2' => new Session(new GoutteDriver(new GoutteClient())),
'custom' => new Session(new MyCustomDriver($startUrl))
));
// Set the default session name
$mink->setDefaultSessionName('goutte2');
// Visit a page
$mink->getSession()->visit($startUrl);
// Interact with the page
$mink->getSession()->getPage()->findLink('Downloads')->click();
echo $mink->getSession()->getPage()->getContent();
// Use a named session
$mink->getSession('custom')->getPage()->findLink('Downloads')->click();
echo $mink->getSession('custom')->getPage()->getContent();
// Mix sessions
$mink->getSession('goutte1')->getPage()->findLink('Chat')->click();
$mink->getSession('goutte2')->getPage()->findLink('Chat')->click();
Dependencies for Behat/Mink are installed using Composer:
$> curl -sS https://getcomposer.org/installer | php
$> php composer.phar install
All the in-depth information and documentation you might need about behat/mink can be found on Mink's main website https://mink.behat.org. For a community of users and contributors, you can engage with official Google Group https://groups.google.com/group/behat. Further resources such as Notes on Patches/Pull Requests can be found in the repository itself under the filename "CONTRIBUTING.md".