Puppeteer is a Node library that 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.
To be able to start working with Puppeteer you need to install it first.
therefore you will need to make sure you already have installed on your computer:
IDE – my recommendation is VS Code (Visual Studio Code) it is free, you can download it from this link.
With the IDE you will write your Puppeteer Code.
Node.js – to be able to use NPM (node package manager) you can download it from this link.
I recommend installing the recommended version.
After you installed your favorite IDE and the node.js you can open the IDE
(for the demo I will use VScode).
Create a new folder anywhere you want to save your project.
Open the VScode and press In the top menu navigation press on the file tab -> open -> select your folder.
In the top menu navigation press on the Terminal tab -> New Terminal button
Now the screen split and we can start type in our new terminal.
The first command will be:
The “npm init” command will initialize a project and create the package.json file
Press enter until it will ask you Is this Ok? – type yes and enter
Then we will type:
The npm install downloads a package and all its dependencies.
For the last step type:
npm i puppeteer
This command will install Puppeteer locally as a dev dependency for your project.
Now you should be able to see that under your folder you now have the node_module, package-lock.json and package.json files.
Now you have Puppeteer installed on your local computer and you can start writing your first automation test.
Next Article – Puppeteer Tutorial | How To Run Your First Puppeteer Test
For all Puppeteer articles click here