CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-puppeteer

A high-level API to control headless Chrome over the DevTools Protocol

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

media-generation.mddocs/

Media Generation

Screenshot capture and PDF generation with extensive customization options for visual testing and documentation.

Capabilities

Screenshot Capture

Take screenshots of pages or specific elements.

/**
 * Take screenshot of page
 * @param options - Screenshot configuration
 * @returns Promise resolving to image buffer
 */
screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;

interface ScreenshotOptions {
  /** Path to save screenshot */
  path?: string;
  /** Image format */
  type?: "png" | "jpeg" | "webp";
  /** Image quality (0-100, JPEG only) */
  quality?: number;
  /** Capture full scrollable page */
  fullPage?: boolean;
  /** Clip to specific area */
  clip?: {x: number; y: number; width: number; height: number};
  /** Omit background (PNG only) */
  omitBackground?: boolean;
  /** Encoding format */
  encoding?: "base64" | "binary";
  /** Capture beyond viewport */
  captureBeyondViewport?: boolean;
  /** From surface (experimental) */
  fromSurface?: boolean;
}

Usage Examples:

// Basic screenshot
const buffer = await page.screenshot();

// Full page screenshot
await page.screenshot({
  path: "fullpage.png",
  fullPage: true
});

// Clipped screenshot
await page.screenshot({
  path: "section.png",
  clip: { x: 0, y: 0, width: 800, height: 600 }
});

// Base64 encoded
const base64 = await page.screenshot({
  encoding: "base64",
  type: "jpeg",
  quality: 80
});

PDF Generation

Generate PDF documents from pages.

/**
 * Generate PDF from page
 * @param options - PDF configuration
 * @returns Promise resolving to PDF buffer
 */
pdf(options?: PDFOptions): Promise<Uint8Array>;

interface PDFOptions {
  /** Path to save PDF */
  path?: string;
  /** Scale factor */
  scale?: number;
  /** Display header and footer */
  displayHeaderFooter?: boolean;
  /** Header template HTML */
  headerTemplate?: string;
  /** Footer template HTML */
  footerTemplate?: string;
  /** Print background graphics */
  printBackground?: boolean;
  /** Landscape orientation */
  landscape?: boolean;
  /** Page ranges to print */
  pageRanges?: string;
  /** Paper format */
  format?: "Letter" | "Legal" | "Tabloid" | "Ledger" | "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6";
  /** Paper width */
  width?: string | number;
  /** Paper height */
  height?: string | number;
  /** Page margins */
  margin?: {
    top?: string | number;
    right?: string | number;
    bottom?: string | number;
    left?: string | number;
  };
  /** Prefer CSS page size */
  preferCSSPageSize?: boolean;
  /** Generate tagged PDF */
  generateTaggedPDF?: boolean;
  /** Generate document outline */
  generateDocumentOutline?: boolean;
}

Usage Examples:

// Basic PDF
const pdfBuffer = await page.pdf();

// Configured PDF
await page.pdf({
  path: "document.pdf",
  format: "A4",
  printBackground: true,
  margin: {
    top: "1in",
    right: "1in",
    bottom: "1in",
    left: "1in"
  }
});

// With header/footer
await page.pdf({
  path: "report.pdf",
  displayHeaderFooter: true,
  headerTemplate: '<div style="font-size:10px;">Header</div>',
  footerTemplate: '<div style="font-size:10px;">Page <span class="pageNumber"></span></div>'
});

Screen Recording

Record page interactions as video.

/**
 * Start screen recording
 * @param options - Recording options
 */
screencast(options?: ScreencastOptions): Promise<void>;

interface ScreencastOptions {
  /** Path to save video */
  path?: string;
  /** Video format */
  format?: "webm";
  /** Video quality */
  quality?: number;
  /** Frame rate */
  fps?: number;
  /** Video scale */
  scale?: number;
  /** Crop area */
  crop?: {x: number; y: number; width: number; height: number};
}

Usage Examples:

// Start recording
await page.screencast({
  path: "recording.webm",
  fps: 25
});

// Perform actions
await page.goto("https://example.com");
await page.click("#button");

// Stop recording (implementation depends on browser)

Install with Tessl CLI

npx tessl i tessl/npm-puppeteer

docs

browser-management.md

device-emulation.md

element-handling.md

index.md

input-interaction.md

locators-waiting.md

media-generation.md

network-control.md

page-interaction.md

performance-debugging.md

tile.json