Source code for pyppeteer.dialog

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Dialog module."""

from types import SimpleNamespace
from pyppeteer.connection import Session


[docs]class Dialog(object): """Dialog class.""" Type = SimpleNamespace( Alert='alert', BeforeUnload='beforeunload', Confirm='confirm', Prompt='prompt', ) def __init__(self, client: Session, type: str, message: str, defaultValue: str = '') -> None: """Make new dialog.""" self._client = client self._type = type self._message = message self._handled = False self._defalutValue = defaultValue @property def type(self) -> str: """Get dialog type.""" return self._type
[docs] def message(self) -> str: """Get dialog message.""" return self._message
[docs] def defaultValue(self) -> str: """Get default selected dialog value.""" return self._defalutValue
[docs] async def accept(self, promptText: str = '') -> None: """Accept the dialog.""" self._handled = True await self._client.send('Page.handleJavaScriptDialog', { 'accept': True, 'promptText': promptText, })
[docs] async def dismiss(self) -> None: """Dismiss the dialog.""" self._handled = True await self._client.send('Page.handleJavaScriptDialog', { 'accept': False, })