Skip to content

This repository will contain Cypress Automation Code to help others to learn and practice

Notifications You must be signed in to change notification settings

daniyalfarman/Cypress-Automation-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swag Labs Test Suite

Description

This project is an automated test suite for Swag Labs, a popular e-commerce website used for testing purposes. The test suite uses Cypress, a powerful end-to-end testing framework, to validate various functionality on the website.

The tests cover a wide range of actions including logging in, adding items to the cart, completing checkout, sorting items, and verifying UI elements. The suite aims to ensure the reliability of the core functionality and provides automated validation for major user interactions on the platform.


Key Features:

  • Login Validation:

    • Verifies that incorrect login credentials display the appropriate error message.
  • Add to Cart & Checkout:

    • Simulates adding items to the shopping cart.
    • Completes the checkout process by filling in personal information and confirming the order.
  • Sorting Mechanism:

    • Tests the sorting functionality for both product names and prices (A-Z, Z-A, low-to-high, high-to-low).
  • UI and Functional Tests:

    • Ensures that elements such as buttons, input fields, and error messages are displayed correctly.
    • Validates interactions like clicking, typing, and selecting dropdown options.

Technologies Used:

  • Cypress: For end-to-end testing
  • JavaScript: For writing test cases
  • HTML/CSS: For interacting with page elements

Test Cases:

1. Invalid Login Test

  • Test Objective: Ensure an error message appears when invalid login credentials are provided.
  • Steps:
    • Visit the login page.
    • Enter incorrect username and password.
    • Verify that the error message is displayed correctly.

2. Add Item to Cart & Complete Checkout

  • Test Objective: Add an item to the cart, proceed to checkout, and confirm the order.
  • Steps:
    • Add "Sauce Labs Backpack" to the cart.
    • Go to the cart and proceed to checkout.
    • Enter personal details and complete the purchase.
    • Verify the success message.

3. Sort Items by Name (A-Z, Z-A)

  • Test Objective: Validate sorting functionality for product names in both A-Z and Z-A orders.
  • Steps:
    • Sort items by name in A-Z and Z-A order.
    • Validate that the items are sorted correctly.

4. Sort Items by Price (Low to High, High to Low)

  • Test Objective: Test the sorting functionality based on product prices.
  • Steps:
    • Sort items by price in both low-to-high and high-to-low orders.
    • Verify the sorted prices are in the correct order.

5. UI Validation

  • Test Objective: Ensure that UI elements like buttons and input fields are properly aligned and displayed.
  • Steps:
    • Verify that the page title is correct.
    • Ensure that all buttons and input fields are visible and clickable.
    • Verify that no UI element is misaligned.

6. Cart Item Length Check

  • Test Objective: Validate that the correct number of items is displayed in the main view.
  • Steps:
    • Check that the number of items in main view is 6 as expected.

Setup Instructions:

  1. Install Dependencies: Ensure that you have Node.js installed on your machine.

    npm install
  2. Run the Tests: To run the test suite using Cypress, run the following command:

    npx cypress open

    This will open the Cypress Test Runner where you can view the tests and their results interactively.

  3. Run Tests in Headless Mode: To run the tests in headless mode (without opening the Cypress Test Runner UI), use the following command:

    npx cypress run

Future Improvements:

  • Add more test cases for additional product types.
  • Implement more UI validation tests for responsiveness on different screen sizes.
  • Integrate CI/CD pipeline to automate the execution of tests on every code change.

Contribution

Feel free to fork this repository, submit pull requests, and contribute to enhancing the test suite!


About

This repository will contain Cypress Automation Code to help others to learn and practice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published