“Project 2: E-commerce End-to-End Test Framework with Page Objects (Playwright Python)”

This project builds a real test framework, not a script. The target is SQA Shop, the SQA Tools practice store, with search, cart, coupons, a four-step checkout (contact, delivery, payment, review), several payment methods, order confirmation and order tracking. You will design page objects for every screen, add fixtures that create carts instantly, cover happy paths and error paths across payment methods, verify money calculations, run the suite in parallel and produce a report. It uses most of Modules 4 to 12 together, and every test shown was run against the live practice site.

Advertisement

📖 What You’ll Learn: designing a framework for a multi-step checkout, the folder layout, a shared Header component, page objects for search results, cart, checkout steps, order confirmation and tracking, step methods that synchronise on the next step, a cart builder and fixtures that seed state, tests for cart behaviour, coupons, guest and member checkout, card, UPI and cash on delivery, validation and declined payments, money arithmetic, order tracking, parallel runs and an HTML report.


🛒 The Application Under Test

SQA Shop is a single-page store with 108 products. The checkout is the interesting part:

Step What happens Rules worth testing
Cart quantities, remove, save for later, coupons SAVE10 (10%, max ₹500, min ₹999) and FLAT200 (min ₹1,499) caps and minimums
1 Contact email and mobile required, formats
2 Delivery address (or a “fill dummy address” button), standard or express speed pincodes starting with 9 are not serviceable
3 Payment card (4111 1111 1111 1111 ok, 4000 0000 0000 0002 declined), UPI (success@upi / failure@upi), net banking, cash on delivery declines appear only when placing the order
4 Review summary, terms checkbox, Place order terms required
Order confirmation with order ID, amount, status, delivery date; tracking by order ID + email data must match

🗂️ Framework Layout

shop-framework/
├── pytest.ini
├── conftest.py               fixtures: shop, cart builder, member state
├── framework/
│   ├── money.py              "₹13,299" -> 13299
│   └── cart_builder.py       seeds carts without clicking
├── pages/
│   ├── base.py               BasePage + Header component
│   ├── search.py             SearchResults
│   ├── cart.py               CartPage
│   ├── checkout.py           CheckoutPage with one method per step
│   └── order.py              OrderPage, TrackOrderPage
└── tests/
    ├── test_cart.py
    ├── test_checkout.py
    ├── test_checkout_errors.py
    └── test_orders.py

📄 pytest.ini

[pytest]
addopts = --base-url https://sqatools.in --screenshot only-on-failure --tracing retain-on-failure
pythonpath = .
testpaths = tests
markers =
    smoke: fast, critical checks

🧰 Framework Helpers

📄 framework/money.py

import re


def money(text: str) -> int:
    """'₹13,299' -> 13299, '−₹500' -> 500, 'Free' -> 0."""
    digits = re.sub(r"[^\d]", "", text)
    return int(digits) if digits else 0

📄 framework/cart_builder.py

import json
from dataclasses import dataclass, field

EARBUDS, HANDBOOK, TSHIRT = "EL-013", "DG-010", "CL-001"


@dataclass
class CartBuilder:
    lines: list[dict] = field(default_factory=list)

    def add(self, product_id: str, qty: int = 1, size: str = ""):
        self.lines.append({"id": product_id, "size": size, "color": "", "qty": qty})
        return self

    def init_script(self) -> str:
        data = json.dumps(json.dumps(self.lines))
        return (f"if (!sessionStorage.getItem('seeded')) {{ localStorage.setItem('spCart', {data}); "
                f"sessionStorage.setItem('seeded', '1'); }}")

📄 Page Objects

Base page and header

📄 pages/base.py

from playwright.sync_api import Page

SHOP = "/dummy-ecommerce-website/"


class Header:
    def __init__(self, page: Page):
        self.page = page
        self.search_input = page.get_by_test_id("search-input")
        self.search_button = page.get_by_test_id("search-button")
        self.cart_count = page.get_by_test_id("cart-count")
        self.account = page.get_by_test_id("account-button")

    def search(self, term: str):
        self.search_input.fill(term)
        self.search_button.click()
        from pages.search import SearchResults
        results = SearchResults(self.page)
        results.cards.first.wait_for()
        return results


class BasePage:
    route = ""

    def __init__(self, page: Page):
        self.page = page
        self.header = Header(page)

    def open(self):
        self.page.goto(SHOP + self.route)
        return self

Search results and cart

📄 pages/search.py

from pages.base import BasePage


