70 lines
1.7 KiB
Python
70 lines
1.7 KiB
Python
|
"""
|
||
|
This type stub file was generated by pyright.
|
||
|
"""
|
||
|
|
||
|
from pyppeteer.connection import CDPSession
|
||
|
|
||
|
"""Dialog module."""
|
||
|
class Dialog:
|
||
|
"""Dialog class.
|
||
|
|
||
|
Dialog objects are dispatched by page via the ``dialog`` event.
|
||
|
|
||
|
An example of using ``Dialog`` class:
|
||
|
|
||
|
.. code::
|
||
|
|
||
|
browser = await launch()
|
||
|
page = await browser.newPage()
|
||
|
|
||
|
async def close_dialog(dialog):
|
||
|
print(dialog.message)
|
||
|
await dialog.dismiss()
|
||
|
await browser.close()
|
||
|
|
||
|
page.on(
|
||
|
'dialog',
|
||
|
lambda dialog: asyncio.ensure_future(close_dialog(dialog))
|
||
|
)
|
||
|
await page.evaluate('() => alert("1")')
|
||
|
"""
|
||
|
Type = ...
|
||
|
def __init__(self, client: CDPSession, type: str, message: str, defaultValue: str = ...) -> None:
|
||
|
...
|
||
|
|
||
|
@property
|
||
|
def type(self) -> str:
|
||
|
"""Get dialog type.
|
||
|
|
||
|
One of ``alert``, ``beforeunload``, ``confirm``, or ``prompt``.
|
||
|
"""
|
||
|
...
|
||
|
|
||
|
@property
|
||
|
def message(self) -> str:
|
||
|
"""Get dialog message."""
|
||
|
...
|
||
|
|
||
|
@property
|
||
|
def defaultValue(self) -> str:
|
||
|
"""If dialog is prompt, get default prompt value.
|
||
|
|
||
|
If dialog is not prompt, return empty string (``''``).
|
||
|
"""
|
||
|
...
|
||
|
|
||
|
async def accept(self, promptText: str = ...) -> None:
|
||
|
"""Accept the dialog.
|
||
|
|
||
|
* ``promptText`` (str): A text to enter in prompt. If the dialog's type
|
||
|
is not prompt, this does not cause any effect.
|
||
|
"""
|
||
|
...
|
||
|
|
||
|
async def dismiss(self) -> None:
|
||
|
"""Dismiss the dialog."""
|
||
|
...
|
||
|
|
||
|
|
||
|
|