How to add a screenshot to allure report with python?
For allure 2
from allure_commons.types import AttachmentType
allure.attach(driver.get_screenshot_as_png(), name="Screenshot", attachment_type=AttachmentType.PNG)
Instead of setting the type
as a string png
, you need to use allure
module attachment type constant, which is an Enum
with extension
attribute defined:
from allure.constants import AttachmentType
allure.attach('screenshot', driver.get_screenshot_as_png(), type=AttachmentType.PNG)