Overview
Checkout (also referred to as the Cart Page) handles all interactions with the shopping cart, including verifying products, managing cart contents, and validating cart badge counts.
Location: cypress/support/pages/Checkout.ts
Extends: BasePage
Class Definition
Constructor
Initializes the Checkout page with required selectors.Properties
| Property | Type | Selector | Description |
|---|---|---|---|
cartList | string | [data-test="cart-list"] | Shopping cart list container |
cartBadge | string | .shopping_cart_badge | Cart badge showing item count |
inventoryItem | string | [data-test="inventory-item"] | Individual cart items (inherited from BasePage) |
Methods
verifyCartPageIsVisible
Verifies that the cart page is displayed and the cart list is visible.verifyProductWasAddedToCart
Verifies that exactly one product exists in the cart.- Checks that the inventory items have a length of 1
verifyAllProductsWereAddedToCart
Verifies that all 6 products are present in the cart.- Checks that the inventory items have a length of 6
verifyThatCheckoutCounterMatch
Verifies that the cart badge count matches the actual number of items in the cart.- Gets the length of inventory items in the cart
- Extracts the text from the cart badge
- Compares the badge number with the actual item count
DeleteAllProductsFromCart
Removes all products from the shopping cart.- Iterates through all inventory items in the cart
- Clicks the “Remove” button for each product
verifyAnyProductExists
Verifies that no products exist in the cart.- Checks that inventory items do not exist in the DOM
Complete Test Flow Examples
Single Product Workflow
Multiple Products Workflow
Cart Deletion Workflow
Common Test Patterns
Add and Verify Pattern
Add, Delete, and Verify Pattern
Related Pages
BasePage
Parent class providing common functionality
HomePage
Add products from home page
Navbar
Navigate to cart via navbar