Search code examples
phpbehatmink

Behat/Mink not finding a default step for a "Then" statement


I cannot get Mink/Behat to find the default step for the phrase

Then I should see "some text" in the element "element"

Here is my thepage.feature file:

Feature: Page Works
  In order to use the page
  As a visitor
  I need to be able to load it and see content

Scenario: Navigating to the page
  Given I am on "mypage.php"
  #Then I should see "some text"
  #Then the "body" element should contain "sometext"
  #Then I should see "sometext" in the "body" element

My FeatureContext extends MinkContext so I don't see why the lower two Then statements come up as undefined, but the upper one works.

  Scenario: Navigating to the page        # features\wikipedia.feature:6
    Given I am on "thepage.php"           # FeatureContext::visit()
    Then I should see "sometext" in the element "body"

1 scenario (1 undefined)
2 steps (1 undefined)

Since the Given statement works, I don't understand what could be wrong! Surely it can't be the yml file or composer.json?

composer.json:

{
    "require": {
        "behat/behat": "2.4.*@stable",
        "behat/mink": "1.4.*@stable",
        "behat/mink-extension": "*",
        "behat/mink-goutte-driver": "*",
        "behat/mink-selenium2-driver": "*"
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}

behat.yml:

default:
  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://localhost
      goutte: ~
      selenium2: ~

Where else could the problem be? Thanks


Solution

  • Try to use

    Then I should see "sometext" in the "body" element
    

    instead of

    Then I should see "sometext" in the element "body"
    

    Here is MinkContext method description