Staulik
Staulik

Reputation: 89

Include screenshots in report test steps with playwright

Friends, does anyone have the code that allows me to include the screenshots in the line I want and make this print be attached to the standard playwright report?

I'm using playwright with javascriptenter image description here npx plawright show-report

Upvotes: 6

Views: 9612

Answers (1)

itronic1990
itronic1990

Reputation: 1441

You can use page.screenshot() to capture the screenshot and use attach() to attach the captured screenshot, then report like this:

const screenshot = await page.screenshot();
await testInfo.attach('screenshot', { body: screenshot, contentType: 'image/png' });

Upvotes: 18

Related Questions