Cannot create a new step, similar to an existing step
This is my existing step syntax:
Then The field labelled '(.*)' includes these dropdown values '(.*)'
I want to create a new step that reads like this:
Then The field labelled '(.*)' at position '(.*)' includes these dropdown values '(.*)'
Everything in bold is a variable/input
However the step looks like this in Visual Studio:
Then The field labelled '(.*)' at position '(.*)' includes these dropdown values '(.*)'
I have tried closing VS and deleting the specflow*.cache file in %TEMP%
I have tried cleaning & rebuilding my solution
I have tried rewording the step, like this:
Then The field labelled '(.*)' includes these dropdown values '(.*)' at position '(.*)'
Is this resolvable, if so how?
-
Hello,
My knowledge of regex is a bit hazy but I believe the problem is that (.*) will capture as many characters as it can (it is greedy).
I find regex101 to be very helpful when trying to troubleshoot these issues.
Here is the starting point:
We can see the problem you described above. Any time you try to use either of the new steps the text will be matched by the regex of your existing step and SpecFlow will invoke your original step with 2 parameters rather than one of the new steps with 3 parameters.
.* is going to match any character (including apostrophes) 0 or more times, and capture as many characters as it can. This is why the following gets matched by one of the two capturing groups: 'foo' at position 'bar'.
We can change the capturing group to match any character other than apostrophes 0 or more times:
I think that might work although I haven't tried in SpecFlow.
Another option I thought might work is to try is changing the capturing group to (.*?). The question mark at the end makes the group lazy. This means the fewest number of characters will be matched.
0 -
Thankyou for the response and suggestions. Very Helpful.
I will investigate that.
I'm sure I'm not the only one who has encountered this issue.
0
Please sign in to leave a comment.
Comments
2 comments