Header Ads

  • Breaking News

    What is puppeteer? setup and writing first script.

    For Web automation mostly we use is selenium webdriver. I have already wrote many posts on learning selenium (click here). Selenium has some limitations, specially it is very slow.  There are also other few tools available which helps to automate website. One of the library backed by google is Puppeteer. So what is puppeteer ? 

    What is puppeteer?

    So as per google's "Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium." So it can be used to write UI automation on chrome. It can perform almost all the actions that user can perform.

    How to setup puppeteer ? 

    To understand puppeteer, setup and writing first script, you can watch our youtube video in detail. Also don't forget to subscribe youtube channel - 
    Starting with puppeteer (setup and writing first script).


    In this video you will learn - 
    • How to install puppeteer in mac and windows.
    • Writing first running script with puppeteer using java script.
    • Run in headless chrome
    • How to take screenshot

    How To setup puppeteer -

    1. Install node Node.JS latest version. You can install it from their official website. It's a free.
    2. Install Visual studio code. (I prefer this for javascript based projects).
    3. Create new project
    4. Go to project in Visual Studio, Open terminal and install puppeteer from below command "npm i puppeteer" or "yarn add puppeteer"
    5. After that make sure package.json is created
    6. create sample script like below
    7. Go through video for more clarification
    Sample Puppeteer script


    const puppeteer = require('puppeteer');


    (async () => {

      const browser = await puppeteer.launch();

      const page = await browser.newPage();

      await page.goto(‘http://www.softwaretestingtipsandtricks.com/’);

      await page.screenshot({path: 'example.png'});

      await browser.close();

    })();


    To run script
    Just write in terminal
    "Node filename.js"
    To understand each and every point why and how, Please watch the video from my youtube channel and subscribe the channel -> Youtube channel . Thank You.

    Follow Us on RedditFacebook and Twitter

    No comments

    Post Top Ad

    Post Bottom Ad