Puppeteer is it only used for chrome browser?

Viewed 2129

Puppeteer is it only used with chrome browser ? what about the others ?

2 Answers

As iamdlm pointed Firefox is also available in puppeteer.

If you are looking for a similar browser automation API that supports more than puppeteer there is also Playwright from Microsoft.

The core API matches puppeteer's in 90% and there are more browser testing targeted methods additionally. The reason they are this similar: it is written by the ex-puppeteer team (after they moved to Microsoft from Google).

It supports:

  • Chrome/Chromium (+ Edge, Opera, Chromium-based browsers)
  • Firefox
  • Webkit (Safari)

Their Firefox and Webkit use so-called "jugglers" - patched binaries of the original browsers. (Puppeteer's Firefox implementation is different, it is communicating to a real Firefox Nightly binary)

Example of browser usage in Playwright:

// @ts-check
const playwright = require('playwright');

(async () => {
  // Try to add 'firefox' to the list ↓
  for (const browserType of ['chromium', 'webkit']) {
    /** @type {import('playwright').Browser} */
    const browser = await playwright[browserType].launch();
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('http://whatsmyuseragent.org/');
    await page.screenshot({ path: `example-${browserType}.png` });
    await browser.close();
  }
})();

source: try.playwright.tech

Related