Testing / Playwright Interview questions
What are assertions in Playwright?
Assertions verify that the application is in an expected state, and Playwright provides two kinds. Web-first assertions, written as expect(locator)..., automatically retry until the condition becomes true or a timeout is reached, which matches how real UIs update asynchronously.
await expect(page.getByRole('alert')).toBeVisible(); await expect(page.getByTestId('count')).toHaveText('3');
Common matchers include toBeVisible(), toBeEnabled(), toHaveText(), toHaveValue(), and toHaveCount(). Generic value assertions like expect(value).toBe(3) also exist for comparing plain JavaScript values, but these check once and don't retry, so they're meant for values that are already settled rather than UI state that's still updating.
More Related questions...