A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://playwright.bootcss.com/python/docs/api/class-dialog below:

Dialog | Playwright

Dialog objects are dispatched by page via the page.on("dialog") event.

An example of using Dialog class:

from playwright.sync_api import sync_playwright

def handle_dialog(dialog):

print(dialog.message)

dialog.dismiss()

def run(playwright):

chromium = playwright.chromium

browser = chromium.launch()

page = browser.new_page()

page.on("dialog", handle_dialog)

page.evaluate("alert('1')")

browser.close()

with sync_playwright() as playwright:

run(playwright)

import asyncio

from playwright.async_api import async_playwright

async def handle_dialog(dialog):

print(dialog.message)

await dialog.dismiss()

async def run(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())

dialog.accept(**kwargs)#

Returns when the dialog has been accepted.

dialog.default_value#

If dialog is prompt, returns default prompt value. Otherwise, returns empty string.

dialog.dismiss()#

Returns when the dialog has been dismissed.

dialog.message#

A message displayed in the dialog.

dialog.type#

Returns dialog's type, can be one of alert, beforeunload, confirm or prompt.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4