1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Playwright - Javascript の Alert を検証する

Last updated at Posted at 2024-04-25

概要

デフォルトではPlaywrightは自動で Javascript の Alert を Accept するようだ

コード例

次のように書くとAlertのメッセージ内容を検証した上で、 Accept できる

  page.on('dialog', (dialog) => {
    expect(dialog.message()).toContain('アラートに表示されるメッセージ')
    dialog.accept()
  })

  await page.getByRole('button').click() // 押すとAlertが出るボタンを押す

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

プロフィール・経歴

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?