Test Automation
Hands on Practice
Practice 1

Objective: Create a new spec in Cypress using JavaScript.

Steps:

Assuming you've successfully installed Cypress and opened Cypress now it's time to add your first test. We're going to do this with the Create new empty spec button.

Open Cypress for the first time to create the default folder structure:

    npx cypress open

Create a New Spec File

  • Your test files (specs) will go inside the cypress/e2e folder .
  • Create a new JavaScript file in the appropriate folder.

For Example:

    File_name.cy.js

Even though we haven't written any code yet - that's okay - let's click on your new spec and watch Cypress launch it. Cypress will visit https://example.cypress.io and the test passes.

Practice 2

Objective: Testing the Quotation List on Demo Lens with Login

1.Log In to Demo Lens:

  • Open Demo Lens.
  • Enter username and password, then click 'Login'.
  • Verify navigation to the main page with the quotation list.


2.Select a Quotation:

  • Locate the quotation list and Select a quotation.


3.Verify Quotation Details:

  • Check the details page like Quotation ID, date, customer info, total amount, items/services.
  • Use assertions to verify correct data.


4.Exit Quotation Details:

  • Confirm return to the main quotation list page.

Hints :

Element Selectors:

  • Use IDs, classes, or data-testid for selectors.
  • Navigate lists/tables with .find(), .first(), etc.

Assertions:

  • Use .should('be.visible') to verify element presence.
  • Check field values with appropriate assertions.
Have a doubt?
Post it here, our mentors will help you out.