I'm writing pytest-bdd + selenium + allure tests. And i need to attach screenshot to each verification step - @then("..."). Pytest bdd have "after step" hook which i implemented like this:
def pytest_bdd_after_step(request, feature, scenario, step, step_func, step_func_args):
if step.keyword == 'Then':
driver = request.getfixturevalue('driver')
allure.attach(driver.get_screenshot_as_png(), name='screenshot',
attachment_type=allure.attachment_type.PNG)
It works fine, but the screenshot appeared AFTER all steps in the report and not inside the step:
So my question is: is it possible to attach something to the step itself in "before/after" hooks? Thanks.