allure-python icon indicating copy to clipboard operation
allure-python copied to clipboard

PNG attachment not displayed in allure reports - allure behave

Open YenikeRaghuRam opened this issue 3 years ago • 4 comments

PNG attachment not displayed in allure reports - allure behave

import allure from allure_commons.types import AttachmentType

allure.attach("Capture.PNG", name="ScreenshotPNG", attachment_type=AttachmentType.PNG)

One

Screenshot not displayed in allure reports

environment:

  • allure behave - 2.9.45
  • framework behave - 1.2.6

YenikeRaghuRam avatar Mar 10 '22 07:03 YenikeRaghuRam

@YenikeRaghuRam I am facing the same issue, have you managed to find any solution/workaround?

bwomsm1 avatar May 02 '22 07:05 bwomsm1

@bwomsm1

I got solution to it allure.attach accepts bytes as argument so convert .png to bytes array and pass is an argument below is code in python

    with open(os.getcwd().split("Path../Pywinauto.png",
              "rb") as image:
        f = image.read()
        b = bytearray(f)
    allure.attach(b,
                  name="ScreenshotPNG", attachment_type=AttachmentType.PNG)

YenikeRaghuRam avatar May 02 '22 08:05 YenikeRaghuRam

@bwomsm1

I got solution to it allure.attach accepts bytes as argument so convert .png to bytes array and pass is an argument below is code in python

    with open(os.getcwd().split("Path../Pywinauto.png",
              "rb") as image:
        f = image.read()
        b = bytearray(f)
    allure.attach(b,
                  name="ScreenshotPNG", attachment_type=AttachmentType.PNG)

Thanks @YenikeRaghuRam that idea solved my problem.

bwomsm1 avatar May 02 '22 15:05 bwomsm1

It is working for me in allure python

allure.attach.file(screenshot_path, name="screenshot", attachment_type=allure.attachment_type.PNG)

vivekvasu95 avatar Jul 14 '22 06:07 vivekvasu95