385d27d0cd
Bumps [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) from 7.0.1 to 8.0.0. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/davidtheclark/cosmiconfig/blob/main/CHANGELOG.md">cosmiconfig's changelog</a>.</em></p> <blockquote> <h2>8.0.0</h2> <p><strong>No major breaking changes!</strong> We dropped support for Node 10 and 12 -- which you're probably not using. And we swapped out the YAML parser -- which you probably won't notice.</p> <ul> <li><strong>Breaking change:</strong> Drop support for Node 10 and 12.</li> <li><strong>Breaking change:</strong> Use npm package <a href="https://www.npmjs.com/package/js-yaml">js-yaml</a> to parse YAML instead of npm package <a href="https://www.npmjs.com/package/yaml">yaml</a>.</li> <li>Added: Loader errors now include the path of the file that was tried to be loaded.</li> </ul> <h2>7.1.0</h2> <ul> <li>Added: Additional default <code>searchPlaces</code> within a .config subdirectory (without leading dot in the file name)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li>See full diff in <a href="https://github.com/davidtheclark/cosmiconfig/commits">compare view</a></li> </ul> </details> <details> <summary>Maintainer changes</summary> <p>This version was pushed to npm by <a href="https://www.npmjs.com/~d-fischer">d-fischer</a>, a new releaser for cosmiconfig since your current version.</p> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=cosmiconfig&package-manager=npm_and_yarn&previous-version=7.0.1&new-version=8.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
---|---|---|
.github | ||
.husky | ||
docker | ||
docs | ||
examples | ||
packages | ||
test | ||
test-d | ||
tools | ||
website | ||
.editorconfig | ||
.eslintignore | ||
.eslintplugin.js | ||
.eslintrc.js | ||
.eslintrc.types.cjs | ||
.gitattributes | ||
.gitignore | ||
.mocharc.cjs | ||
.npmrc | ||
.prettierignore | ||
.prettierrc.cjs | ||
.release-please-manifest.json | ||
commitlint.config.js | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
release-please-config.json | ||
tsconfig.base.json | ||
versions.js |
Puppeteer
Guides | API | FAQ | Contributing | Troubleshooting
Puppeteer is a Node.js library which provides a high-level API to control Chrome/Chromium over the DevTools Protocol. Puppeteer runs in headless mode by default, but can be configured to run in full (non-headless) Chrome/Chromium.
What can I do?
Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:
- Generate screenshots and PDFs of pages.
- Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).
- Automate form submission, UI testing, keyboard input, etc.
- Create an automated testing environment using the latest JavaScript and browser features.
- Capture a timeline trace of your site to help diagnose performance issues.
- Test Chrome Extensions.
Getting Started
Installation
To use Puppeteer in your project, run:
npm i puppeteer
# or `yarn add puppeteer`
# or `pnpm i puppeteer`
When you install Puppeteer, it automatically downloads a recent version of
Chromium (~170MB macOS, ~282MB Linux, ~280MB Windows) that is
guaranteed to work
with Puppeteer. For a version of Puppeteer without installation, see
puppeteer-core
.
Configuration
Puppeteer uses several defaults that can be customized through configuration files.
For example, to change the default cache directory Puppeteer uses to install
browsers, you can add a .puppeteerrc.cjs
(or puppeteer.config.cjs
) at the
root of your application with the contents
const {join} = require('path');
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
After adding the configuration file, you will need to remove and reinstall
puppeteer
for it to take effect.
See the configuration guide for more information.
puppeteer-core
Every release since v1.7.0 we publish two packages:
puppeteer
is a product for browser automation. When installed, it downloads
a version of Chromium, which it then drives using puppeteer-core
. Being an
end-user product, puppeteer
automates several workflows using reasonable
defaults that can be customized.
puppeteer-core
is a library to help drive anything that supports DevTools
protocol. Being a library, puppeteer-core
is fully driven through its
programmatic interface implying no defaults are assumed and puppeteer-core
will not download Chromium when installed.
You should use puppeteer-core
if you are
connecting to a remote browser
or managing browsers yourself.
If you are managing browsers yourself, you will need to call
puppeteer.launch
with
an an explicit
executablePath
(or channel
if it's
installed in a standard location).
When using puppeteer-core
, remember to change the import:
import puppeteer from 'puppeteer-core';
Usage
Puppeteer follows the latest maintenance LTS version of Node.
Puppeteer will be familiar to people using other browser testing frameworks. You launch/connect a browser, create some pages, and then manipulate them with Puppeteer's API.
For more in-depth usage, check our guides and examples.
Example
The following example searches developers.google.com/web for articles tagged "Headless Chrome" and scrape results from the results page.
import puppeteer from 'puppeteer';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://developers.google.com/web/');
// Type into search box.
await page.type('.devsite-search-field', 'Headless Chrome');
// Wait for suggest overlay to appear and click "show all results".
const allResultsSelector = '.devsite-suggest-all-results';
await page.waitForSelector(allResultsSelector);
await page.click(allResultsSelector);
// Wait for the results page to load and display the results.
const resultsSelector = '.gsc-results .gs-title';
await page.waitForSelector(resultsSelector);
// Extract the results from the page.
const links = await page.evaluate(resultsSelector => {
return [...document.querySelectorAll(resultsSelector)].map(anchor => {
const title = anchor.textContent.split('|')[0].trim();
return `${title} - ${anchor.href}`;
});
}, resultsSelector);
// Print all the files.
console.log(links.join('\n'));
await browser.close();
})();
Default runtime settings
1. Uses Headless mode
Puppeteer launches Chromium in
headless mode.
To launch a full version of Chromium, set the
headless
option when launching a browser:
const browser = await puppeteer.launch({headless: false}); // default is true
2. Runs a bundled version of Chromium
By default, Puppeteer downloads and uses a specific version of Chromium so its
API is guaranteed to work out of the box. To use Puppeteer with a different
version of Chrome or Chromium, pass in the executable's path when creating a
Browser
instance:
const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});
You can also use Puppeteer with Firefox Nightly (experimental support). See
Puppeteer.launch
for
more information.
See
this article
for a description of the differences between Chromium and Chrome.
This article
describes some differences for Linux users.
3. Creates a fresh user profile
Puppeteer creates its own browser user profile which it cleans up on every run.
Using Docker
See our Docker guide.
Using Chrome Extensions
See our Chrome extensions guide.
Resources
Contributing
Check out our contributing guide to get an overview of Puppeteer development.