1

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:

Allure report: screenshots appeared after all steps

So my question is: is it possible to attach something to the step itself in "before/after" hooks? Thanks.

  • I'm afraid this is not possible. I also was trying to do something similar in Java but Allure documentation is poor about this topic. Each attachment regardless type is always added at the end of test body. – Omeniq Feb 21 '20 at 14:07
  • I had the same problem. I think this will help you: https://stackoverflow.com/questions/58728908/is-it-possible-to-have-screenshots-of-allure-report-between-steps-like-extent-re – 0xM4x Feb 21 '20 at 15:39
  • @M3trix, Greg Burghardt, yes, this approach will work. And actually i think this is only solution, unfortunately. – Aleksandr Artemov Feb 27 '20 at 14:46

0 Answers0