WebPage#
Superclasses: Object
A loaded web page.
Methods#
- class WebPage
-
- get_form_manager(world: ScriptWorld | None = None) WebFormManager#
Get the
WebFormManagerofweb_pageinworld.Added in version 2.40.
- Parameters:
world – a
ScriptWorld
- get_main_frame() Frame#
Returns the main frame of a
WebPage.Added in version 2.2.
Deprecated since version 2.48: Please do not use it in newly written code
- get_uri() str#
Returns the current active URI of
web_page.You can monitor the active URI by connecting to the notify::uri signal of
web_page.
- async send_message_to_view(self, message: UserMessage) UserMessage#
This is the awaitable version of
send_message_to_view().Added in version 2.28.
- Parameters:
message – a
UserMessage
- send_message_to_view(message: UserMessage, cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None#
Send
messageto theWebKitWebViewcorresponding toweb_page. Ifmessageis floating, it’s consumed.If you don’t expect any reply, or you simply want to ignore it, you can pass
Noneascallback. When the operation is finished,callbackwill be called. You can then callsend_message_to_view_finish()to get the message reply.Added in version 2.28.
- Parameters:
message – a
UserMessagecancellable – a
CancellableorNoneto ignorecallback – A
AsyncReadyCallbackto call when the request is satisfied orNoneuser_data – the data to pass to callback function
- send_message_to_view_finish(result: AsyncResult) UserMessage#
Finish an asynchronous operation started with
send_message_to_view().Added in version 2.28.
- Parameters:
result – a
AsyncResult
Properties#
Signals#
- class WebPage.signals
- console_message_sent(console_message: ConsoleMessage) None#
Emitted when a message is sent to the console. This can be a message produced by the use of JavaScript console API, a JavaScript exception, a security error or other errors, warnings, debug or log messages. The
console_messagecontains information of the message.Added in version 2.12.
- Parameters:
console_message – the
ConsoleMessage
Emitted before a context menu is displayed in the UI Process to give the application a chance to customize the proposed menu, build its own context menu or pass user data to the UI Process. This signal is useful when the information available in the UI Process is not enough to build or customize the context menu, for example, to add menu entries depending on the node at the coordinates of the
hit_test_result. Otherwise, it’s recommended to useWebKitWebView::context-menu signal instead.Added in version 2.8.
- Parameters:
context_menu – the proposed
ContextMenuhit_test_result – a
WebHitTestResult
- document_loaded() None#
This signal is emitted when the DOM document of a
WebPagehas been loaded.You can wait for this signal to get the DOM document
- send_request(request: URIRequest, redirected_response: URIResponse) bool#
This signal is emitted when
requestis about to be sent to the server. This signal can be used to modify theURIRequestthat will be sent to the server. You can also cancel the resource load operation by connecting to this signal and returningTrue.In case of a server redirection this signal is emitted again with the
requestargument containing the new request to be sent to the server due to the redirection and theredirected_responseparameter containing the response received by the server for the initial request.Modifications to the
URIRequestand its associatedMessageHeaderswill be taken into account when the request is sent over the network.- Parameters:
request – a
URIRequestredirected_response – a
URIResponse, orNone
- user_message_received(message: UserMessage) bool#
This signal is emitted when a
UserMessageis received from theWebKitWebViewcorresponding toweb_page. You can reply to the message usingsend_reply().You can handle the user message asynchronously by calling
ref()onmessageand returningTrue. If the last reference ofmessageis removed and the message has been replied, the operation in theWebKitWebViewwill finish with errorUSER_MESSAGE_UNHANDLED_MESSAGE.Added in version 2.28.
- Parameters:
message – the
UserMessagereceived