Cart Tests S3447a96b→

2 0 2

Tests (4)

A

Add item to cart Td472099e→

Description
Code
  test("Add item to cart", async ({ page, loginPage }) => {
    const add = new AddItem(page);
    await add.addItem();

    await expect(page.locator(".shopping_cart_badge")).toBeVisible();

    await page.waitForTimeout(3000);
  });

A

Remove item from cart T44a6a3c1→

Description
Code
  test("Remove item from cart", async ({ page, loginPage }) => {
    const add = new AddItem(page);
    await add.addItem();
    await add.cartItems();

    const remove = new RemoveItem(page);
    await remove.removeItem();

    await expect(page.locator(".shopping_cart_badge")).toBeHidden();

    await page.waitForTimeout(3000);
  });

M

Adding item to cart T8f0ecdc3→

Description
### Description
Checks that a logged-in user can successfully add an item to the cart and see it displayed correctly.

### Preconditions
User is logged in on [https://www.saucedemo.com/](https://www.saucedemo.com/)


### Steps

| # | Action | Expected Result |
|---|---------|----------------|
| 1 | Click **“Add to cart”** button | The **“Add to cart”** button is clicked |
| 2 | Verify that the **shopping cart icon** displays a badge with the number **“1”** | The **shopping cart icon** displays a badge with the number “1” |
| 3 | Click **“Shopping cart”** icon | The **shopping cart icon** is clicked |
| 4 | Verify that the **item has been added** | The added product is displayed in the cart with the correct name and price |


![](/attachments/V3MQgXmZF3.png)


---

### Expected Result
The selected product is successfully added to the cart.  
Attachments
M

Remove item from cart T9151896b→

Description
### Description
Verifies that a user can successfully remove an item from the shopping cart.

### Preconditions
User is logged in on [https://www.saucedemo.com/](https://www.saucedemo.com/)  
At least one item has been added to the cart.

### Steps

| # | Action | Test Data | Expected Result |
|---|---------|------------|----------------|
| 1 | Click **“Remove”** button | — | The item is removed from the cart list |
| 2 | Verify that the **shopping cart icon badge** has disappeared | — | The badge indicator is no longer visible |
| 3 | Verify that the **item is no longer displayed** in the cart | — | The cart is empty or does not contain the previously removed item |


![](/attachments/AHeG8s1igz.png)

---

### Expected Result
The item is successfully removed from the cart.  

Attachments