> For the complete documentation index, see [llms.txt](https://testingvn.gitbook.io/playwright/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testingvn.gitbook.io/playwright/take-screenshot.md).

# Take Screenshot

```typescript
// Take a screenshot of the full page
await page.screenshot({ path: 'screenshot.png', fullPage: true });

// Take a screenshot of a specific element
await page.locator('.element').screenshot({ path: 'element.png' });

// Take a screenshot on test failure
test('visual test', async ({ page }) => {
  await page.goto('https://example.com' );
  try {
    await expect(page.locator('h1')).toHaveText('Expected Text');
  } catch (error) {
    await page.screenshot({ path: `failure-${test.info().title}.png` });
    throw error;
  }
});

```
