Supporting track

Playwright

Auto-waiting, contexts and tracing — modern browser automation.

What this track covers

Locators & auto-waitingBrowser contextsFixturesNetwork interceptionTrace viewerParallel workersAPI testing built inSelenium migration strategy

Auto-waiting locators

Playwright locators re-resolve and run actionability checks, removing most explicit waits.

Why it is required: It eliminates the largest category of Selenium flakiness by design.

Example: A login test with zero explicit waits.

typescript
1test('user can log in', async ({ page }) => {
2 await page.goto('/login');
3 await page.getByLabel('Username').fill('standard_user');
4 await page.getByLabel('Password').fill('secret_sauce');
5 await page.getByRole('button', { name: 'Login' }).click();
6
7 await expect(page.getByRole('heading', { name: 'Products' })).toBeVisible();
8});

Expected result

Stable execution without a single wait statement.

Common mistakes

  • Using page.waitForTimeout() out of Selenium habit
  • CSS/XPath instead of role and label locators
  • Sharing one context across tests and losing isolation

How does Playwright's auto-waiting differ from Selenium's explicit waits?

Related interview questions

Open bank
  • Why would you migrate from Selenium to Playwright?

    Auto-waiting, browser contexts for cheap isolation, built-in tracing/network interception, and much faster parallel execution — but Selenium wins on legacy browser support and ecosystem.

  • How do Playwright fixtures, projects and auto-waiting change framework design?

    Fixtures replace base classes for setup, projects replace testng.xml for browser/environment matrices, and web-first assertions with auto-waiting remove most explicit wait code.

  • How does Playwright auto-waiting differ from Selenium waits?

    Playwright checks actionability (attached, visible, stable, enabled, receives events) before every action and retries until the timeout, so explicit waits are rarely needed.

  • Which locators do you prefer in Playwright and why?

    Role-based and label-based locators first (getByRole, getByLabel), then getByTestId; raw CSS/XPath last because they couple tests to markup.

  • How do you reuse authentication instead of logging in per test?

    Log in once in a setup project, save the session with storageState, and load that state in the config so each test starts signed in.

  • How do you mock or intercept network calls in Playwright?

    page.route intercepts matching requests so you can fulfil them with fixtures, abort them, or modify the response — ideal for error states and third-party isolation.