Behat 3 + Mink + Selenium
We will be installing the following:
- Behat version 3 – the testingframework
- Mink – for controlling real webbrowsers to run your tests
- PHPUnit – for using the handy ‘assert’ methods PHPUnit provides.
- Selenium Standalone Server – this will act as a service to accept connections and map them to browsers.
Install Behat, Mink and PHPUnit with composer:
$ composer require behat/mink-extension behat/mink-goutte-driver
Note: PHPUnit is not in the list. This is done so that composer can figure out the right version to download.
Download Selenium Standalone Server from the following URL: http://www.seleniumhq.org/download/
We will tell behat to use the Mink extension, use
http://localhost as the URL that needs to be tested. All stepdefinitions will be used from classes
Create a file in the root of the
tests directory named
behat.yml and put in the following contents.
# file tests/behat.yml default: extensions: Behat\MinkExtension: base_url: http://localhost goutte: ~ selenium2: ~ suites: default: contexts: - FeatureContext - Behat\MinkExtension\Context\MinkContext
Now, run the tests: