What is the difference between let, const, and var? var has function scope, let and const have block scope. const cannot be reassigned.
Explain closures with an example. A closure is a function that remembers its outer variables even after the outer function returns.
What is the event loop? The event loop handles async operations. Callbacks/microtasks (Promise) go to microtask queue; setTimeout/IO go to macrotask queue.
What does this refer to in different contexts? In a method: the object. In a function (non-strict): global. In arrow function: lexical scope.
Playwright-Specific
How does Playwright auto-wait work? Playwright waits for elements to be visible, enabled, and stable before actions. No explicit wait needed.
What are the advantages of getByRole over CSS selectors? Accessibility-first, more resilient to DOM changes, better error messages, matches user perception.
Explain browser contexts. Isolated browser sessions with separate storage, cookies, and cache. Each context is like a separate incognito window.
How would you test a file download? Use page.waitForEvent('download') and download.saveAs().
What is the difference between page.route() and page.waitForResponse()? route() intercepts and modifies requests. waitForResponse() waits for a specific response to complete.
How do you run tests in parallel? Set fullyParallel: true in config or test.describe.configure({ mode: 'parallel' }).
SDET & Automation
What is the Page Object Model? A design pattern that encapsulates page-specific elements and actions in classes for maintainability.
How do you handle dynamic content? Use waitForSelector, waitForURL, or assertions with auto-retrying (toBeVisible).
How do you set up CI for Playwright? GitHub Actions with matrix strategy across browsers. Install with --with-deps flag.
What is visual testing and when would you use it? Comparing screenshots pixel-by-pixel. Useful for UI regression, cross-browser consistency, responsive layout checks.
Explain retries and flaky tests. Retries re-run failed tests. Flaky tests pass intermittently — fix root cause rather than relying on retries.
✏️ Exercise: Practice answering all 15 questions aloud within 75 minutes. Write a Playwright test for the scenario described in question 8 (file download).