Errors and failure analysis
Classify a failed run, collect the smallest useful evidence, and change the right layer.
When a browser test fails, do not start by increasing the timeout or changing the locator. First name the failure class and collect the evidence that can prove it.
Start from the symptom
| Symptom | First evidence |
|---|---|
| Locator or assertion timeout | screenshot and trace |
| Browser launch failure | install logs and CI environment |
| Page JavaScript error | console evidence and trace |
| Request failure | request/response evidence |
| Missing download | response evidence and artifact path |
| Protocol or driver error | version information and transport logs |
A timeout says that a condition never became true. It does not tell you whether the locator, application state, network, frame, or environment was wrong.
Use a mechanical first pass
- Copy the exact error class and message.
- Identify the failed setup step, action, or assertion.
- Check the screenshot or trace for the actual page and URL.
- Check console and network evidence only when they can explain that state.
- Compare local and CI context options for CI-only failures.
- Change the test only after the evidence points to the failing layer.
This prevents a larger timeout from hiding a product regression, failed request, missing fixture, or wrong environment variable.
Compare environments deliberately
For a CI-only failure, compare:
- browser engine and installed browser version;
- headless mode;
- viewport, locale, and timezone;
- base URL and environment variables;
- permissions and stored state;
- PHP and dependency versions.
Make the relevant values explicit in the context or test configuration. “Same code” does not mean “same browser environment”.
Avoid noisy diagnostics
Do not add every possible listener to every test. Collect the smallest artifact that answers the question:
- screenshot for final visible state;
- trace for sequence and timing;
- console for page-side errors;
- network evidence for backend exchanges;
- client logs for driver or protocol problems.
Keep broad diagnostics temporary. Permanent evidence should be predictable, redacted, and easy to find in CI.
Common mistakes
- Calling every timeout a flake.
- Fixing the selector before checking which page loaded.
- Increasing timeouts without opening the trace.
- Ignoring frame boundaries or failed requests.
- Uploading artifacts without linking them from the failed job.
- Treating a protocol error as a product bug before verifying versions.
Go next
- Follow the complete workflow: Debugging
- Inspect a run interactively: Inspector
- Keep useful signals: Logs
- Fix timing decisions: Timeouts and retries