how can we get scenario name in pytest-bdd with pytest_bdd_before_scenario

432 Views Asked by At

unable to find scenario name

@sanity
    Scenario Outline: B) Change User Name and validate message Master Credentials
      Given the case is "<case>"

output:

scenario : B) Change User Name and validate message Master Credentials
1

There are 1 best solutions below

0
On
 def pytest_bdd_before_scenario(request, scenario):
     print(f'SCENARIO: {str(scenario.name)}')

same as for pytest_bdd_after_scenario

 def pytest_bdd_after_scenario(request, scenario):
     print(f'SCENARIO: {str(scenario.name)}')