Skip to content
CodeKruPro

Handle Sequential Dialogs

45/70

Handle Sequential Dialogs

Use page.once('dialog', ...) to handle a single dialog, or keep a counter in your page.on('dialog') handler for different responses.

Task:

  1. Navigate to https://testkru.com/Interactions/Alerts
  2. Set up a dialog handler that accepts the first dialog and prints its message
  3. Trigger the "Show Alert" button
  4. Wait briefly, then set up a new handler for the confirm dialog that dismisses it
  5. Trigger the "Show Confirm" button
  6. Print the confirm result

Expected output:

Alert: This is a simple alert!
Confirm result: You clicked: Cancel