Search code examples
seleniumselenium-webdrivercucumberselenium-idecucumber-jvm

Regular Expressions in the Cucumber feature file parameters


Is there a way to write Regular Expressions in the Cucumber feature file parameters?

for example I would like to write something like:

When I click "Edit*"

[ then Edit* will match all strings with prefix Edit (for example: Edit_Button) ]

But when I will write:

When I click "Edit"

[only Edit will be matched.]

I want the step to allow both parameter options (Edit or Edit*)

Is there a way to do that?


Solution

  • It can be done but not in the way you suggest. The "Edit*" in the example will be a String in your step definition. What you could do is write some logic that takes a string and converts that into the regex you want. Some examples here.