class SearchResults(BasePage):
    def __init__(self, page):
        super().__init__(page)
        self.cards = page.get_by_test_id("product-card")

    def add_to_cart(self, name: str):
        before = int(self.header.cart_count.inner_text())
        card = self.cards.filter(has_text=name).first
        card.get_by_role("button", name="Add to cart").click()
        self.header.cart_count.filter(has_text=str(before + 1)).wait_for()   # synchronise on the badge
        return self

📄 pages/cart.py

from playwright.sync_api import Page

from pages.base import BasePage


class CartPage(BasePage):
    route = "#/cart"

    def __init__(self, page: Page):
        super().__init__(page)
        self.title = page.get_by_test_id("cart-title")
        self.item_names = page.get_by_test_id("cart-item-name")
        self.coupon_input = page.get_by_test_id("coupon-input")
        self.coupon_message = page.get_by_test_id("coupon-message")
        self.coupon_discount = page.get_by_test_id("coupon-discount")
        self.total = page.get_by_test_id("order-total")
        self.checkout_button = page.get_by_test_id("checkout-button")

    def quantity(self, product_id: str):
        return self.page.get_by_test_id(f"cart-qty-{product_id}")

    def increase(self, product_id: str):
        self.page.get_by_test_id(f"cart-plus-{product_id}").click()
        return self

    def remove(self, product_id: str):
        self.page.get_by_test_id(f"remove-{product_id}").click()
        return self

    def apply_coupon(self, code: str):
        self.coupon_input.fill(code)
        self.page.get_by_test_id("apply-coupon").click()
        return self

    def checkout(self):
        self.checkout_button.click()
        from pages.checkout import CheckoutPage
        return CheckoutPage(self.page).wait_for_step("contact")
Advertisement

Checkout: one method per step

📄 pages/checkout.py

from playwright.sync_api import Page

from pages.base import BasePage

CARD_OK, CARD_DECLINED = "4111 1111 1111 1111", "4000 0000 0000 0002"


class CheckoutPage(BasePage):
    route = "#/checkout"

    def __init__(self, page: Page):
        super().__init__(page)
        self.continue_button = page.get_by_test_id("step-continue")
        self.delivery_fee = page.get_by_test_id("delivery-fee")
        self.total = page.get_by_test_id("order-total")
        self.place_error = page.get_by_test_id("place-error")

    def wait_for_step(self, name: str):
        self.page.get_by_test_id(f"step-{name}").wait_for()
        return self

    def error_for(self, field_id: str):
        return self.page.locator(f"#{field_id}-err")

    # step 1
    def contact(self, email: str = "guest@example.com", phone: str = "9876543210"):
        self.page.get_by_test_id("checkout-email").fill(email)
        self.page.get_by_test_id("checkout-phone").fill(phone)
        self.continue_button.click()
        return self

    # step 2
    def delivery(self, pincode: str | None = None, express: bool = False):
        self.page.get_by_test_id("fill-dummy-address").click()
        if pincode:
            self.page.get_by_test_id("ad-pin").fill(pincode)
        self.page.get_by_test_id("speed-express" if express else "speed-standard").check()
        self.continue_button.click()
        return self

    # step 3
    def pay_by_card(self, number: str = CARD_OK):
        self.page.get_by_test_id("pay-card").check()
        self.page.get_by_test_id("card-name").fill("Test User")
        self.page.get_by_test_id("card-number").fill(number)
        self.page.get_by_test_id("card-expiry").fill("12/30")
        self.page.get_by_test_id("card-cvv").fill("123")
        return self._to_review()

    def pay_by_upi(self, upi: str = "success@upi"):
        self.page.get_by_test_id("pay-upi").check()
        self.page.get_by_test_id("upi-id").fill(upi)
        return self._to_review()

    def pay_cash_on_delivery(self):
        self.page.get_by_test_id("pay-cod").check()
        return self._to_review()

    def _to_review(self):
        self.continue_button.click()
        return self.wait_for_step("review")

    # step 4
    def place_order(self, accept_terms: bool = True):
        if accept_terms:
            self.page.get_by_test_id("accept-terms").check()
        self.page.get_by_test_id("place-order").click()
        return self

    def confirmed_order(self):
        from pages.order import OrderPage
        order = OrderPage(self.page)
        order.confirmation.wait_for(timeout=10_000)        # the store shows a 2-second "placing order" overlay
        return order

Order confirmation and tracking

📄 pages/order.py

from pages.base import BasePage


