Model answers for 4 Playwright questions
Typical round: concepts, framework design, live test writing
Q: How is Playwright different from Selenium? A: Playwright talks to browsers directly instead of through WebDriver, auto-waits for elements to be actionable, supports Chromium, Firefox and WebKit from one API, and ships with a test runner, tracing and parallelism built in.
Q: Which locators do you prefer and why? A: User-facing ones: getByRole, getByLabel, getByText and getByTestId. They survive styling and layout changes better than CSS or XPath chains, and they encourage accessible markup.
Q: How do you fix a flaky test? A: Open the trace to see what happened, replace fixed waits with web-first assertions like expect(locator).toBeVisible(), isolate test data so tests don't share state, and mock unstable third-party calls. Retries are a safety net, not the fix.
Q: How do you handle login across many tests? A: Log in once in a setup project, save storageState to a file, and reuse it in other projects so tests start already authenticated.