Automated E2E testing for SauceDemo's SwagLab application using Playwright with TypeScript, featuring encrypted credentials, video recording, and comprehensive artifact management.
- Cross-browser testing - Chromium, Firefox, WebKit
- TypeScript - Type-safe test code
- Encrypted credentials - AES-256 encryption for sensitive data
- Video recording - Full test execution videos (WebM format)
- Screenshot capture - Timestamped screenshots at key test points
- HTML reports - Interactive test reports with embedded assets
- Timestamped artifacts - Organized test results with historical preservation
- CI/CD ready - GitHub Actions integration for automated testing
SwagLab/
βββ .github/workflows/
β βββ playwright.yml # GitHub Actions CI/CD pipeline
βββ config/
β βββ credentials.ts # Encrypted credential management (AES-256)
βββ hooks/
β βββ setup.ts # Playwright setup hooks
βββ tests/
β βββ Navigate.spec.ts # Login and checkout tests
β βββ AddAllItems.spec.ts # Full cart checkout test
βββ Screenshots/ # Timestamped screenshot folders
β βββ [DDMMYY_HHMMSS]/
βββ Videos/ # Timestamped video folders
β βββ [DDMMYY_HHMMSS]/
βββ Reports/ # Timestamped HTML reports
β βββ [DDMMYY_HHMMSS]/
βββ playwright.config.ts # Playwright configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies
βββ archiveReports.ts # Report archival utility
βββ organizeVideos.ts # Video organization utility
- Node.js 18+
- Git
- Windows 10+ (or Linux/macOS with appropriate adjustments)
- Clone the repository
git clone https://github.com/Kumarg3/swaglabtest.git
cd SwagLab- Install dependencies
npm install- Install Playwright browsers
npx playwright install- Configure credentials (optional)
Edit
config/credentials.tsto update encrypted credentials as needed.
Credentials are encrypted using AES-256-CBC with SHA-256 key derivation:
- Default credentials stored in:
config/credentials.ts - Encrypted format:
IV:ENCRYPTED_DATA(base64-encoded) - Access at runtime: Use
getCredentials()function
import { getCredentials } from './config/credentials';
const { username, password } = getCredentials();
// Credentials are only decrypted at runtimenpm testnpx playwright test tests/Navigate.spec.tsnpx playwright test --headednpx playwright test --debugnpm run show:reportAll test artifacts are organized by execution timestamp (format: DDMMYY_HHMMSS):
Screenshots/
βββ DDMMYY_HHMMSS/ # Test run folder
β βββ DDMMYY_HHMMSS_Login_PASS.png
β βββ DDMMYY_HHMMSS_Checkout_PASS.png
β βββ ...
Videos/
βββ DDMMYY_HHMMSS/
β βββ DDMMYY_HHMMSS_video.webm
Reports/
βββ DDMMYY_HHMMSS/
β βββ index.html # Interactive HTML report
β βββ data/ # Report assets (screenshots, videos)
Archive reports:
npx ts-node archiveReports.tsOrganize videos:
npx ts-node organizeVideos.tsGitHub Actions automatically:
-
On every push/PR:
- Checks out code
- Installs dependencies
- Installs Playwright browsers
- Runs all tests
- Organizes videos and reports
- Uploads artifacts (30-day retention)
- Comments on PRs with test results
-
Scheduled daily runs:
- Runs at 2 AM UTC
- Maintains historical test data
- Go to: https://github.com/Kumarg3/swaglabtest/actions
- Click on any workflow run to see results, logs, and artifacts
- Test 1: Login to SauceDemo
- Test 2: Login and checkout single item (Bike Light)
- Features: Encrypted credentials, screenshots, report attachment
- Test: Add all 6 items to cart and complete checkout
- Features: Full video recording, multiple checkpoints, random checkout info
- Artifacts: 5 checkpoint screenshots + full test video
- Browser: Chromium (configurable in
playwright.config.ts) - Video: Enabled for all tests (WebM format)
- Screenshots: On failure + key test points
- Trace: On first retry
- Timeout: 30 seconds per test
- Retries: 0 (configurable)
- Check
config/credentials.tsencryption key - Verify environment variable is set (if using custom key)
- Ensure
embedAssets: trueinplaywright.config.ts - Check screenshot directory permissions
- Run:
npx ts-node organizeVideos.tsmanually - Verify
test-results/directory exists
- Increase timeout in
playwright.config.ts - Check network connectivity
- Verify SauceDemo site is accessible
- @playwright/test - Test framework
- typescript - Type safety
- Node.js built-ins - crypto, fs, path for encryption & file management
Kumar G (kumarg3)
Email: fastkumar09@gmail.com
Private Repository - All rights reserved
Last Updated: April 4, 2026
Test Framework: Playwright v1.40+
TypeScript: v5.0+