WebPage

class WebPage(**properties: Any)

Superclasses: Object

A loaded web page.

Methods

class WebPage
get_editor() WebEditor

Gets the WebEditor of a WebPage.

Added in version 2.10.

get_form_manager(world: ScriptWorld | None = None) WebFormManager

Get the WebFormManager of web_page in world.

Added in version 2.40.

Parameters:

world – a ScriptWorld

get_id() int

Get the identifier of the WebPage

get_main_frame() Frame

Returns the main frame of a WebPage.

Added in version 2.2.

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.

send_message_to_view(message: UserMessage, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Send message to the WebKitWebView corresponding to web_page. If message is floating, it’s consumed.

If you don’t expect any reply, or you simply want to ignore it, you can pass None as callback. When the operation is finished, callback will be called. You can then call send_message_to_view_finish() to get the message reply.

Added in version 2.28.

Parameters:
  • message – a UserMessage

  • cancellable – a Cancellable or None to ignore

  • callback – A AsyncReadyCallback to call when the request is satisfied or None

  • user_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

class WebPage
props.uri: str

The current active URI of the WebPage.

Signals

class WebPage.signals
context_menu(context_menu: ContextMenu, hit_test_result: WebHitTestResult) bool

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 use WebKitWebView::context-menu signal instead.

Added in version 2.8.

Parameters:
document_loaded() None

This signal is emitted when the DOM document of a WebPage has 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 request is about to be sent to the server. This signal can be used to modify the URIRequest that will be sent to the server. You can also cancel the resource load operation by connecting to this signal and returning True.

In case of a server redirection this signal is emitted again with the request argument containing the new request to be sent to the server due to the redirection and the redirected_response parameter containing the response received by the server for the initial request.

Modifications to the URIRequest and its associated MessageHeaders will be taken into account when the request is sent over the network.

Parameters:
user_message_received(message: UserMessage) bool

This signal is emitted when a UserMessage is received from the WebKitWebView corresponding to web_page. You can reply to the message using send_reply().

You can handle the user message asynchronously by calling ref() on message and returning True. If the last reference of message is removed and the message has been replied, the operation in the WebKitWebView will finish with error USER_MESSAGE_UNHANDLED_MESSAGE.

Added in version 2.28.

Parameters:

message – the UserMessage received