I code cucumber scripts for java
There is a following case for or selection
working @When("^(chrome|firefox|edge) browser started")
don't work @When("(chrome|firefox|edge) browser started")
Also, I don't understand function of ^ char, because
don't work @When("^browser") => feature when browser started
working @When("^browser started") => feature when browser started
working @When("browser started") => feature when browser started
CodePudding user response:
Cucumber supports two types of expressions which are mutually exclusive:
- regular expressions (aka RegEx)
- Cucumber expressions
Cucumber distinguishes which sort of expressions you are using with checking "anchors" symbols which for RegEx have to be ^
at the start and $
at the end of the string.
So while the syntax in your first example is valid for RegEx, it is working. But if your expressions misses anchors (like in your second example) it is treated as "Cucumber Expression" where that (chrome|firefox|edge)
is not valid any more.
For cucumber expressions to work with your case you have to apply "Custom Pameter Types".
See details at cucumber github page.