pytest-dev / pytest-bdd

BDD library for the py.test runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.3k stars 219 forks source link

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

Open marcinosb opened 10 months ago

marcinosb commented 10 months ago

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

youtux commented 10 months ago

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

kotavi commented 7 months ago

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?

youtux commented 7 months ago

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

kotavi commented 7 months ago

@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

youtux commented 7 months ago

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

kotavi commented 6 months ago

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