Puppeteer tutorial || Web automation with Puppeteer and Nodejs

Puppeteer is a node library that is used to control the Chrome browser. In this Puppeteer tutorial, we will see What is puppeteer and how to perform a web automation with puppeteer and node.js.

What is Puppeteer?

As I said, Puppeteer is a node library that is used to handle the Chromium and Chrome. Puppeteer supports headless automation by default and we can perform many operations with puppeteer like take a screenshot, Get the PDF, etc. Let’s see all the features of the puppeteer in detail.

Features of Puppeteer

  • Web Automation like UI testing, Input form submission, Keyboard input, button click, etc.
  • Puppeteer helps to generate the screenshot and PDF of the page.
  • Puppeteer always run the script directly in the latest version of the chrome browser. So it’s not bad if I say it creates up to date automation testing.
  • It can capture the performance issues of the web page.

Prepare your machine to run the puppeteer script.

During this whole puppeteer tutorial, I am going to use the windows machine so I will use all the required lib according to the windows.

At the very top, we need Node installed in our machine and one editor to write the code like notepad, Notepad++, TextLime its depend on your choice.

As we know Puppeteer is a node library so at the very first level we need to install node in our machine. Let’s see

How to install a node in the windows machine.

Install Node in windows machine.

Step 1) Download Node according to OS.


Step 2) Install node: Its really easy just click to Next or follow the instruction carefully.

Step 3) Once installation is done Let’s check the version of the node to confirm the installation.

Open Node.js CMD prompt and enter command “node -v”.

If you notice it’s showing the version of node In the above image. It means cheers! your node is installed successfully.

Puppeteer Installation

Step 1) Switch again to “node.js cmd prompt” and enter the command “npm i puppeteer

It downloads the latest version of chromium

Step 2) Install puppeteer-core: Enter the command “npm i puppeteer-core

It will help to launch an exiting browser or to connect with a remote browser.

Now the installation is done let’s see a demo script and then from upcoming tutorials will take a deep dive in Puppeteer.

const puppeteer = require('puppeteer');

(async () => {

const browser = await puppeteer.launch();

const page = await browser.newPage();

await page.goto('http://codedec.com/');

await page.screenshot({path: 'E:\\PupeteerScript\\output\\1.png'});

await browser.close();


The above script will launch the browser and navigate to the URL “http://codedec.com/” and take a screenshot.