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.
-
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.
- Cypress: For end-to-end testing
- JavaScript: For writing test cases
- HTML/CSS: For interacting with page elements
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
-
Install Dependencies: Ensure that you have Node.js installed on your machine.
npm install
-
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.
-
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
- 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.
Feel free to fork this repository, submit pull requests, and contribute to enhancing the test suite!