class OrderPage(BasePage):
    def __init__(self, page):
        super().__init__(page)
        self.confirmation = page.get_by_test_id("order-confirmation")
        self.title = page.get_by_test_id("confirm-title")
        self.order_id = page.get_by_test_id("order-id")
        self.paid = page.get_by_test_id("order-paid")
        self.status = page.get_by_test_id("order-status")
        self.eta = page.get_by_test_id("delivery-eta")


class TrackOrderPage(BasePage):
    route = "#/orders"

    def track(self, order_id: str, email: str):
        self.page.get_by_test_id("track-order-id").fill(order_id)
        self.page.get_by_test_id("track-email").fill(email)
        self.page.get_by_test_id("track-button").click()
        return OrderPage(self.page)

🧩 Fixtures

📄 conftest.py

import json

import pytest
from playwright.sync_api import BrowserContext, Page

from framework.cart_builder import CartBuilder
from pages.base import BasePage
from pages.cart import CartPage


@pytest.fixture
def shop(page: Page) -> BasePage:
    return BasePage(page).open()


@pytest.fixture
def cart_with(context: BrowserContext, page: Page):
    """cart_with(CartBuilder().add(...)) -> an open CartPage with those items, no clicking needed."""
    def _cart(builder: CartBuilder) -> CartPage:
        context.add_init_script(builder.init_script())
        return CartPage(page).open()
    return _cart


@pytest.fixture
def member(context: BrowserContext):
    """Log in as the remembered demo user before any page script runs (Lesson 58, StoredLogin)."""
    context.add_init_script(f"localStorage.setItem('spUser', {json.dumps(json.dumps('testuser'))});")

✅ Cart Tests

📄 tests/test_cart.py

import pytest
from playwright.sync_api import expect

from framework.cart_builder import EARBUDS, HANDBOOK, CartBuilder
from framework.money import money
from pages.cart import CartPage


@pytest.mark.smoke
def test_add_from_search(shop):
    shop.header.search("earbuds").add_to_cart("Wireless Earbuds")
    expect(shop.header.cart_count).to_have_text("1")
    cart = CartPage(shop.page).open()
    expect(cart.item_names).to_have_text(["Wireless Earbuds"])


def test_quantity_updates_total(cart_with):
    cart = cart_with(CartBuilder().add(EARBUDS))
    one = money(cart.total.inner_text())
    cart.increase(EARBUDS)
    expect(cart.quantity(EARBUDS)).to_have_value("2")
    expect(cart.header.cart_count).to_have_text("2")
    assert money(cart.total.inner_text()) == 2 * one


def test_remove_line(cart_with):
    cart = cart_with(CartBuilder().add(EARBUDS).add(HANDBOOK))
    cart.remove(HANDBOOK)
    expect(cart.item_names).to_have_text(["Wireless Earbuds"])


@pytest.mark.parametrize("builder, code, message, discount", [
    pytest.param(CartBuilder().add(EARBUDS), "SAVE10", "Coupon SAVE10 applied.", "−₹500", id="save10-capped"),
    pytest.param(CartBuilder().add(EARBUDS), "FLAT200", "Coupon FLAT200 applied.", "−₹200", id="flat200"),
    pytest.param(CartBuilder().add(HANDBOOK), "SAVE10", "Add ₹500 more to use SAVE10.", None, id="save10-below-min"),
    pytest.param(CartBuilder().add(HANDBOOK, qty=3), "FLAT200", "Add ₹2 more to use FLAT200.", None, id="flat200-just-below"),
])
def test_coupons(cart_with, builder, code, message, discount):
    cart = cart_with(builder).apply_coupon(code)
    expect(cart.coupon_message).to_have_text(message)
    if discount:
        expect(cart.coupon_discount).to_have_text(discount)
    else:
        expect(cart.coupon_discount).to_have_count(0)

⌨️ Terminal

pytest tests/test_cart.py -v

🖥️ Output

============================= test session starts =============================
platform win32 -- Python 3.15.1, pytest-9.2.0, pluggy-1.7.0 -- C:\Users\you\playwright-python\.venv\Scripts\python.exe
cachedir: .pytest_cache
baseurl: https://sqatools.in
rootdir: C:\Users\you\playwright-python
configfile: pytest.ini
plugins: allure-pytest-2.16.2, base-url-2.1.0, bdd-9.0.1, html-4.2.0, metadata-3.1.1, playwright-0.10.0, rerunfailures-16.7, xdist-3.8.0
collecting ... collected 7 items

