Katalon Cucumber - Ambiguous Step Definitions Exception. Please help!

Hello,

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?

any feedback is much appreciated. Thanks!

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.

Hello there,

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.

1 Like

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 :slight_smile:

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 (.*)")

Is (.*) the problem here?