new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

dialog

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Dialog class overview and event dispatch

Dialog objects are dispatched by page via the Page.dialog event. Dialog objects are automatically dismissed unless there is a Page.dialog event listener. When a listener is present, it must either call Dialog.accept() or Dialog.dismiss() on the dialog, otherwise the page will freeze waiting for the dialog and actions like click will never finish.

Dialog class usage example with JavaScript

Example showing Dialog handling with JavaScript: const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch(); const page = await browser.newPage(); page.on('dialog', async dialog => { console.log(dialog.message()); await dialog.dismiss(); }); await page.evaluate(() => alert('1')); await browser.close(); })();

Dialog class usage example with Python async

Example showing Dialog handling with Python async: import asyncio; from playwright.async_api import async_playwright, Playwright; async def handle_dialog(dialog): print(dialog.message); await dialog.dismiss(); async def run(playwright: Playwright): chromium = playwright.chromium; browser = await chromium.launch(); page = await browser.new_page(); page.on("dialog", handle_dialog); page.evaluate("alert('1')"); await browser.close(); async def main(): async with async_playwright() as playwright: await run(playwright); asyncio.run(main());

Give your agent this brain