Bộ test tự động hóa hoàn chỉnh cho website Phúc Long Coffee & Tea, bao gồm các test case cho đăng nhập, đặt hàng và đăng xuất.
- TC001: Đăng nhập thành công với thông tin hợp lệ
- TC002: Đặt mua sản phẩm Hồng Trà Đào với tùy chỉnh
- TC003: Đăng xuất thành công
- TC004: End-to-End Flow - Login, Order, Logout
- TC005: Negative Test - Login với thông tin sai
- TC006: Test Responsive Design - Mobile View
- TC007: Page Load Performance
- TC008: Login Performance
- TC009: Keyboard Navigation
- TC010: Screen Reader Compatibility
cd test
npm installnpm run install:browsersnpm testnpm run test:uinpm run test:headed# Test đăng nhập
npm run test:login
# Test đặt hàng
npm run test:order
# Test đăng xuất
npm run test:logout
# Test end-to-end
npm run test:e2e
# Test negative cases
npm run test:negative
# Test responsive design
npm run test:responsive
# Test performance
npm run test:performance
# Test accessibility
npm run test:accessibility# Chrome
npm run test:chromium
# Firefox
npm run test:firefox
# Safari
npm run test:webkit
# Mobile
npm run test:mobilenpm run test:debugnpm run test:reportnpm run codegenplaywright.config.js- Cấu hình Playwrightpackage.json- Scripts và dependencies
- Base URL: https://phuclong.com.vn
- Timeout: 10s cho actions, 30s cho navigation
- Retry: 2 lần trên CI, 0 lần local
- Screenshot: Chỉ khi fail
- Video: Giữ lại khi fail
- Trace: Khi retry
- Chrome (Chromium)
- Firefox
- Safari (WebKit)
- Mobile Chrome (Pixel 5)
- Mobile Safari (iPhone 12)
// Icon user
page.locator('i').nth(1)
// Số điện thoại
page.getByRole('textbox', { name: 'Số điện thoại*' })
// Mật khẩu
page.getByRole('textbox', { name: 'Mật khẩu*' })
// Buttons
page.getByRole('button', { name: 'Tiếp tục' })
page.getByRole('button', { name: 'Đăng nhập' })// Product button
page.getByRole('button', { name: 'Chọn Size' }).first()
// Customization options
page.getByText('Nhiều').first() // Ngọt
page.getByText('Nhiều').nth(1) // Trà
page.getByText('Nhiều').nth(2) // Đá
// Add to cart
page.getByRole('button', { name: 'Đặt mua' })// User menu
page.locator('i').nth(1)
// Logout button
page.getByText('Đăng xuất')- Target: < 5 seconds
- Measurement: Time to network idle
- Target: < 3 seconds
- Measurement: Complete login flow
- Tab navigation support
- Enter key activation
- Focus management
- ARIA labels
- Proper form labels
- Semantic HTML
-
Test fails with timeout
- Check internet connection
- Verify website is accessible
- Increase timeout in config
-
Locator not found
- Website may have changed
- Update locators in test file
- Use
npm run codegento generate new locators
-
Login fails
- Verify test credentials are valid
- Check for CAPTCHA or rate limiting
- Update credentials in test file
-
Run with headed mode
npm run test:headed
-
Use debug mode
npm run test:debug
-
Check screenshots
- Screenshots saved in
test-results/folder - Only captured on test failure
- Screenshots saved in
-
View traces
- Traces saved when tests retry
- Open with Playwright trace viewer
- Phone: 0794174833
- Password: 123123
- Name: Hồng Trà Đào (L)
- Customization: Nhiều ngọt, nhiều trà, nhiều đá
name: Phúc Long Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: cd test && npm install
- run: cd test && npm run install:browsers
- run: cd test && npm testNếu gặp vấn đề với test suite:
- Kiểm tra logs trong console
- Xem screenshots trong
test-results/ - Chạy với
--headedmode để debug - Cập nhật locators nếu website thay đổi