Domanda

I am implementing Behat with Mink, using the following feature:

Scenario: Search for another phrase that exists
Given I am on "/wiki/Main_Page"
When I fill in "search" with "Behavior Driven Development"
And I press "searchButton"
Then I should see "agile software development"

I have used the Goutte and Sahi, and the error is consistent. I get the error on "Then I should see "agile software development"

Scenario: Search for another phrase that exists              # features/wikipedia.feature:13
Given I am on "/wiki/Main_Page"                            # WikipediaFeatureContext::visit()
When I fill in "search" with "Behavior Driven Development" # WikipediaFeatureContext::fillField()
And I press "searchButton"                                 # WikipediaFeatureContext::pressButton()
Then I should see "agile software development"
  Ambiguous match of "I should see "agile software development"":
  to `/^I should see "([^"]*)"$/` from AccountFeatureContext::iShouldSee()
  to `/^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/` from WikipediaFeatureContext::assertPageContainsText()

How to fix this issue.

È stato utile?

Soluzione

Removed "I" from Then I should see "agile software development" step.

Altri suggerimenti

Your gherkin statement is matching more than one method's regex.

You likely have another method in your FeatureContext file which will match "I should see" causing the ambiguous error.

I found that when I came across this I had mistakenly spelled should with a capital S resulting in a new method being appended.

"I Should see "blah blah"" instead of "I should see "blah blah""

Please check your feature files for any misspelled "I should see..." statements and check your feature context file and remove the extra method.

You'll then be able to write your statements in gherkin syntax properly including your I's

You are including 2 different contexts that define/implement the "same" Step Definition. The I should see "something" step definition comes for free in MinkContext, so my recommendation is removing it from your custom contexts: AccountFeatureContext and WikipediaFeatureContext and including MinkContext:

http://behat.org/en/latest/user_guide/context.html#multiple-contexts

If you put extra logic in your method definition, I recommend creating a new Sentence explaining what exactly you are pretending to see and there use subcontexts for reusing existing implementations:

http://docs.behat.org/en/v2.5/guides/4.context.html

Apart from this consider using another driver different to Sahi, it's no longer maintained:

https://packagist.org/packages/behat/mink-sahi-driver

This issue could also be avoided by making the regular expressions less ambiguous.

The approach you used above still lets you write ambiguous steps.

Best.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top