Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Created June 2, 2024 22:16
Show Gist options
  • Save YumaInaura/cc1d9c724431361037f37ba3267b1f63 to your computer and use it in GitHub Desktop.
Save YumaInaura/cc1d9c724431361037f37ba3267b1f63 to your computer and use it in GitHub Desktop.
Playwright - Expect message of window.comfirm Example

Expect message and comfirm dialog

Good

  page.on('dialog', async (dialog) => {
    expect(dialog.message()).toContain('Expected Message')
    await dialog.accept()
  })

BAD

No Async / Await

  page.on('dialog', (dialog) => {
    expect(dialog.message()).toContain('Expected Message')
    dialog.accept()
  })

Ref

https://playwright.dev/docs/dialogs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment