MCPcopy Index your code
hub / github.com/microsoft/playwright-python / _on_dialog

Method _on_dialog

playwright/_impl/_browser_context.py:677–690  ·  view source on GitHub ↗
(self, dialog: Dialog)

Source from the content-addressed store, hash-verified

675 self.emit(BrowserContext.Events.Console, message)
676
677 def _on_dialog(self, dialog: Dialog) -> None:
678 has_listeners = self.emit(BrowserContext.Events.Dialog, dialog)
679 page = dialog.page
680 if page:
681 has_listeners = page.emit(Page.Events.Dialog, dialog) or has_listeners
682 if not has_listeners:
683 # Although we do similar handling on the server side, we still need this logic
684 # on the client side due to a possible race condition between two async calls:
685 # a) removing "dialog" listener subscription (client->server)
686 # b) actual "dialog" event (server->client)
687 if dialog.type == "beforeunload":
688 asyncio.create_task(dialog.accept())
689 else:
690 asyncio.create_task(dialog.dismiss())
691
692 def _on_page_error(
693 self, error: Error, page: Optional[Page], location: WebErrorLocation

Callers 1

__init__Method · 0.95

Calls 2

acceptMethod · 0.45
dismissMethod · 0.45

Tested by

no test coverage detected