To use Puppeteer in your project, run: npm i puppeteer# or “yarn add puppeteer”
Note: When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win), a guaranteed API fit.
Puppeteer looks for certain environment variables to aid its operations. If Puppeteer doesn’t find them in the environment during the installation step, a lower cased variant of these variables will be used from the npm config.
- HTTP_PROXY, HTTPS_PROXY, NO_PROXY – Use this to define HTTP proxy settings and to download & run Chromium
- PUPPETEER_SKIP_CHROMIUM_DOWNLOAD – Do not download bundled Chromium during installation step
- PUPPETEER_DOWNLOAD_HOST – Overwrite URL prefix used to download Chromium Note: this includes protocol and might even include path prefix. Defaults to https://storage.googleapis.com.
- PUPPETEER_CHROMIUM_REVISION – Specify a certain version of Chromium you’d like Puppeteer to use.
- PUPPETEER_EXECUTABLE_PATH – Specify an executable path to be used in puppeteer.launch. See puppeteer.launch([options]) on how the executable path is inferred. BEWARE: Puppeteer is only guaranteed to work with the bundled Chromium, use at your own risk.
Since version 1.7.0, we publish the puppeteer-core package, a version of Puppeteer that does not download Chromium by default.
npm i puppeteer-core# or “yarn add puppeteer-core”
Puppeteer-core is intended to be a lightweight version of Puppeteer. You can use it either to launch an existing browser installation or to connect to a remote one. It is important to check that the version of puppeteer-core you install is compatible with the browser you intend to connect.
What are the Features?
While Puppeteer’s ability to launch a headless browser is one feature that has gained it some fame, that is not the only feature which makes it awesome. Puppeteer has a couple of other features that make it useful, let’s take a quick look at some of them.
While there are other tools that can be used for web automation, Puppeteer comes out on top. This is because it works best for one browser only – the Headless Chrome browser, therefore it carries out web automation tasks in the most efficient way possible. Puppeteer is also compatible with popular unit testing libraries such as Mocha and Jasmine.
This is a vital feature for any automated web testing task. Screenshots help keep track of the result of interactions with elements on a web page. Libraries such as Puppeteer-screenshot tester also exist in Puppeteer that allow the comparing of screenshots generated while testing. Besides generating test screenshots, Puppeteer can also help generate PDFs from tested web pages.
Chrome provides DevTools that allows the recording of the Performance Timeline of web pages, and Puppeteer takes advantage of this too. With Puppeteer, timeline traces of websites can be captured to examine performance issues. Due to the Puppeteer’s high-level API control over Chrome Developers Tools Protocol, it gives users the ability to control service workers and test caching of websites.
Puppeteer is the start of a new era in Automated Testing. The success of Puppeteer with Chrome cannot be reduced only to its efficiency; the fact that it is Google-backed is also the reason why it has been accepted and recognized globally. Additionally, this software offers a high-level API to control the Chrome browser via the DevTools protocol. Leveraging Puppeteer for automation, we can develop solutions to solve problems, whether it is for quality assurance, productivity enhancements or data aggregation.
The foundation of success in today’s digital world lies in successful adoption of agile principles and DevOps processes, which are in turn dependent on faster and reliable feedback from testing pipeline. At Nitor, we have helped clients achieve success in continuous testing through 70% of automation using Puppeteer.
To know more about Puppeteer based testing please contact firstname.lastname@example.org.
Anup is an accomplished Tech-Functional Manager with 13+ years of experience and proven expertise in software design, development and testing on various technology platforms and business domains.
- Big Data