Puppeteer provides a high-level API to control Chrome or Firefox over the DevTools Protocol or WebDriver BiDi, enabling browser automation for tasks like testing, scraping, and PDF generation. It runs headless by default but can be configured for full UI. The current stable version is 24.41.0. Releases are frequent, often several times a month, typically synchronizing with new Chrome and Firefox browser versions.
npm install puppeteerVerified import paths — ran on the pinned version, not inferred.
This example launches a headless Chrome browser, navigates to a URL, interacts with elements using Puppeteer's custom selectors, extracts text content, and then closes the browser.
Install `puppeteer-core` instead: `npm i puppeteer-core`. You will then need to provide the `executablePath` option to `puppeteer.launch()`.
Upgrade your Node.js environment to version 18 or newer. Use a Node.js version manager like nvm (Node Version Manager) for easy switching.
Add `--no-sandbox` to the `args` array in `puppeteer.launch()`: `puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] })`. For production, investigate a more secure sandboxing configuration for your environment.Regularly update your Puppeteer package (`npm update puppeteer`) to ensure compatibility with the browser it launches. If using `puppeteer-core` with an external browser, ensure that browser is also up-to-date.
While powerful, consider supplementing custom selectors with standard CSS selectors (`page.locator('div.my-class')`) or `page.$eval()` for robust and widely understood element selection, especially for stable UI components.If using `puppeteer`, try reinstalling it to redownload the browser (`npm install puppeteer`). If using `puppeteer-core`, you must specify the `executablePath` in `puppeteer.launch()` to point to your browser binary.
Ensure that `browser.close()` or `page.close()` is called only after all necessary operations on that context are complete. Check for asynchronous operations that might complete after a page or browser is closed.
Increase the timeout for the specific navigation call (`await page.goto(url, { timeout: 60000 });`) or globally (`page.setDefaultNavigationTimeout(60000);`). Ensure the network and server are responsive.After any significant page navigation or DOM manipulation, re-select elements and obtain new `ElementHandle`s rather than reusing old ones. Ensure your element references are always fresh.
Upgrade your Node.js version to 18 or higher. You can use tools like `nvm install 18` and `nvm use 18`.
No dependency data recorded yet.