posts in
What is Puppeteer?

Straight from the official documentation:

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.

Let's break that down:

Navigating & waiting

Every useful script that we will write will almost certainly do three key things:

  1. Navigating to some web page
  2. Waiting for something
  3. Possibly getting a timeout 😐

Both frameworks handle these scenarios in very similar ways but Playwright explicitly differentiates itself from Puppeteer by having a "built in" waiting mechanism that covers a lot of common scenarios.

Initial navigation to any page is pretty much the same for both frameworks and can happen in multiple ways.

  • Whenever your code does a page.goto(), or a page.click() on a link, you explicitly trigger a navigation.
  • The webpage you are on can also trigger a navigation by executing location.href= 'https://example.com' or using the history.pushState() API.

In the example below we trigger two navigations:

  1. The initial load of the page.
  2. A navigation to the shopping cart by clicking a link