🌍 Real World — E-Commerce Full Scenario

Real World — E-Commerce Full Scenario: An e-commerce critical path test is like an airport security chain audit: check-in, passport, security, boarding gate — if any single link

An e-commerce critical path test is like an airport security chain audit: check-in, passport, security, boarding gate — if any single link breaks, the plane departs but the passenger is left behind, and nobody knows exactly which link failed. The scenario below inspects each link with a separate assertion: "did login succeed, was the product added to cart, did stock decrement, did the payment service return 200?" Why write this in Playwright rather than Selenium/Java? Because checkout flows typically involve a payment iframe, a new tab for email verification, and API wait times — in Selenium each of those meant separate WebDriverWait and switchTo() lines. In Playwright, frameLocator, page.waitForResponse, and context.newPage() collapse that complexity into a handful of lines. The QA reality: on an e-commerce site it's not enough for the "Buy" button to work. If the payment service returns success but the confirmation email never arrives, inventory doesn't update, or the user dashboard shows the wrong order — that's a production incident. That's why end-to-end scenario testing matters far more than testing a single action.

Micro Lab: Playwright — Locator selection

Replace the TODO line with the critical line from the expected solution. This is not a real runtime; the goal is to reinforce writing the correct structure in a controlled way.

Step by Step: Playwright — Locator selection

Try semantic locators first: getByRole, getByLabel, getByPlaceholder

If not semantic, use getByText or getByTestId

If CSS/XPath needed, write page.locator("css") or page.locator("xpath=...")

Verify locator works with await expect(locator).toBeVisible()

Narrow with filter()

If multiple elements match, narrow with .first() / .nth() / .filter()

What is the Playwright locator selection and verification order?

🎬 The Button Worked, But Did the Order Actually Go Through?

Shallow Test: "Button Worked" → PASS

Stock Never Decremented + No Email Sent