FeatureContext文件中未定义的步骤。我已经定义了步骤。不知道是否正在调用featurecontext文件

时间:2019-02-14 16:40:31

标签: drupal behat mink

这是我的behat.yml文件。我尝试了变体以便链接FeatureContext文件。有人可以通过检查这是否是在behat.yml文件中链接功能上下文文件的正确方法来帮助我。如果需要featurecontext文件的路径,则这是路径%path.base%/features/bootstrap

default:
  suites:
    default:
      path: %paths.base%/features
      contexts: 
             - Behat\MinkExtension\Context\MinkContext
             - FeatureContext
  extensions:
    Behat\MinkExtension:
      base_url: http://echidnaacerdev.prod.acquia-sites.com/
      sessions:
        default:
          goutte: ~

这是我的FeatureContext.php文件

<?php

use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext implements Context
{
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {

    }

    /**
    * Click some text
    *
    * @When /^I click on the text :text$/
    */
    public function iClickOnTheText($text)
    {
        $session = $this->getSession();
        $element = $session->getPage()->find('xpath',$session->getSelectorsHandler()->selectorToXpath('xpath', '*//*[text()="'. $text .'"]'));
        if (null === $element) {
            throw new InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
        }

        $element->click();

    }
}

我不确定如何在behat.yml中定义功能上下文文件。谁能帮我这个忙。我得到的错误消息是 behat\minkextension\context\minkcontext has missing steps. define them with the snippets 对于特定的步骤When I click on the text "Members"

1 个答案:

答案 0 :(得分:0)

您未正确使用该步骤,应使用When I click on the text Members,请记住匹配是通过正则表达式完成的,并且正弦值应为Gherkin或Turnip。

FeatureContext应该扩展MinkContext 从yml中删除MinkContext,如果按照我说的进行扩展,则不需要,也可以删除该路径,默认情况下,它在features/bootstrap

中查找