Skip to content

Loading interactive demos…

RESUME

Test Automation Demo

Follow a feature from test design to Playwright automation, reporting, defect investigation and retesting.

TEST AUTOMATION DEMO

How I test a feature from start to finish — one login story through every step: analysis, test case, manual test, automation, report, and a real bug found, reported and retested.

ONE SCENARIO · FOUR STEPS

From a login story to a verified fix.

Follow one example, one step at a time. Start with what should happen, then see how a test catches a logout bug.

Interactive simulation
STEP 01 / 04

What are we testing?

A user should be able to log in, see the Products page, then log out safely.

Log in View products Log out

1. Define success

Valid credentials open the Products page. Logout ends the session and shows the login form.

This is the acceptance criteria.

2. Write the checks

  1. Log in with the demo account.
  2. Check that Products is visible.
  3. Click Logout.
  4. Check that the login form returns.

3. Check manually first

Follow the steps in the browser and compare the result with the requirement.

Automate this stable flow for regression checks.

The key check: after Logout, the login form must be visible again. We will use this same check in the code and the run.

View the full test case & Gherkin Technical detail

TC-LOGIN-001 documents the expected flow. The sample PASS below describes the manual baseline; the automated build results appear in Step 03.

User Story As a user, I should log in successfully and leave the session safely.
Acceptance Criteria User can log in with valid credentials, access the Products page, log out successfully, and return to the login form.
Requirement Analysis Questions for the PO / extra scenarios:
  • Error message for wrong password or empty fields?
  • What happens for a locked-out user?
  • After logout, can the user go back to Products with the browser Back button?
→ Added as separate negative test cases (TC-LOGIN-002…004).
Test Case ID TC-LOGIN-001
Test Case Description Verify successful login with valid credentials and complete Sauce Demo login/logout flow.
Pre-Condition Application is accessible and demo environment is available.
Test Steps and Description
  1. Navigate to the application URL.
  2. Log in with valid credentials.
  3. Verify logged in.
  4. Open side menu and Click Logout.
  5. Verify login form is displayed again.
Test Data
URL: https://www.saucedemo.com User: standard_user Pass: secret_sauce
Expected Result User logs in successfully, logs out successfully, and the login form is displayed again.
Execution Manual first (Chrome) → then automated: critical, stable and repeated in every regression.
Actual Result Actual behavior matches expected result. Test completed successfully.
Comments / evidence Demo execution output confirms successful flow.
Pass / Fail PASS
Feature: User Authentication
  Scenario: Successful login and logout
    Given the login page is displayed
    When I log in with valid credentials
    Then the inventory page should be visible
    When I click Logout
    Then the login page should be displayed again
Next: turn these checks into code.
STEP 02 / 04

The same checks, written as code.

Playwright repeats the user’s actions and checks the expected result after each one.

USER ACTION

Log in with valid credentials

await loginPage.login(user, password);
FIRST CHECK

Confirm that Products is visible

await inventoryPage.expectLoaded();
FINAL CHECK

Log out and check the login form

await inventoryPage.logout();
await expect(loginPage.loginButton).toBeVisible();

Why automate this? Login and logout are critical actions. The same test can check them again after every change.

View the full Playwright test & page objects TypeScript
import { test, expect } from '@playwright/test';
import { LoginPage } from './pages/LoginPage';
import { InventoryPage } from './pages/InventoryPage';

test.describe('SauceDemo — auth', () => {
  let loginPage: LoginPage;
  let inventoryPage: InventoryPage;

  test.beforeEach(async ({ page }) => {
    loginPage = new LoginPage(page);
    inventoryPage = new InventoryPage(page);
    await loginPage.goto();
  });

  test('TC-LOGIN-001: login → inventory → logout', async () => {
    await loginPage.login('standard_user', 'secret_sauce');
    await inventoryPage.expectLoaded();

    await inventoryPage.logout();
    await expect(loginPage.loginButton).toBeVisible();
  });
});
STEP 03 / 04

Can the test catch a broken logout?

Start with v1.0.1. Login works, but Logout leaves the user on Products — so our final check should fail.

Test console

Pick a build and click Run test. Build v1.0.1 has a logout bug, so the test fails. Report the bug, then retest on the fixed build v1.0.2.

npx playwright test — chromium

Execution summary

STATUS —
Browser —
Framework —
Execution time —

Browser preview

Chromium (headed · demo)
about:blank
Headed preview
Run the test to watch the UI follow each Playwright step.
Loading page…
Swag Labs

Products (inventory)

  1. Start — engine & open URL
  2. Log in with demo user
  3. Assert products (inventory)
  4. Open menu & log out
  5. Back to login & pass
STEP 04 / 04

Understand the failure. Verify the fix.

Run the test in Step 03 to generate evidence. Here is what to look for in this example.

Expected

Logout ends the session. The login form is visible again.

The v1.0.1 regression

The user stays on Products. The login-form check fails.

Verify v1.0.2

Run the same test on the fixed build. A passing result confirms this logout check works again.

Inspect the test report & evidence Awaiting run

Test Report & Evidence (HTML report · screenshots · video · trace)

Awaiting run No execution yet — click Run test to populate.
No results report: — browser: —
HTML Report —
— test cases
—

SUITES 0 item total

—
Show all

Environment

There are no environment variables (simulation)

Test cases 0 items total

Show all
Total tests
—
Suite scope
Passed
—
Assertions OK
Failed
—
Flaky / errors
Duration
—
Wall time
Browser
—
Project

Recent run

Test name Status Duration
— — —

Artifacts

Screenshot

On a real run, Playwright saves PNGs per step or on failure. In this demo, assert thumbnails (login, inventory, logout) load only after the run finishes; until then, the slots stay empty.

Assert: Swag Labs login (demo screenshot)
Assert: SauceDemo inventory (demo screenshot)
Assert: back to sign-in (demo screenshot)
Video

On a real run, set video: 'on' or 'retain-on-failure' in playwright.config — output often lands in test-results/. In this demo, a screen recording (video evidence) is attached only after the run completes.

Demo file: videos/pw-run-demo-evidence.mp4 — optimized screen capture of the login → inventory → logout run.

Trace Viewer
Traces bundle DOM, network, and console. Open with npx playwright show-trace trace.zip — ideal for debugging flaky steps in a headed timeline UI.
HTML Report
Default reporter writes playwright-report/index.html. Use npx playwright show-report locally; publish the folder as a CI artifact. Allure users swap in allure-playwright + allure serve for a comparable dashboard.

This panel is a front-end simulation. In production, wire the same layout to your reporter output or Allure JSON — the workflow matches how QA engineers triage runs after npx playwright test.

Write a bug report Interactive lab

Bug Report Lab — loading…

This interactive lab is loading. If this message stays, please refresh the page.

More practice: CI pipelines & API testing Optional labs

CI Pipeline Lab — loading…

This interactive lab is loading. If this message stays, please refresh the page.

API & Network Testing — loading…

This interactive lab is loading. If this message stays, please refresh the page.