ExpertPW-DBG-00360 minutesPlaywright

Debug an unhandled dialog

A native confirm appears before the test registers its handler, leaving the flow in the wrong state.

  • debugging
  • trace-viewer
  • dialogs

Objective

What to automate

Diagnose the event ordering with trace/video/console evidence and register the handler before the click.

Preconditions and test data

Preconditions

  • Use a fresh isolated Practice Lab browser context.
  • Open the fixture identified by FX-DIALOG-001.

Test data

  • starter: examples/debugging/unhandled-dialog.spec.ts

Expected result

The diagnosis identifies late handler registration; the repaired test handles the confirm before triggering it.

Progressive hints

Hint 1

Inspect the trace action that triggered the dialog.

Hint 2

Check whether the dialog listener existed before click.

Hint 3

Register page.once(dialog) first, then click and assert the accepted result.

I’ve tried it — show solution
  1. Inspect the trace action that triggered the dialog.
  2. Check whether the dialog listener existed before click.
  3. Register page.once(dialog) first, then click and assert the accepted result.

The deliberately failing starter is in examples/debugging/unhandled-dialog.spec.ts inside the TypeScript starter ZIP.