DEV Community

Kayode
Kayode

Posted on β€’ Originally published at blog.zt4ff.dev on

1 1 1 1 1

Playwright Tutorial for Beginners 8 - Screenshots

To screenshot, make use of page.screenshot({ path: 'screenshot/screenshot.png' })

Full page screenshots

Full page screenshot is a screenshot of a full scrollable page, as if you had a very tall screen and the page could fit it entirely.

await page.screenshot({ path: 'screenshot.png', fullPage: true });

Enter fullscreen mode Exit fullscreen mode

Element screenshots

You can also take screenshots of elements too:

await page.locator('.header').screenshot({ path: 'screenshot.png' });

Enter fullscreen mode Exit fullscreen mode

An example

const { test } = require('@playwright/test');

test('Demo video', async ({ page }) => {
  await page.goto('https://playwright.dev');
  await page.screenshot({ path: 'screenshot.png' });
});

Enter fullscreen mode Exit fullscreen mode

screenshot.png

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay