pytest-bdd icon indicating copy to clipboard operation
pytest-bdd copied to clipboard

Step definition is not found when using Scenario Outline and "/" characters in the Examples

Open marcinosb opened this issue 1 year ago • 6 comments

Hello,

pytest-bdd: 7.0.0

I am having a simple Scenario Outline which is using table like this:

        | Popup    | Country  | Site                             | Locator                       |
        | False      | US           | https://my-site.com  | <selenium_locator>  |

In this case I am getting everytime: pytest_bdd.exceptions.StepDefinitionNotFoundError exception. Removing // from the https://my-site.com seems to help and the step works perfectly fine in that case.

Are there any characters that are not allowed to be used in the Scenario Outline examples?

Thanks! Marcin

marcinosb avatar Nov 24 '23 08:11 marcinosb

interesting, this seems a bug indeed, I'll have a look

youtux avatar Dec 02 '23 20:12 youtux

I have similar issue but with "#". I'm validating a text on the screen

And User verifies that "UP/DN NX/PR #JMP Add Brkup Del Edit  [1]" is on line "7" on the screen

@given(parsers.cfparse('User verifies that "{text}" is on line "{line}" on the screen'))

But I get

E           KeyError: 'pytestbdd_then_User verifies that "UP/DN NX/PR'

..\..\sepac-pytest-bdd-autotests\venv\lib\site-packages\_pytest\fixtures.py:599: KeyError

any suggestions?

kotavi avatar Feb 28 '24 15:02 kotavi

@kotavi that happens because pytest-bdd treats everything after # as comment (like in python). That's unrelated to the original issue

youtux avatar Mar 01 '24 08:03 youtux

@youtux is there an existing issue for this or should I create a new one? "#" should be accepted as a part of the input in the step definition

kotavi avatar Mar 01 '24 14:03 kotavi

Did you try escaping it with a backslash, like \#?

youtux avatar Mar 02 '24 09:03 youtux

when I do '#' it's treated as a string with '', so I just added a workaround in the step definition code.

kotavi avatar Mar 05 '24 15:03 kotavi