user10156372
user10156372

Reputation: 21

How to enable Mink extension in Behat

I'm trying to use mink for a simple behat test but when I run behat command I get error: "Mink instance has not been set on Mink context class. Have you enabled the Mink Extension? (RuntimeException)"

Here's my behat.yml:

default:
    extensions:
        Behat\MinkExtension:
            base_url: "https://en.wikipedia.org"
            sessions: 
                default:
                    selenium2:
                        wd_host: http://localhost:4444/wd/hub

Here's my feature:

Feature: search wikipedia
    In order to learn about BDD
    As a passionate developers
    I need to be able to search a general internet site

Scenario:
    Given I am in wikipedia
    When I search for "Behaviour driven development"
    Then the first heading should be "Behaviour-driven-development"

And here's my FeatureContext.php:

<?php

use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\MinkExtension\Context\MinkContext; 
#use Behat\MinkContext\Context\RawMinkContext;

class FeatureContext extends MinkContext implements Context,   SnippetAcceptingContext
{

/**
 * @Given I am in wikipedia
 */
public function iAmInWikipedia()
{
    $this->visitPath("/");
}

/**
 * @When I search for :arg1
 */
public function iSearchFor($arg1)
{
    throw new PendingException();
}

/**
 * @Then the first heading should be :arg1
 */
public function theFirstHeadingShouldBe($arg1)
{
    throw new PendingException();
}
}

Upvotes: 2

Views: 598

Answers (1)

lauda
lauda

Reputation: 4173

You also need to add your context(s) to the behat.yml default contexts.

Before extensions at the same level, add:

suites:
 default:
  contexts:
    - FeatureContext

Upvotes: 0

Related Questions