0

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

Jodes
  • 14,118
  • 26
  • 97
  • 156

2 Answers2

1

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

Igor Lantushenko
  • 1,771
  • 10
  • 19
0

Try with these (got it from here):

composer.json

"require-dev": {
    "behat/behat": "2.5.5",
    "behat/mink-extension": "1.3.3",
    "behat/mink": "1.5.0",
    "behat/symfony2-extension": "1.1.2",
    "behat/mink-selenium2-driver": "1.1.1",
    "behat/mink-browserkit-driver": "1.1.0",
    "behat/mink-goutte-driver": "1.0.9"
}

behat.yml

default:
    formatter:
        name: pretty
        parameters:
            output_styles:
                comment: [ magenta ]
    context:
        class: Application\BackendBundle\Features\Context\FeatureContext
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://football.local/app_test.php/'
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

For more examples, look here

BentCoder
  • 12,257
  • 22
  • 93
  • 165