I have two feature files that have essentially the same steps in their respective steps definition groovy file.
Both feature files start something like this:
Feature: Open a savings account with VPS
Scenario Outline: Verify the savings account order comes out in the receipt
Given: Bank advisor logs in with <customernumber>
When:...
Feature: Open a savings account with a funds account
Scenario Outline: Verify the funds account comes out in the receipt
Given: Bank advisor logs in with <customernumber1> for a funds account
When:...
I keep getting the error cucumber.runtime.AmbiguousStepDefinitionsException since the first instruction matches more than one step definition. How is that possible? Both âGivenâ statements are different enough so that cucumber should know which one to point at. Even the parameter is different.
I think this is how itâs supposed to work but this there a solution around this? To what extent do I have to make my given when then statements different enough so I wonât get the ambiguous error? What if I actually need the first steps to be similar? Is there anyway I can make a feature file point only at a specific steps definition file?
I am also having the same issue. Two similar but not exact steps. I havenât ever gotten this issue with other implementations of Cucumber so itâs likely a Katalon issue.
The feature files have not too much to do with the AmbiguousStepDefinitionsException, in my understanding. Itâs an error related to the step definitions. So, first step, not necessary the last one, would probably be to have a look at the (full) exception and your step definitionsâ annotations. Other than that, generally, the more info you post, the easier it gets to understand for other people what the issue might be.
Your issue is related to the two Given statements being named âambiguouslyâ ⌠this just means the .groovy script that handles the cucumber feature file found two functions that are named very similarly
The ones giving you issues are: @Given(âBank advisor logs in with (.)â)
Because it closely matches @Given('Bank advisor logs in with (.) for a funds accountâ)
To solve your problem just come up with a new name for one of the Given statements and keep this in mind in the future to prevent the same thing from happening.
Tip:
Dont get this confused with re-ussing lines on the feature script, you can call
Give âBank advisor logs in with < username > for a funds accountâ
as much as you want but you can only have one instance of @Give(âBank advisor logs in with (.*) for a funds accountâ)
inside of your groovy scripts
Its kind of a bummer but at the same time I can understand why it would complain, computers can only be so smart
Having the same issue, but chaging the âsentenceâ would be cumbersome. Arenât there other solutions to this?
I have tried some regex found on Stackoverflow (adding ^ + $), but doesnt seem to work with Katalon? Here is one of the situations i have:
@When("ik een (.*) toevoeg aan het profiel van (.*) met de gegevens: (.*), (.*) en (.*)")
@When("ik een contactpersoon bij nood toevoeg aan het profiel van (.*) met de gegevens: (.*), (.*), (.*) en (.*)")