This project demonstrates automated testing of a web application using Playwright with TypeScript. It implements the Page Object Model (POM) design pattern and includes comprehensive test coverage for login, inventory, and checkout flows.
- Playwright
- TypeScript
- Allure Report
- dotenv
├── tests/
│ ├── pages/ # Page Object Models
│ ├── specs/ # Test Specifications
│ └── fixtures/ # Test Fixtures and Data
├── playwright.config.ts
├── tsconfig.json
└── package.json
- Install dependencies:
pnpm install
- Copy the
.env.example
file to.env
and update the credentials:
cp .env.example .env
- Run tests:
pnpm test # Run all tests
pnpm test:chrome # Run tests in Chrome only
pnpm test:headed # Run tests in headed mode
pnpm test:ui # Run tests with UI mode
- Configure the Allure Report in your machine:
Mac OS:
brew install allure
Linux:
# Using package file
# 1. Download the latest release
# Go to the latest Allure Report release on GitHub and download the allure-*.deb file.
# 2. Install the package
sudo dpkg -i allure_<version>_all.deb
sudo apt-get install -f # Install dependencies if needed
# Verify installation
allure --version
For other Linux distributions, check the official Allure documentation.
- BasePage: Abstract base class with common functionality
- AuthenticatedPage: Base class for authenticated pages
- LoginPage: Login page interactions
- InventoryPage: Product inventory functionality
- CheckoutPage: Checkout process handling
- Login Tests: User authentication scenarios
- Inventory Tests: Product listing and cart operations
- Checkout Tests: Order completion flow
- Multiple user type authentication:
- Standard user
- Performance glitch user
- Error user
- Visual user
- Problem user
- Error validation:
- Locked out user handling
- Invalid credentials messaging
- Error message verification
- Page navigation validation
- Product listing:
- Price sorting (low to high, high to low)
- Alphabetical sorting (A to Z)
- Product details verification
- Cart operations:
- Single item add/remove
- Multiple items management
- Cart badge count updates
- Cart persistence after page reload
- Navigation:
- Cart page access
- Shopping flow continuity
-
Information Form (Step One):
- Form field validation:
- First name requirement
- Last name requirement
- Postal code requirement
- Error message handling
- Navigation controls (continue/cancel)
- Form field validation:
-
Order Summary (Step Two):
- Item list verification
- Price calculations:
- Subtotal accuracy
- Tax computation
- Total amount validation
- Cart persistence
- Navigation options
-
Order Completion:
- Success message verification
- Order confirmation elements
- Post-purchase navigation
- Cart status reset
Generate and view test reports:
pnpm report
-
Page Object Model
- Modular and maintainable test structure
- Reusable page components
- Type-safe interactions
-
Cross-browser Testing
- Chrome, Firefox, and Safari support
- Mobile viewport testing (configurable)
-
Test Fixtures
- Shared test context
- User credentials management
- Error message constants
-
CI/CD Ready
- Configurable retry logic (configurable)
- Parallel test execution (configurable)
- Failure screenshots and videos (configurable)
-
Data-test Attributes
- Consistent selector strategy using data-test attributes
- Reliable element identification
- Maintainable selectors
-
Type Safety
- Strong TypeScript types
- Interface definitions for test data
- Compile-time error checking
-
Error Handling
- Graceful failure handling
- Detailed error messages
- Visual failure evidence
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
MIT License