Core Concepts

1. Browser and Page

At the heart of Puppeteer lies the concept of a browser and a page. The browser represents the Chrome or Chromium instance controlled by Puppeteer, while the page represents a single tab within that browser instance. Think of the browser as your window to the internet, and each page as a separate document or website within that window.

2. Selectors

Selectors are a fundamental aspect of web automation, allowing you to pinpoint and interact with specific elements on a web page. Puppeteer leverages various types of selectors, including:

  • CSS Selectors: Utilize CSS syntax to target elements based on their attributes, classes, or relationships with other elements.
  • XPath Selectors: Employ XPath expressions to locate elements by their position in the HTML document tree.
  • DOM Selectors: Interact with elements using their unique IDs, names, or other properties within the Document Object Model (DOM).

Understanding selectors is crucial for navigating and manipulating web pages effectively with Puppeteer. They serve as the building blocks for automating interactions such as clicking buttons, inputting text, or extracting data from specific elements.