This repository contains automated tests for the Swag Labs application using Cypress. The goal is to ensure the functionality and reliability of the application through automated end-to-end testing.
- Introduction
- Prerequisites
- Installation
- Running Tests
- Folder Structure
- Custom Commands
- Test Cases Covered
- Contributing
- License
Swag Labs is a web application that simulates a shopping experience. This project automates various features of the Swag Labs application to validate user flows and ensure seamless functionality.
Before you begin, ensure you have met the following requirements:
- Node.js (version 14.x or later)
- npm (Node package manager)
-
Clone the repository:
git clone https://github.com/hasanazeerkhan/swaglabs-automation-cypress.git cd swaglabs-automation-cypress
-
Install the required dependencies:
npm install
To run the tests, use the following command:
npx cypress open
This will open the Cypress Test Runner. You can then select the test files you want to run.
For headless execution, you can run:
npx cypress run
The project follows a standard Cypress folder structure:
swaglabs-automation-cypress/
├── cypress/
│ ├── fixtures/ # Test data files
│ ├── integration/ # Test specifications
│ ├── support/ # Custom commands and global configurations
├── cypress.json # Cypress configuration file
└── package.json # Project dependencies and scripts
Custom commands are defined in the cypress/support/commands.js
file. They help to simplify repetitive tasks within tests. Feel free to add your own custom commands as needed.
- Test Step: Navigate to the login page.
- Expected Result: The URL should match
https://example.com/login
.
- Test Step: Check the title of the login page.
- Expected Result: The title should be "User Login".
- Test Step: Enter valid username and password and submit.
- Expected Result: User should be redirected to the dashboard, and a welcome message should be displayed.
- Test Step: Enter invalid username and/or password and submit.
- Expected Result: An error message "Invalid username or password" should be displayed, and the URL should remain as
https://example.com/login
.
- Test Step: Open the menu.
- Expected Result: All menu items should be visible, including "About", "Logout", "Reset App State", and "Close".
- Test Step: Click on the "About" menu item.
- Expected Result: A new page containing information about the application should open.
- Test Step: Click on the "Logout" menu item.
- Expected Result: The user should be logged out and redirected to the login page.
- Test Step: Click on "Reset App State".
- Expected Result: All added options should be removed, and the app should return to its default state.
- Test Step: Click on the "Close" button in the left pane.
- Expected Result: The left pane should close successfully.
- Test Step: Apply each of the three filter options sequentially.
- Expected Result: The displayed items should update according to the selected filter criteria.
- Test Step: Add an item to the cart and then remove it.
- Expected Result: The cart should be empty after removal.
- Test Step: Click on the "Continue Shopping" button after adding an item to the cart.
- Expected Result: User should be redirected back to the product listing page.
- Test Step: Click on the "Checkout" button in the cart.
- Expected Result: The user should be taken to the checkout page.
- Test Step: Enter required information (e.g., shipping address, payment details) on the checkout page.
- Expected Result: All information should be accepted without errors.
- Test Step: Click on the "Cancel" button on the checkout page.
- Expected Result: The user should be returned to the cart page with no changes made.
Contributions are welcome! If you have suggestions for improvements or new features, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch
git checkout -b feature/YourFeature
- Make your changes.
- Commit your changes
git commit -m 'Add some feature'
- Push to the branch
git push origin feature/YourFeature
- Open a pull request.