     [Answers](https://scrapfly.io/blog)   /  [playwright](https://scrapfly.io/blog/tag/playwright)   /  [How to take a screenshot with Playwright?](https://scrapfly.io/blog/answers/how-to-take-screenshot-with-playwright)   # How to take a screenshot with Playwright?

 by [Bernardas Alisauskas](https://scrapfly.io/blog/author/bernardas) Dec 05, 2022 1 min read [\#playwright](https://scrapfly.io/blog/tag/playwright) [\#python](https://scrapfly.io/blog/tag/python) 

 [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright "Share on LinkedIn")    

 

 

When web scraping, we might want to collect page screenshots or peek into what our headless browsers are seeing for debugging. In Playwright a screenshot can be taken using the `screenshot()` method of `page` or

python```python
from pathlib import Path
from playwright.sync_api import sync_playwright

with sync_playwright() as pw:
    browser = pw.chromium.launch(headless=False)

    # To save cookies to a file first extract them from the browser context:
    context = browser.new_context(viewport={"width": 1920, "height": 1080})
    page = context.new_page()
    page.goto('https://httpbin.dev/html')
    image_bytes = page.screenshot(
        full_page=True,   # this will try to scroll to capture full page
        path='screenshot.png',  # this will save the screenshot directly to a file
        clip={"x": 0, "y": 0, "width": 100, "height": 100},  # this will clip the screenshot to a specific region
    )
    # or we can save it manually
    Path("screenshot.png").write_bytes(image_bytes)

    # we can also take a screenshot of an element
    element = page.locator('p')
    image_bytes = element.screenshot(path='screenshot.png')

```



⚠ Note that when scraping dynamic web pages, screenshots could be captured before the page is fully loaded. For more see [How to wait for page to load in Playwright?](https://scrapfly.io/blog/answers/how-to-wait-for-page-to-load-in-playwright)

For capturing screenshots at scale, consider a cloud [Screenshot API](https://scrapfly.io/screenshot-api). Compare options in our [best screenshot API guide](https://scrapfly.io/blog/posts/what-is-the-best-screenshot-api).



 

    



Scale Your Web Scraping

Anti-bot bypass, browser rendering, and rotating proxies, all in one API. Start with 1,000 free credits.

  No credit card required  1,000 free API credits  Anti-bot bypass included 

 [Start Free](https://scrapfly.io/register) [View Docs](https://scrapfly.io/docs/onboarding) 

 Not ready? Get our newsletter instead. 

 

## Explore this Article with AI

 [ ChatGPT ](https://chat.openai.com/?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright) [ Gemini ](https://www.google.com/search?udm=50&aep=11&q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright) [ Grok ](https://x.com/i/grok?text=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright) [ Perplexity ](https://www.perplexity.ai/search/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright) [ Claude ](https://claude.ai/new?q=Summarize%20this%20page%3A%20https%3A%2F%2Fscrapfly.io%2Fblog%2Fanswers%2Fhow-to-take-screenshot-with-playwright) 



 ## Related Articles

 [  

 python headless-browser 

### How To Take Screenshots In Python?

Learn how to take Python screenshots through Selenium and Playwright, including common browser tips and tricks for custo...

 

 ](https://scrapfly.io/blog/posts/how-to-take-screenshots-in-python) [     

 python screenshots 

### How to Track Web Page Changes with Automated Screenshots

There are many different ways to monitor web page changes and one of the most popular techniques is screenshot tracking....

 

 ](https://scrapfly.io/blog/posts/how-to-track-web-page-changes-using-automated-screenshots) [  

 screenshots 

### How to Automate Website Screenshots with Python &amp; JavaScript

Learn how to automate Chrome screenshots with Playwright, Selenium, Puppeteer, browser commands, extensions, and APIs fo...

 

 ](https://scrapfly.io/blog/posts/how-to-automate-chrome-screenshots) 

  ## Related Questions

- [ Q How to take a screenshot with Selenium? ](https://scrapfly.io/blog/answers/how-to-take-screenshot-with-selenium)
- [ Q How to check if element exists in Playwright? ](https://scrapfly.io/blog/answers/how-to-check-for-element-in-playwright)
- [ Q How to capture background requests and responses in Playwright? ](https://scrapfly.io/blog/answers/how-to-capture-xhr-requests-playwright)
- [ Q How to find elements by CSS selectors in Playwright? ](https://scrapfly.io/blog/answers/how-to-find-elements-by-css-selectors-in-playwright)
 
  



   



 Run headless browsers at scale, **1,000 free credits** [Start Free](https://scrapfly.io/register)