Php 该步骤已声明,或者尚未在Mink上下文类上设置Mink实例
我正在尝试使用Drupal项目进行一些测试(但Behat不在其中),但是我在Mink及其会话方面遇到了麻烦,我必须承认我对自己正在做的事情一无所知 以下是我目前的档案: FeatureContext.php behat.ymlPhp 该步骤已声明,或者尚未在Mink上下文类上设置Mink实例,php,behat,Php,Behat,我正在尝试使用Drupal项目进行一些测试(但Behat不在其中),但是我在Mink及其会话方面遇到了麻烦,我必须承认我对自己正在做的事情一无所知 以下是我目前的档案: FeatureContext.php behat.yml default: suites: default: contexts: - FeatureContext - Drupal\DrupalExtension\Context\DrupalContext - Dru
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
Behat\MinkExtension:
browser_name: chrome
base_url: http://www.spheria.rec
sessions:
default:
chrome:
api_url: http://localhost:9222
Drupal\DrupalExtension:
blackbox: ~
测试功能
Feature: Sample feature
Scenario: Arrived on website, checking out what's around me
Given I am an anonymous user
And I go to "/"
And I should see "Se connecter"
And I should see "Nom d'utilisateur"
And I should see "Mot de passe"
When I fill in "admin@spheria.com" for "name"
And I fill in "admin" for "pass"
And I press "Se connecter"
Then I should get a 200 HTTP response
And the url should match "/dashboard"
And I should see "Tableau de bord"
我的问题是,如果我在behat文件和FeatureContext中使用MinkContext,控制台会向我返回每个函数都声明了两次(至少,MincContext::PressButton
,但如果出现其他问题,我不会感到惊讶)
当我从behat.yml
和FeatureContext中删除它时,它什么都不识别,并要求我定义这些函数,我想这是有道理的
当我仅在behat文件或FeatureContext文件中使用MinkContext时,我会得到一个错误,如下所示:
尚未在Mink上下文类上设置Mink实例。您启用了貂皮扩展了吗?(运行时异常)
我使用的是DMore Chrome驱动程序,因为我无法正确运行带有Selenium的Chrome,我感觉在构造函数中实例化Mink会产生一些问题
说我完全不知道该做什么是委婉的说法
我怎样才能解决这个问题
提前感谢您您只需扩展MinkContext一次,否则每次扩展都会看到重复的步骤
behat.yml
中的一个上下文已经在扩展MinkContext
,因此您需要:
FeatureContext
FeatureContext
不应扩展MinkContext
,而应扩展RawMinkContext
Feature: Sample feature
Scenario: Arrived on website, checking out what's around me
Given I am an anonymous user
And I go to "/"
And I should see "Se connecter"
And I should see "Nom d'utilisateur"
And I should see "Mot de passe"
When I fill in "admin@spheria.com" for "name"
And I fill in "admin" for "pass"
And I press "Se connecter"
Then I should get a 200 HTTP response
And the url should match "/dashboard"
And I should see "Tableau de bord"