Playwright · Junior · Question 52 of 75

How do you take a screenshot of the page?

Show the answer

Correct answer: await page.screenshot({ path: 'home.png' })

Explanation

Screenshots can be full page (fullPage: true) or of one element via locator.screenshot(). For automatic screenshots on failure, use the screenshot option.

Further reading

Problem with a question

Playwright · Junior · question 52

Test yourself

Take the Playwright · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz