mokr.input.dialog

Classes

Dialog

Dialog objects are initialised by the parent mokr.browser.Page

Module Contents

class mokr.input.dialog.Dialog(client: mokr.connection.DevtoolsConnection, dialog_type: str, message: str, default_value: str | None = None)

Dialog objects are initialised by the parent mokr.browser.Page when a dialog event is triggered.

Parameters:
  • client (DevtoolsConnection) – A mokr.connection.DevtoolsConnection spawned by the parent mokr.browser.Page.

  • dialog_type (str) – Dialog type from the triggering event’s type.

  • message (str) – Message in the dialog.

  • default_value (str | None, optional) – Default prompt that the dialog spawned with. Defaults to None.

Example:

async def close_dialog(dialog):
    print(dialog.message)
    await dialog.dismiss()
page.on("dialog", close_dialog)
property kind: str

Get the remote Dialog event type. One of “alert”, “beforeunload, “confirm”, “prompt, or “”.

property message: str

Get the message the dialog spawned with.

property default_value: str

Get default prompt value, if remote dialog type is “prompt”. Otherwise, get “”.

async accept(prompt_text: str = '') None

Accept the remote dialog. Can optionally accept with the given prompt_text, if Dialog.type is “prompt”.

Parameters:

prompt_text (str, optional) – _description_. Defaults to ‘’.

async dismiss() None

Dismiss the remote dialog.