tests/test_cart.py::test_add_from_search[chromium] PASSED                [ 14%]
tests/test_cart.py::test_quantity_updates_total[chromium] PASSED         [ 28%]
tests/test_cart.py::test_remove_line[chromium] PASSED                    [ 42%]
tests/test_cart.py::test_coupons[chromium-save10-capped] PASSED          [ 57%]
tests/test_cart.py::test_coupons[chromium-flat200] PASSED                [ 71%]
tests/test_cart.py::test_coupons[chromium-save10-below-min] PASSED       [ 85%]
tests/test_cart.py::test_coupons[chromium-flat200-just-below] PASSED     [100%]

============================= 7 passed in 15.62s ==============================

The boundary case flat200-just-below uses three handbooks (3 × ₹499 = ₹1,497), ₹2 short of FLAT200’s ₹1,499 minimum. Boundary values like this are where pricing bugs live.


Advertisement

💳 Checkout Tests

📄 tests/test_checkout.py

import re

import pytest
from playwright.sync_api import expect

from framework.cart_builder import EARBUDS, CartBuilder
from framework.money import money


@pytest.mark.smoke
@pytest.mark.parametrize("pay, status", [
    pytest.param(lambda c: c.pay_by_card(), "Paid · confirmed", id="card"),
    pytest.param(lambda c: c.pay_by_upi("success@upi"), "Paid · confirmed", id="upi"),
    pytest.param(lambda c: c.pay_cash_on_delivery(), "Confirmed · pay on delivery", id="cod"),
])
def test_guest_checkout(cart_with, pay, status):
    cart = cart_with(CartBuilder().add(EARBUDS))
    checkout = cart.checkout().contact().delivery()
    total = money(pay(checkout).total.inner_text())
    order = checkout.place_order().confirmed_order()

    expect(order.title).to_have_text("Order placed successfully!")
    expect(order.order_id).to_have_text(re.compile(r"^OD\d{14}$"))
    expect(order.status).to_contain_text(status)
    assert money(order.paid.inner_text()) == total
    expect(order.header.cart_count).to_have_text("0")                     # the cart is emptied


def test_express_delivery_costs_more(cart_with):
    standard = cart_with(CartBuilder().add(EARBUDS)).checkout().contact().delivery(express=False)
    standard_total = money(standard.total.inner_text())
    standard.page.get_by_role("button", name="← Back").click()
    express = standard.wait_for_step("address").delivery(express=True)
    fee = money(express.delivery_fee.inner_text())
    print(f"\nexpress delivery fee: ₹{fee}")
    assert fee > 0
    assert money(express.total.inner_text()) == standard_total + fee


def test_member_details_are_prefilled(member, cart_with):
    cart = cart_with(CartBuilder().add(EARBUDS))
    checkout = cart.checkout()
    expect(checkout.page.get_by_test_id("logged-in-note")).to_contain_text("Signed in as Test User")
    expect(checkout.page.get_by_test_id("checkout-email")).to_have_value("test.user@example.com")

⌨️ Terminal

pytest tests/test_checkout.py -v -s

🖥️ Output

============================= test session starts =============================
platform win32 -- Python 3.15.1, pytest-9.2.0, pluggy-1.7.0 -- C:\Users\you\playwright-python\.venv\Scripts\python.exe
cachedir: .pytest_cache
baseurl: https://sqatools.in
rootdir: C:\Users\you\playwright-python
configfile: pytest.ini
plugins: allure-pytest-2.16.2, base-url-2.1.0, bdd-9.0.1, html-4.2.0, metadata-3.1.1, playwright-0.10.0, rerunfailures-16.7, xdist-3.8.0
collecting ... collected 5 items

tests/test_checkout.py::test_guest_checkout[chromium-card] PASSED
tests/test_checkout.py::test_guest_checkout[chromium-upi] PASSED
tests/test_checkout.py::test_guest_checkout[chromium-cod] PASSED
tests/test_checkout.py::test_express_delivery_costs_more[chromium] 
express delivery fee: ₹149
PASSED
tests/test_checkout.py::test_member_details_are_prefilled[chromium] PASSED

============================= 5 passed in 19.53s ==============================

The parametrized test takes a lambda that performs the payment step, so three payment methods share one test body. The order ID format, status text, the amount paid and the emptied cart are all verified.


🚫 Error Paths

📄 tests/test_checkout_errors.py

from playwright.sync_api import expect

from framework.cart_builder import EARBUDS, CartBuilder
from pages.checkout import CARD_DECLINED


