PageSourceSearch

https://playwright.dev/assets/js/70866c66.d551d822.js

js playwright.dev collected 2026-09-24 06:53:31 UTC 6,212 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkplaywright_dev=self.webpackChunkplaywright_dev||[]).push([["1138"],{83560(e,s,n){n.r(s),n.d(s,{metadata:()=>t,default:()=>o,frontMatter:()=>c,contentTitle:()=>l,toc:()=>d,assets:()=>h});var t=JSON.parse('{"id":"commands/screenshots-pdf","title":"Screenshots & PDF","description":"Screenshots","source":"@site/agent-cli/commands/screenshots-pdf.mdx","sourceDirName":"commands","slug":"/commands/screenshots-pdf","permalink":"/agent-cli/commands/screenshots-pdf","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{"title":"Screenshots & PDF"},"sidebar":"agentCli","previous":{"title":"Console & Eval","permalink":"/agent-cli/commands/console-eval"},"next":{"title":"Codegen & Highlighting","permalink":"/agent-cli/commands/codegen"}}'),i=n(74848),r=n(28453);let c={title:"Screenshots & PDF"},l="Screenshots & PDF",h={},d=[{value:"Screenshots",id:"screenshots",level:2},{value:"PDF export",id:"pdf-export",level:2},{value:"When to use screenshots",id:"when-to-use-screenshots",level:2},{value:"Snapshots",id:"snapshots",level:2}];function a(e){let s={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.header,{children:(0,i.jsx)(s.h1,{id:"screenshots--pdf",children:"Screenshots & PDF"})}),"\n",(0,i.jsx)(s.h2,{id:"screenshots",children:"Screenshots"}),"\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{children:"Command"}),(0,i.jsx)(s.th,{children:"Description"})]})}),(0,i.jsxs)(s.tbody,{children:[(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot"})}),(0,i.jsx)(s.td,{children:"Screenshot of the viewport"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot [target]"})}),(0,i.jsx)(s.td,{children:"Screenshot of a specific element"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot --filename=<f>"})}),(0,i.jsx)(s.td,{children:"Save with a custom filename"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot --type=<png|jpeg|webp>"})}),(0,i.jsx)(s.td,{children:"Image format"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot --full-page"})}),(0,i.jsx)(s.td,{children:"Full scrollable page instead of the viewport"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:(0,i.jsx)(s.code,{children:"screenshot --hires"})}),(0,i.jsx)(s.td,{children:"Capture device pixels instead of CSS pixels"})]})]})]}),"\n",(0,i.jsxs)(s.p,{children:["Without ",(0,i.jsx)(s.code,{children:"--filename"}),", the file is named ",(0,i.jsx)(s.code,{children:"page-{timestamp}.{png|jpeg|webp}"})," in the output directory.\nThe format is inferred from the filename extension when ",(0,i.jsx)(s.code,{children:"--type"})," is not given, and defaults to PNG."]}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-bash",children:"$ playwright-cli screenshot\n# Screenshot saved to .playwright-cli/page-2026-03-15T10-22-01-118Z.png\n\n$ playwright-cli screenshot e15\n# Screenshot of element e15\n\n$ playwright-cli screenshot --filename=login-page.png\n$ playwright-cli screenshot --full-page --filename=full-page.png\n$ playwright-cli screenshot --filename=preview.jpeg\n$ playwright-cli screenshot --hires --filename=retina.png\n"})}),"\n",(0,i.jsxs)(s.p,{children:[(0,i.jsx)(s.code,{children:"--hires"})," accounts for the device pixel ratio, which makes text legible in a captured design\nreview \u2014 but its pixel coordinates no longer line up with the CSS-pixel coordinates that\n",(0,i.jsx)(s.a,{href:"/agent-cli/commands/keyboard-mouse",children:"mouse commands"})," take."]}),"\n",(0,i.jsx)(s.h2,{id:"pdf-export",children:"PDF export"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-bash",children:"playwright-cli pdf                      # save as page-{timestamp}.pdf\nplaywright-cli pdf --filename=page.pdf  # save with custom name\n"})}),"\n",(0,i.jsx)(s.h2,{id:"when-to-use-screenshots",children:"When to use screenshots"}),"\n",(0,i.jsx)(s.p,{children:"Screenshots complement accessibility snapshots:"}),"\n",(0,i.jsxs)(s.table,{children:[(0,i.jsx)(s.thead,{children:(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.th,{children:"Use case"}),(0,i.jsx)(s.th,{children:"Best tool"})]})}),(0,i.jsxs)(s.tbody,{children:[(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Interacting with elements"}),(0,i.jsx)(s.td,{children:"Accessibility snapshot (refs)"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Verifying visual layout"}),(0,i.jsx)(s.td,{children:"Screenshot"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Canvas/chart content"}),(0,i.jsx)(s.td,{children:"Screenshot"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Documenting a bug"}),(0,i.jsx)(s.td,{children:"Screenshot"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Understanding page structure"}),(0,i.jsx)(s.td,{children:"Accessibility snapshot"})]}),(0,i.jsxs)(s.tr,{children:[(0,i.jsx)(s.td,{children:"Reading text content"}),(0,i.jsx)(s.td,{children:"Accessibility snapshot"})]})]})]}),"\n",(0,i.jsx)(s.h2,{id:"snapshots",children:"Snapshots"}),"\n",(0,i.jsx)(s.p,{children:"For accessibility tree output (not a visual capture):"}),"\n",(0,i.jsx)(s.pre,{children:(0,i.jsx)(s.code,{className:"language-bash",children:'playwright-cli snapshot                 # full page snapshot\nplaywright-cli snapshot --filename=f    # custom filename\nplaywright-cli snapshot [target]        # element snapshot\nplaywright-cli snapshot --depth=N       # limit depth\nplaywright-cli snapshot --boxes         # include bounding boxes\nplaywright-cli find "text"              # search instead of capturing\n'})}),"\n",(0,i.jsxs)(s.p,{children:["See ",(0,i.jsx)(s.a,{href:"/agent-cli/snapshots",children:"Snapshots"})," for details on the format and usage."]})]})}function o(e={}){let{wrapper:s}={...(0,r.R)(),...e.components};return s?(0,i.jsx)(s,{...e,children:(0,i.jsx)(a,{...e})}):a(e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.