Skip to content

CODEBUN

  • Home
  • Automation
    • Selenium Tutorial
    • Selenium Web Driver With Java
    • Selenium Web Driver With C#
    • Katalon studio
    • Puppeteer and Jest
  • Development
    • Java Tutorial
    • JSP Tutorial
    • Servlet Tutorial
    • Spring Tutorial
    • Hibernate Tutorial
    • Spring Boot with ReactJS
    • Angular JS
    • JS and HTML
    • C# Tutorial
    • ReactJS Tutorial
    • MERN Stack Development
    • Java web application Development tutorial
    • Database Tutorial
    • Android Tutorial
  • Projects
    • Java Projects
    • Spring Boot Projects
    • Project In Java
    • Project In Hibernate
    • Project in spring
    • Java web application Development tutorial
    • UML Diagrams
    • PHP Project
  • Programs
    • Java program
    • VB Program
    • C# Program
  • Interview Q&A
    • Placement Q&A
      • Computer || Programming
      • Maths
      • Reasoning
      • English
    • C Interview Questions and Answer
    • Data Structure Q & A
    • Operating System Interview Q&A
    • HTML and CSS Q&A
  • Downloads
Menu
  • Home
  • Automation
    • Selenium Tutorial
    • Selenium Web Driver With Java
    • Selenium Web Driver With C#
    • Katalon studio
    • Puppeteer and Jest
  • Development
    • Java Tutorial
    • JSP Tutorial
    • Servlet Tutorial
    • Spring Tutorial
    • Hibernate Tutorial
    • Spring Boot with ReactJS
    • Angular JS
    • JS and HTML
    • C# Tutorial
    • ReactJS Tutorial
    • MERN Stack Development
    • Java web application Development tutorial
    • Database Tutorial
    • Android Tutorial
  • Projects
    • Java Projects
    • Spring Boot Projects
    • Project In Java
    • Project In Hibernate
    • Project in spring
    • Java web application Development tutorial
    • UML Diagrams
    • PHP Project
  • Programs
    • Java program
    • VB Program
    • C# Program
  • Interview Q&A
    • Placement Q&A
      • Computer || Programming
      • Maths
      • Reasoning
      • English
    • C Interview Questions and Answer
    • Data Structure Q & A
    • Operating System Interview Q&A
    • HTML and CSS Q&A
  • Downloads
Search
Close this search box.
Search

Automate Login and Registration Page using puppeteer, Mocha and Jest

  • Bhupendra Patidar
  • May 9, 2020
  • Puppeteer and Jest

How to automate the login and registration page using puppeteer, Mocha, and jest. In this puppeteer automation tutorial, We will see web automation examples using puppeteer.

Puppeteer is a node library that is used to handle chromium and chrome browser in headless mode or without headless mode. If you are a beginner in puppeteer. I’ll recommend following the puppeteer tutorial.

Automate Registration page using puppeteer

  • Launch browser.
  • Navigate to the registration page.
  • Enter your personal details.
  • Enter your address.
  • And click to register button.

Automate Login page using puppeteer

  • Navigate to the login page.
  • Enter a valid username.
  • Enter a valid password.
  • Click to sign in button.
  • Verify the signout button.
const puppeteer = require('puppeteer');
const expect = require('chai').expect;


describe("Automte Login and Registration Page in puppeteer",()=>{

    let browser
    let page
    before(async function(){
      browser = await puppeteer.launch({
        headless:false,
        slowMo:0
      })
      //Launch browser
      page = await browser.newPage()
      //Enter Url
      await page.goto("http://automationpractice.com/index.php")
    })

    it('Navigate to URL', async()=>{

      //Click to login link
      await page.waitForSelector('.login');
      await page.click('.login');

    })

   it("Register As user",async()=>{
     //Enter Email Id
     await page.waitForSelector('#email_create');
     await page.type('#email_create','Codebuntut06@gmail.com')
     await page.click('#SubmitCreate');

     await page.waitForSelector('#id_gender1');
     await page.click('#id_gender1');

     //Enter FirstNmae........
     await page.type('#customer_firstname', 'bhupi');
     //Enter LastName.....
     await page.type('#customer_lastname', 'Patel');
    
     //Enter password....
     await page.type('#passwd','Demo@123');
     //Select Date Of Birth.....
     await page.select('#days','8');
     await page.select('#months','5');
     await page.select('#years','1992');

     //Enter your address
     await page.type('#company','Bhupi');
     await page.type('#address1','Bhupi');
     await page.type('#city','Imorec');
     await page.select('#id_state','4');
     await page.type('#postcode','25968');
     await page.type('#phone_mobile','8585858585');
     await page.type('#alias','gfdg fdgfdgf');
     
     //Click to Registration button..
     await page.click('#submitAccount');

     await page.waitForSelector('.logout');
     let signoutText = await page.$eval('.logout', element=>element.textContent);
     //Verify signout text...
     console.log(signoutText);
     expect(signoutText).to.include('Sign out');
     //Logout

     await page.click('.logout');

    })


    it('Login as user',async()=>{


      //Enter username...
      await page.waitForSelector('#email')
      await page.type('#email','Codebuntut06@gmail.com');
      //Enter password
      await page.type('#passwd', 'Demo@123');
      //click to login b3utton.
      await page.click('#SubmitLogin');
      //Verify login
      await page.waitForSelector('.logout');
      let signoutText = await page.$eval('.logout', element=>element.textContent);
      //Verify signout text...
      console.log(signoutText);
      expect(signoutText).to.include('Sign out');
    })

    after(async function(){
       await browser.close()
    })

 });

Output:

PrevPreviousAirline reservation system project in java with source code and project report
NextAutomate Visual testing using Puppeteer and Jest || Visual regression testingNext

Recent Post

How to Explain Your Automation Testing Project in an Interview

December 1, 2024

Automation Testing Interview Questions for Wait in Selenium C Sharp

December 1, 2024

Automation Task: Extracting Product Names and Ratings with Selenium in C#

November 25, 2024

Space Booking Project in java using JSP and Servlet with source code

November 23, 2024

Design Test Automation Framework using Java, Selenium, TestNG, POM

August 1, 2024

Bug Reporting Project using Spring Boot, Hibernate, JPA and Mysql

July 8, 2024

Cannot find the declaration of element ‘project’ in Pom.xml

May 8, 2024

Failed to configure a DataSource: ‘url’ attribute is not specified

May 8, 2024

Solve “Non-resolvable parent POM” Error in pom.xml with Spring Boot 3

May 8, 2024

JSP and Servlet Project Configuration Tutorial

May 2, 2024

CODEBUN

  • jcodebun@gmail.com
  • +91 8827363777
Facebook Twitter Youtube

Automation

  • Who We Are?
  • Services And Plan
  • Contact Us
  • Privacy Policy
  • Terms And Conditions
  • Internship

Programs

  • Java program
  • VB Program
  • C# Program

Automation

  • Selenium Tutorial
  • Selenium Web Driver With Java
  • Selenium Web Driver With C#
  • Katalon studio
  • Puppeteer and Jest