await dialog.accept(); console.log("message is = "+dialog.message());
}); // await page.pause(); await page.locator("#confirmbtn").click(); await page.waitForEvent(); //waits for 30 sec and throw error // await page.waitForTimeout(4000); I used this to solve it but its like thread.sleep()
This thread is trying to answer question "Why does Playwright page.waitForEvent('dialog') throw an error after waiting for 30 seconds and how can it be resolved?"
You have an event listener set up with page.on('dialog', ...), you might not need to use page.waitForEvent('dialog') at all. Once the dialog pops up, your event listener should handle it.
Also, keep in mind that page.waitForEvent() will wait indefinitely if the specified event does not occur, unless you specify a timeout.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email email@example.com.