Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I add an image to an Allure report with addattachment on JS?

I’m trying to add the screenshots to my allure reports between steps, but in my case is that the test cases are manually created from the IDE with Allure TestOps plugin. How do I modify this code to use the existing screenshots (eg uploaded to the GH repo) just to display it in the allure report and not to take screenshots?

const png = await browser.takeScreenshot() allure.createAttachment('screenshot',new Buffer(png,'base64'),'image/png')

I tried to use
const img = new image();
img.src = …
but it doesn’t work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

May be this can help

// Import the fs module to read the file
const fs = require("fs");

// Read the file into a Buffer object
const screenshotBuffer = fs.readFileSync("path/to/screenshot.png");

// Add the screenshot to the Allure report
allure.createAttachment("screenshot", screenshotBuffer, "image/png");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading