Skip to main content
Capture a screenshot with Playwright’s page.screenshot() and upload it with uploadFileToS3 (TypeScript) or upload_file_to_s3 (Python).
TypeScript
import { BrowserContext, Page } from "playwright-core";
import { uploadFileToS3 } from "@intuned/browser"

export default async function handler(
  params: any,
  page: Page,
  context: BrowserContext
) {
  await page.goto("https://www.example.com")

  // Capture screenshot as bytes
  const screenshotInBytes = await page.screenshot()

  // Upload to S3
  const uploadedFile = await uploadFileToS3({
    file: screenshotInBytes,
    fileNameOverride: "screenshot.png",
    contentType: "image/png"
  })

  // Get signed URL for access
  const signedUrl = await uploadedFile.getSignedUrl()
  console.log(
    `check here to see the screenshot: \x1b[1;4;36m\x1b]8;;${signedUrl}\x1b\\Click here\x1b]8;;\x1b\\\x1b[0m \n`
  )
  return uploadedFile
}