When a test fails, most beginners do one of two things. They change something at random and run it again, or they ask a senior engineer. Both are slow.
The truth is that Playwright usually tells you exactly what went wrong. The skill is reading the message literally, word by word. Let me show you the three you will see most often.
The timeout message.
Timed out 5000ms waiting for locator getByTestId('contact-line') to be visible
Read it in order: Playwright retried for 5 seconds, waiting for this locator, and it never became visible. Two possible causes, and you check them in this order:
- The locator is wrong. Open the app, inspect the element, compare the real attribute or role. This is the cause most of the time.
- The element never appears here at all. Then the app or your test's idea of the flow is wrong, also worth knowing.
What almost never helps: raising the timeout. If the element never appears, 50 seconds fails the same way, just slower.
The strict-mode violation.
strict mode violation: getByRole('button') resolved to 3 elements
Your locator is ambiguous. Playwright refuses to guess which of the three you meant. That refusal just caught a selector bug for you. Narrow the locator (a name, a test id, .filter()), or use .first() only when any match really is fine.
The assertion diff.
expect(locator).toHaveText('1') failed, received: '0'
This one is a gift: the app really did something different from your claim. Either the claim is wrong (fix the test) or the app is broken (you found a bug). Deciding which is the whole job, and it starts with reading the diff, not re-running and hoping.
On TestAcademy there is a third verdict you will meet: "your test passed, but it also passed when we broke the app." That is not fixed with selectors or waits. It means an assertion is missing or too weak. Go back to what the test claims.
For deeper investigation, Playwright records traces you can replay step by step: Trace viewer.
The final problem of this track: prove that logout really logs you out. Read every failure you hit on the way. Each one tells you your next step.