LinuxCommandLibrary

puppeteer

Browser automation and testing library

TLDR

Install Puppeteer

$ npm install puppeteer
copy
Run Puppeteer script
$ node [script.js]
copy
Install without bundled Chrome
$ npm install puppeteer-core
copy

SYNOPSIS

puppeteer JavaScript library for browser automation

DESCRIPTION

Puppeteer is a Node.js library for controlling Chrome/Chromium. It provides a high-level API for headless browser automation, testing, screenshot capture, and PDF generation.

EXAMPLES

$ // Generate PDF
await page.pdf({path: 'page.pdf', format: 'A4'});

// Click element
await page.click('#submit');

// Type text
await page.type('#search', 'query');

// Wait for selector
await page.waitForSelector('.result');

// Evaluate in page context
const title = await page.evaluate(() => document.title);

// Headful mode
const browser = await puppeteer.launch({headless: false});
copy

BASIC SCRIPT

$ const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});
  await browser.close();
})();
copy

COMMON OPTIONS

$ puppeteer.launch({
  headless: true,
  slowMo: 100,           // Slow down
  args: ['--no-sandbox'],
  executablePath: '/path/to/chrome'
});
copy

CAVEATS

Downloads Chromium by default (~150MB). Use puppeteer-core with own browser. Memory-intensive.

HISTORY

Puppeteer was developed by the Google Chrome DevTools team, released in 2017 as the official Node.js library for Chrome automation.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community