Q1.A test passes locally but fails about 1 in 10 runs in CI with "element not visible". What do you do?
This Playwright question checks whether you can go beyond textbook knowledge on A test passes locally but fails about 1 in 10 runs in CI with "element not visible". What do you do and reason about it the way a working QA engineer does — with a definition, an example, and the edge case that usually comes up next.
Answer: First I open the trace for a failing run to see what the page looked like at the moment of failure. The usual cause is that the test checks the page before the app has finished loading, often because of a manual check such as isVisible() that doesn't wait. I replace it with a web-first assertion, which retries until the condition is true or the timeout ends.
// Flaky: isVisible() returns immediately, no retry
expect(await page.getByRole('alert').isVisible()).toBe(true);
// Stable: retries until visible (default 5s expect timeout)
await expect(page.getByRole('alert')).toBeVisible();To prevent it, I enable trace: 'on-first-retry' in the config so every CI failure comes with evidence, and I add a lint rule against waitForTimeout.
- Anchor the answer in a real Playwright project — panels reward specificity on A test passes locally but fails about 1 in 10 runs in CI with "element not visible". What do you do over textbook wording.
- Be ready to whiteboard the A test passes locally but fails about 1 in 10 runs in CI with "element not visible". What do you do snippet live — panels often ask you to type it, not describe it.
- Quote a real flake-rate number before and after your fix; measured outcomes score far higher than "we added retries".

Discussion
Ask a question, share your experience, or correct us. Be kind — real people are reading.