dtby67541
2015-07-26 14:36
浏览 43
已采纳

Behat / Mink没有找到“Then”语句的默认步骤

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

图片转代码服务由CSDN问答提供 功能建议

我无法让Mink / Behat找到短语的默认步骤

 然后我应该在元素“element”中看到“some text”
   
 
 

这是我的thepage.feature文件: \ n

 功能:页面工作
为了使用页面
作为访问者
我需要能够加载它并查看内容
 
场景:导航到页面
鉴于我 am on“mypage.php”
#然后我应该看到“some text”
#然后“body”元素应该包含“sometext”
#然后我应该在“body”元素中看到“sometext”
    
 
 

我的 FeatureContext 扩展 MinkContext 所以我不明白为什么下面的两个然后语句出现为未定义,但上层语句有效。

 场景:导航到页面#features \ wikipedia.feature:6 
鉴于我在“页面上”。  php“#FeatureContext :: visit()
然后我应该在元素”body“中看到”sometext“
 
1 scena  rio(1 undefined)
2步骤(1 undefined)
   
 
 

由于 Given 语句有效,我不明白可能是什么 错误! 当然它不能是yml文件或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“:”*“
},
”最小稳定性“:”dev“,
”config“:  {
“bin-dir”:“bin /”
} 
} 
   
 
 

behat.yml:

 默认:
 extensions:
 Behat \ MinkExtension \ Extension:
 base_url:http:// localhost 
 goutte:〜
 selenium2:〜
   
 \  n 

问题还有什么地方? 谢谢

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dsgdsf12312 2015-07-26 17:30
    已采纳

    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

    点赞 打赏 评论
  • dqpfkzu360216 2015-07-26 17:47

    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

    点赞 打赏 评论

相关推荐 更多相似问题