Học Playwright tiếng Việt, Cộng đồng Playwright cho người Việt

Playwright tips

[Sưu tầm] Một số câu hỏi phỏng vấn Playwright

Beginner Level

Cơ bản về Playwright:

  • Playwright là gì? So sánh với Selenium?
  • Playwright hỗ trợ những browser nào?
  • Cài đặt và setup project Playwright như thế nào?
  • Cấu trúc cơ bản của một test case Playwright?

Selectors và Locators:

  • Các loại locator trong Playwright? Ưu nhược điểm từng loại?
  • Viết selector cho element có text “Submit”
  • Làm sao để locate element trong shadow DOM?
  • page.locator() vs page.$() khác nhau gì?

Basic Actions:

  • Click, fill text, select dropdown trong Playwright
  • Chờ element xuất hiện như thế nào?
  • Làm sao để verify text/attribute của element?
  • Upload file và handle dialog boxes

Intermediate Level

Test Organization:

  • Page Object Model trong Playwright implement như thế nào?
  • Test fixtures và hooks trong Playwright
  • Parallel testing và cách configure
  • Data-driven testing với Playwright

Advanced Interactions:

  • Drag and drop implementation
  • Handle multiple tabs/windows
  • iframes và nested frames
  • Mouse hover và keyboard shortcuts

Configuration & Setup:

  • playwright.config.js cấu hình những gì?
  • Headless vs headed mode
  • Browser contexts vs pages
  • Retry mechanisms và timeout settings

Assertions & Waits:

  • Soft assertions vs hard assertions
  • Auto-waiting mechanism hoạt động ra sao?
  • Custom wait conditions
  • Visual comparisons và screenshot testing

Advanced Level

Network & API:

  • Intercept và modify network requests
  • Mock API responses
  • Test API endpoints với Playwright
  • Handle authentication cookies/tokens

Performance & Monitoring:

  • Performance testing với Playwright
  • Memory leaks detection
  • Coverage reports
  • Tracing và debugging

CI/CD Integration:

  • Setup Playwright trong CI pipeline
  • Docker containers cho testing
  • Parallel execution strategies
  • Report generation và artifact handling

Advanced Patterns:

  • Custom fixtures và dependency injection
  • Test data management strategies
  • Cross-browser testing approaches
  • Mobile testing simulation

Expert Level Questions

Architecture & Design:

  • Thiết kế framework testing scalable
  • Micro-frontends testing strategies
  • Component testing vs E2E testing
  • Test maintenance và refactoring

Troubleshooting:

  • Debug flaky tests
  • Performance bottlenecks identification
  • Browser compatibility issues
  • Memory optimization

Code Examples họ có thể hỏi:

// Viết test case cho login flow
// Implement custom matcher
// Handle dynamic content loading
// Create reusable components

Câu hỏi tình huống thực tế:

  1. “Làm sao test một trang web có lazy loading?”
  2. “Handle authentication trong E2E tests”
  3. “Test file download/upload”
  4. “Dealing với third-party integrations”
  5. “Testing PWA applications”
  6. “Cross-origin iframe testing”

Tips chuẩn bị:

  • Ôn lại documentation chính thức
  • Thực hành viết code trực tiếp
  • Chuẩn bị examples về projects đã làm
  • Hiểu rõ best practices và anti-patterns
  • Nắm solid về async/await trong JavaScript

Trả lời