def test_contact_is_validated(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout()
    checkout.contact(email="not-an-email", phone="12345")
    expect(checkout.page.get_by_test_id("step-contact")).to_be_visible()      # still on step 1
    expect(checkout.error_for("ck-email")).not_to_be_empty()
    expect(checkout.error_for("ck-phone")).not_to_be_empty()


def test_unserviceable_pincode(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout().contact()
    checkout.delivery(pincode="900001")
    expect(checkout.error_for("ad-pin")).to_have_text("Sorry, we do not deliver to this pincode yet.")


def test_declined_card_does_not_create_an_order(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout().contact().delivery().pay_by_card(CARD_DECLINED)
    checkout.place_order()
    expect(checkout.place_error).to_contain_text("Payment declined by the bank", timeout=10_000)
    expect(checkout.header.cart_count).to_have_text("1")                       # nothing was bought


def test_terms_are_required(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout().contact().delivery().pay_by_card()
    checkout.place_order(accept_terms=False)
    expect(checkout.page.locator("#agree-err")).to_have_text("Please accept the terms to place the order.")

📦 Order Tracking

📄 tests/test_orders.py

from playwright.sync_api import expect

from framework.cart_builder import HANDBOOK, CartBuilder
from pages.order import TrackOrderPage


def test_track_order_by_id_and_email(cart_with):
    checkout = cart_with(CartBuilder().add(HANDBOOK)).checkout().contact(email="tracker@example.com")
    order = checkout.pay_by_upi().place_order().confirmed_order()        # digital product: no delivery step
    order_id = order.order_id.inner_text()

    tracked = TrackOrderPage(order.page).open().track(order_id, "tracker@example.com")
    expect(tracked.order_id).to_have_text(order_id)


def test_unknown_order(shop):
    tracked = TrackOrderPage(shop.page).open().track("OD00000000000000", "nobody@example.com")
    expect(tracked.page.locator("#track-id-err")).to_have_text("No order found for this ID and email in this browser.")

⌨️ Terminal

pytest tests/test_checkout_errors.py tests/test_orders.py -v

🖥️ Output

============================= test session starts =============================
platform win32 -- Python 3.15.1, pytest-9.2.0, pluggy-1.7.0 -- C:\Users\you\playwright-python\.venv\Scripts\python.exe
cachedir: .pytest_cache
baseurl: https://sqatools.in
rootdir: C:\Users\you\playwright-python
configfile: pytest.ini
plugins: allure-pytest-2.16.2, base-url-2.1.0, bdd-9.0.1, html-4.2.0, metadata-3.1.1, playwright-0.10.0, rerunfailures-16.7, xdist-3.8.0
collecting ... collected 6 items

tests/test_checkout_errors.py::test_contact_is_validated[chromium] PASSED [ 16%]
tests/test_checkout_errors.py::test_unserviceable_pincode[chromium] PASSED [ 33%]
tests/test_checkout_errors.py::test_declined_card_does_not_create_an_order[chromium] PASSED [ 50%]
tests/test_checkout_errors.py::test_terms_are_required[chromium] PASSED  [ 66%]
tests/test_orders.py::test_track_order_by_id_and_email[chromium] PASSED  [ 83%]
tests/test_orders.py::test_unknown_order[chromium] PASSED                [100%]

============================= 6 passed in 20.35s ==============================

test_track_order_by_id_and_email also checks a business rule hidden in the flow: an eBook is a digital product, so checkout goes straight from contact to payment without a delivery step.


⚡ Run the Whole Framework in Parallel

⌨️ Terminal

pytest -n 4 -q --html=reports/report.html --self-contained-html

🖥️ Output

bringing up nodes...
bringing up nodes...

..................                                                       [100%]
- Generated html report: file:///C:/Users/you/playwright-python/reports/report.html -
18 passed in 23.35s

All tests are independent (each seeds its own cart in its own browser context), so four workers run them safely in parallel. Failures would leave screenshots and traces in test-results/ thanks to the options in pytest.ini.


🧠 Design Decisions Worth Copying

Decision Why
One CheckoutPage with step methods returning self The checkout is one URL with internal steps; chaining reads like the user journey
Step methods synchronise (wait_for_step, cart badge) Prevents races in a single-page app (Lesson 56)
CartBuilder + add_init_script Cart setup in milliseconds; only one test exercises adding via search
money() helper Arithmetic assertions instead of string comparisons
Payment as a lambda parameter Several payment methods without duplicating the flow
Error tests stay on the right step and check nothing was bought Negative tests verify side effects, not just messages

Advertisement

🏋️ Practice Exercises

Try each exercise on your own first, then open the answer to compare. The answers use the same practice sites and project layout as the lesson.

Exercise 1: Add a pay_by_netbanking(bank) method to CheckoutPage and a test that places an order with “Demo National Bank”.

Show answer
def pay_by_netbanking(self, bank: str = "Demo National Bank"):
    self.page.get_by_test_id("pay-netbanking").check()
    self.page.get_by_test_id("bank").select_option(bank)
    return self._to_review()
def test_netbanking(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout().contact().delivery().pay_by_netbanking()
    order = checkout.place_order().confirmed_order()
    expect(order.title).to_have_text("Order placed successfully!")

Exercise 2: Write a test that UPI failure@upi leads to the declined message and keeps the cart.

Show answer
def test_upi_failure(cart_with):
    checkout = cart_with(CartBuilder().add(EARBUDS)).checkout().contact().delivery().pay_by_upi("failure@upi")
    checkout.place_order()
    expect(checkout.place_error).to_contain_text("Payment declined", timeout=10_000)
    expect(checkout.header.cart_count).to_have_text("1")

Exercise 3: Clothing items need a size. Extend CartBuilder usage to seed a T-shirt (CL-001) in size M, and assert the cart shows the size.

Show answer
cart = cart_with(CartBuilder().add(TSHIRT, size="M"))
expect(cart.page.get_by_test_id("cart-item")).to_contain_text("M")

CartBuilder.add already accepts size; the cart line stores it and the cart shows it with the item.

Exercise 4: The marketing team adds a coupon WELCOME50 (₹50 off, no minimum). Which single change gives you a test for it?

Show answer

Add one pytest.param(CartBuilder().add(HANDBOOK), "WELCOME50", "Coupon WELCOME50 applied.", "−₹50", id="welcome50") to the test_coupons parameter list. The framework already knows how to seed carts, apply coupons and read discounts; new business rules become new data rows.


🧠 MCQ Quiz: Project 2: E-commerce End-to-End Framework

10 questions on this lesson. Pick one answer for each, then press Check answers to see your score and an explanation for every question.

  1. Why is CheckoutPage one class with step methods instead of four page classes?
  2. What does wait_for_step("review") do?
  3. How do most tests get items into the cart?
  4. Why is the payment step passed as a lambda in test_guest_checkout?
  5. What does flat200-just-below test?
  6. What does the declined-card test verify besides the error message?
  7. Why does confirmed_order() wait up to 10 seconds?
  8. Why can this suite run with -n 4 safely?
  9. How does test_track_order_by_id_and_email reveal a business rule?
  10. How would you add a new coupon rule to the tests?

Want a longer, timed test? Take the Playwright Python mock interviews (13 modules, 20 MCQs each).


Advertisement

❓ Frequently Asked Questions

🤔 Why not create carts through an API?

SQA Shop is a client-side app with no backend API, so the equivalent of “create via API” is seeding its browser storage. In an application with a server, use page.request calls instead (Lesson 55); the fixture interface stays the same.

🤔 Should assertions live in page objects here?

No. Page objects expose locators and actions and synchronise; tests decide what is correct. The only waits inside page objects are for the next screen, never verdicts.

🤔 How do I add a mobile run of this framework?

Run it with --device "Pixel 7" (Lesson 50). The locators are test ids, so they work unchanged on the mobile layout; add separate tests for mobile-only elements such as the filter drawer.

🤔 Where would Allure fit in?

Decorate page-object methods with @allure.step (Lesson 64) and every test gets a readable step tree for free.

🤔 How big should a real e-commerce suite be?

Cover every pricing and payment rule with focused tests like these, keep a handful of full journeys as smoke tests, and move combinatorial pricing checks to API or unit tests where possible.


🏁 Summary

  • A page-object framework mirrors the app: a shared Header, search results, cart, a step-based checkout and order pages.
  • Step methods return the page and synchronise on the next step; fixtures seed carts and member state instantly.
  • Tests cover cart behaviour, coupon boundaries, three payment methods, express delivery arithmetic, validation, declined payments and order tracking.
  • Money values are compared as numbers; negative tests check that nothing was bought.
  • Independent tests run in parallel with an HTML report and failure artifacts.

🎬 Watch the Playwright tutorial series on YouTube!

Subscribe to SqaToolsByDY • Practice on the SQA Tools Automation Practice Page