Skip to content
FLAKY PLAYWRIGHT TESTS

Find the cause.
Fix the flaky test.

Compare a failing run with a passing one. Work through timing, shared state, data, network, and locators to find your next useful check.

LOOK ONE STEP EARLIERIllustrative example
Save team settingsThe same test. A different outcome.
save.spec.ts
Compare an illustrative passing and failing save action
StepPassing runFailing run
Open settingsPage readyPage ready
Click saveClickedClicked
Check the resultSavedStill saving

This is where to look next.The click completed in both runs. Check the response and the state that follows.

01Recognize the pattern02Capture the evidence03Verify one change
01 / START WITH WHAT YOU CAN OBSERVE

A familiar failure.
A useful next check.

Choose the pattern closest to yours. Each one gives you evidence to gather and an explanation to test.

Find your next checkGUIDED CHECKLIST
What do you notice?

Several causes can produce the same symptom. Use these checks to test an explanation.

Timing & readiness

Check the state the test is waiting for.

A button can be clickable while the application is still loading or saving. Look at what the test expects immediately before and after the action.

  1. Read the failed action’s log and DOM snapshots. Was the target ready, or did the expected result never appear?

  2. Wait for an observable application state with a retrying assertion. A fixed sleep does not tell you whether that state is ready.

KEEP THIS EVIDENCE

The failed assertion, the preceding action, and the UI state in both runs.

NEXT EXPERIMENT

Try one condition-based wait or assertion, then repeat in the environment that failed.

Playwright’s retrying assertions

Take these checks into your issue.
02 / MAKE THE NEXT RUN USEFUL

Keep the failure.
Learn from the trace.

  1. Keep the failure visible

    Repeat a focused test with retries disabled for the investigation. Keep the browser, environment, and data conditions that matter.

  2. Compare the first difference

    Open the HTML report and compare traces. Inspect the action, DOM state, console, and relevant network activity before the failure.

  3. Verify one change

    Test one explanation at a time, then repeat with fresh setup and the original suite conditions. Several passes are evidence, not a guarantee.

Explore Playwright’s Trace Viewer
A FOCUSED LOCAL INVESTIGATION
npx playwright test tests/checkout.spec.ts \
  --retries=0 --repeat-each=5 \
  --trace=on --reporter=html
0 retries
Keep each failed attempt visible.
5 repetitions
Look for a pattern across runs.
Traces + report
Compare what happened before the failure.

Replace tests/checkout.spec.ts with your test file. Keep the failing browser and environment; tracing every attempt is for this focused investigation.

Playwright command reference
03 / ADD THE PATH YOU CAN REPRODUCE

Keep the steps
that triggered it.

When you can reproduce the issue by hand, record the steps with Samelogic. Replay the sequence, inspect the affected element, and add a note for the receiving engineer.

PLAYWRIGHT TRACE

The automated actions, snapshots, and network evidence from the test.

SAMELOGIC RECORDING

The manual browser path, inspected element, and your explanation of the issue.

Add to ChromeFree extension for desktop Chrome. Try it before signing up.
A BROWSER PATH WORTH KEEPINGSample recording
Renewal quote mismatchbilling.example / renewal
  1. Open seat renewal
  2. Click “Add seat”
  3. Click “Add seat” again
  4. Calculate renewal
NOTE ON THE AFFECTED ELEMENT

Three seats on screen.
Two in the quote.

The second click is the context to keep.
Explore this recording
FOLLOW THE EVIDENCE

Go deeper
where it matters.

Explore all workflows
BEFORE YOU CHANGE THE TEST

Good questions.
Clear answers.

What makes a Playwright test flaky?

A flaky test passes and fails without an intentional change to the behavior being tested. Common sources include timing, shared state, test data, network behavior, and locator changes. The symptom gives you a place to investigate; it does not identify the cause by itself.

Should I increase retries or timeouts?

Retries can keep a pipeline moving and help collect evidence, but a passing retry does not explain the original failure. Keep the failed attempt visible while investigating. Change a timeout when the expected operation legitimately needs longer, and check the condition you are waiting for before adding a fixed delay.

Why does it pass locally and fail in CI?

Compare browser and operating-system versions, worker count, service access, environment configuration, account permissions, and test data. Resource or timing differences can expose a problem that is hard to observe locally. Reproduce the relevant CI conditions and use the trace to decide what to check next.

Can Samelogic run or diagnose my Playwright suite?

Samelogic does not run your CI suite or automatically diagnose every failure. Use Playwright’s reports and traces for the automated run. If you can reproduce the issue manually, use the extension to record the browser steps, replay them, inspect an element, and share context with the receiving engineer.

Does the checklist analyze my trace?

No. Choose an observed pattern to see suggested checks and copy an investigation outline. Nothing is uploaded or analyzed. Run the checks against your own test and record what you find.

Can I try the extension before signing up?

Yes. Install the free extension in desktop Chrome and try recording and inspecting a browser flow. An account is needed to save recordings to a workspace and share them. Review the recording and its access settings before sharing.

How Playwright handles retries
MAKE THE HANDOFF USEFUL

Give the fix
a clear starting point.

Record the browser steps your teammate needs to investigate. Keep the relevant moment and element close to the issue.