A unified Playwright + TypeScript test automation framework covering:
- UI Automation: OrangeHRM Live Demo (Login, PIM Employee CRUD, Search, Personal Details)
- API Automation: Swagger Petstore API (Pet & Store endpoints)
- Assignment mapping: Each requirement in the problem statement is mapped to concrete specs/pages:
- UI:
tests/ui/*.spec.ts+ POMs insrc/pages/*(login/logout, employee create/search/edit/delete, personal details, Job Title search). - API:
tests/api/pet.spec.tsandtests/api/store.spec.ts(all listed Pet + Store endpoints).
- UI:
- How to execute quickly:
- Install once:
npm installthennpx playwright install chromium. - Run all tests:
npm test(runs UI + API projects). - Or run only UI:
npm run test:ui, only API:npm run test:api.
- Install once:
- Where to see evidence:
- HTML report:
npm run report→ openstest-results/html-report/index.htmlwith per-test logs, traces, screenshots, and videos for failures. - Centralised logs:
logs/test-execution.log(Winston, timestamped). - Test data strategy:
src/utils/test-data.ts(factories for login data, employees, pets, and orders).
- HTML report:
- Design highlights:
- Page Object Model with Playwright fixtures (
src/fixtures/page-fixtures.ts) so specs are thin and readable. - Positive/negative coverage called out by
TC-*IDs in the tables below. - Error handling & flakiness controls are encapsulated in POMs (smart waits, toast helpers, autocomplete fallbacks), keeping specs stable against the OrangeHRM demo environment.
- Page Object Model with Playwright fixtures (
| Technology | Purpose |
|---|---|
| Playwright | Browser & API testing framework |
| TypeScript | Type-safe test development |
| Winston | Test execution logging |
| HTML Reporter | Test execution reports |
playwright-automation-framework/
├── playwright.config.ts # Playwright configuration (2 projects)
├── src/
│ ├── pages/ # Page Object Model (POM)
│ │ ├── base.page.ts # Shared utilities
│ │ ├── login.page.ts # Login page interactions
│ │ ├── dashboard.page.ts # Dashboard & navigation
│ │ ├── pim.page.ts # Employee list & search
│ │ ├── addEmployee.page.ts # Add Employee form
│ │ └── employeeDetails.page.ts # Personal details
│ ├── utils/
│ │ ├── logger.ts # Winston logging
│ │ ├── test-data.ts # Test data factories
│ │ └── api-helper.ts # API request wrapper
│ └── fixtures/
│ └── page-fixtures.ts # Custom Playwright fixtures
├── tests/
│ ├── ui/ # UI test specs
│ │ ├── login.spec.ts
│ │ ├── employee-crud.spec.ts
│ │ ├── employee-search.spec.ts
│ │ └── employee-details.spec.ts
│ └── api/ # API test specs
│ ├── pet.spec.ts
│ └── store.spec.ts
├── logs/ # Test execution logs (auto-generated)
└── test-results/ # Reports (auto-generated)
- Node.js >= 18.x
- npm >= 9.x
# 1. Clone the repository
git clone <repository-url>
cd playwright-automation-framework
# 2. Install dependencies
npm install
# 3. Install Playwright browsers
npx playwright install chromiumnpm testnpm run test:uinpm run test:apinpm run test:headednpx playwright test tests/ui/login.spec.ts
npx playwright test tests/api/pet.spec.tsnpm run reportThe HTML report is generated at test-results/html-report/index.html after each test run.
Execution logs are written to logs/test-execution.log with timestamps.
| Test ID | Scenario | Type |
|---|---|---|
| TC-L01 | Login with valid credentials | ✅ Positive |
| TC-L02 | Logout from dashboard | ✅ Positive |
| TC-L03 | Login with invalid username | ❌ Negative |
| TC-L04 | Login with invalid password | ❌ Negative |
| TC-L05 | Login with empty credentials | ❌ Negative |
| TC-E01 | Create a new employee | ✅ Positive |
| TC-E02 | Edit employee details | ✅ Positive |
| TC-E03 | Delete employee from list | ✅ Positive |
| TC-S01 | Search employee by ID | ✅ Positive |
| TC-S02 | Search employee by name | ✅ Positive |
| TC-S03 | Search employee by Job Title | ✅ Positive |
| TC-S04 | Search non-existent employee | ❌ Negative |
| TC-PD01 | Submit personal details | ✅ Positive |
| TC-PD02 | Verify personal details persist | ✅ Positive |
| Test ID | Scenario | Type |
|---|---|---|
| TC-P01 | Add a new pet | ✅ Positive |
| TC-P02 | Add pet with missing fields | ❌ Negative |
| TC-P03 | Find pet by ID | ✅ Positive |
| TC-P04 | Find non-existent pet | ❌ Negative |
| TC-P05 | Update existing pet | ✅ Positive |
| TC-P06 | Update pet with invalid data | ❌ Negative |
| TC-P07 | Delete a pet | ✅ Positive |
| TC-P08 | Delete non-existent pet | ❌ Negative |
| TC-ST01 | Place an order | ✅ Positive |
| TC-ST02 | Place order with invalid data | ❌ Negative |
| TC-ST03 | Find order by ID | ✅ Positive |
| TC-ST04 | Find non-existent order | ❌ Negative |
| TC-ST05 | Delete purchase order | ✅ Positive |
| TC-ST06 | Delete non-existent order | ❌ Negative |
- Page Object Model (POM): All UI interactions abstracted into page objects for maintainability
- Custom Fixtures: Playwright fixtures inject page objects into tests automatically
- Test Data Factories: Unique data generated per run using
Date.now()/Math.random() - Serial Execution: CRUD tests run in order (
serial mode) to maintain data dependencies - Auto-Cleanup: Each test suite creates and cleans up its own test data
- Winston Logging: Structured logs to console + file with timestamps and levels