protocol/page
⚙️ This module was generated from the Chrome DevTools Protocol version 1.3
Page Domain
Actions and events related to the inspected page belong to the page domain.
📖 View this domain on the DevTools Protocol API Docs
Types
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command add_script_to_evaluate_on_new_document
pub type AddScriptToEvaluateOnNewDocumentResponse {
AddScriptToEvaluateOnNewDocumentResponse(
identifier: ScriptIdentifier,
)
}
Constructors
-
AddScriptToEvaluateOnNewDocumentResponse( identifier: ScriptIdentifier, )
Arguments
-
identifier
Identifier of the added script.
-
Error while paring app manifest.
pub type AppManifestError {
AppManifestError(
message: String,
critical: Int,
line: Int,
column: Int,
)
}
Constructors
-
AppManifestError( message: String, critical: Int, line: Int, column: Int, )
Arguments
-
message
Error message.
-
critical
If critical, this is a non-recoverable parse error.
-
line
Error line.
-
column
Error column.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the possible values of the enum property format
of captureScreenshot
pub type CaptureScreenshotFormat {
CaptureScreenshotFormatJpeg
CaptureScreenshotFormatPng
CaptureScreenshotFormatWebp
}
Constructors
-
CaptureScreenshotFormatJpeg
-
CaptureScreenshotFormatPng
-
CaptureScreenshotFormatWebp
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command capture_screenshot
pub type CaptureScreenshotResponse {
CaptureScreenshotResponse(data: String)
}
Constructors
-
CaptureScreenshotResponse(data: String)
Arguments
-
data
Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command create_isolated_world
pub type CreateIsolatedWorldResponse {
CreateIsolatedWorldResponse(
execution_context_id: runtime.ExecutionContextId,
)
}
Constructors
-
CreateIsolatedWorldResponse( execution_context_id: runtime.ExecutionContextId, )
Arguments
-
execution_context_id
Execution context of the isolated world.
-
Javascript dialog type.
pub type DialogType {
DialogTypeAlert
DialogTypeConfirm
DialogTypePrompt
DialogTypeBeforeunload
}
Constructors
-
DialogTypeAlert
-
DialogTypeConfirm
-
DialogTypePrompt
-
DialogTypeBeforeunload
Information about the Frame on the page.
pub type Frame {
Frame(
id: FrameId,
parent_id: option.Option(FrameId),
loader_id: network.LoaderId,
name: option.Option(String),
url: String,
security_origin: String,
mime_type: String,
)
}
Constructors
-
Frame( id: FrameId, parent_id: option.Option(FrameId), loader_id: network.LoaderId, name: option.Option(String), url: String, security_origin: String, mime_type: String, )
Arguments
-
id
Frame unique identifier.
-
parent_id
Parent frame identifier.
-
loader_id
Identifier of the loader associated with this frame.
-
name
Frame’s name as specified in the tag.
-
url
Frame document’s URL without fragment.
-
security_origin
Frame document’s security origin.
-
mime_type
Frame document’s mimeType as determined by the browser.
-
Unique frame identifier.
pub type FrameId {
FrameId(String)
}
Constructors
-
FrameId(String)
Information about the Frame hierarchy.
pub type FrameTree {
FrameTree(
frame: Frame,
child_frames: option.Option(List(FrameTree)),
)
}
Constructors
-
FrameTree( frame: Frame, child_frames: option.Option(List(FrameTree)), )
Arguments
-
frame
Frame information for this tree item.
-
child_frames
Child frames.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_app_manifest
pub type GetAppManifestResponse {
GetAppManifestResponse(
url: String,
errors: List(AppManifestError),
data: option.Option(String),
)
}
Constructors
-
GetAppManifestResponse( url: String, errors: List(AppManifestError), data: option.Option(String), )
Arguments
-
url
Manifest location.
-
data
Manifest content.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_frame_tree
pub type GetFrameTreeResponse {
GetFrameTreeResponse(frame_tree: FrameTree)
}
Constructors
-
GetFrameTreeResponse(frame_tree: FrameTree)
Arguments
-
frame_tree
Present frame tree structure.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_layout_metrics
pub type GetLayoutMetricsResponse {
GetLayoutMetricsResponse(
css_layout_viewport: LayoutViewport,
css_visual_viewport: VisualViewport,
css_content_size: dom.Rect,
)
}
Constructors
-
GetLayoutMetricsResponse( css_layout_viewport: LayoutViewport, css_visual_viewport: VisualViewport, css_content_size: dom.Rect, )
Arguments
-
css_layout_viewport
Metrics relating to the layout viewport in CSS pixels.
-
css_visual_viewport
Metrics relating to the visual viewport in CSS pixels.
-
css_content_size
Size of scrollable area in CSS pixels.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_navigation_history
pub type GetNavigationHistoryResponse {
GetNavigationHistoryResponse(
current_index: Int,
entries: List(NavigationEntry),
)
}
Constructors
-
GetNavigationHistoryResponse( current_index: Int, entries: List(NavigationEntry), )
Arguments
-
current_index
Index of the current navigation history entry.
-
entries
Array of navigation history entries.
-
Layout viewport position and dimensions.
pub type LayoutViewport {
LayoutViewport(
page_x: Int,
page_y: Int,
client_width: Int,
client_height: Int,
)
}
Constructors
-
LayoutViewport( page_x: Int, page_y: Int, client_width: Int, client_height: Int, )
Arguments
-
page_x
Horizontal offset relative to the document (CSS pixels).
-
page_y
Vertical offset relative to the document (CSS pixels).
-
client_width
Width (CSS pixels), excludes scrollbar if present.
-
client_height
Height (CSS pixels), excludes scrollbar if present.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command navigate
pub type NavigateResponse {
NavigateResponse(
frame_id: FrameId,
loader_id: option.Option(network.LoaderId),
error_text: option.Option(String),
)
}
Constructors
-
NavigateResponse( frame_id: FrameId, loader_id: option.Option(network.LoaderId), error_text: option.Option(String), )
Arguments
-
frame_id
Frame id that has navigated (or failed to navigate)
-
loader_id
Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.
-
error_text
User friendly error message, present if and only if navigation has failed.
-
Navigation history entry.
pub type NavigationEntry {
NavigationEntry(
id: Int,
url: String,
user_typed_url: String,
title: String,
transition_type: TransitionType,
)
}
Constructors
-
NavigationEntry( id: Int, url: String, user_typed_url: String, title: String, transition_type: TransitionType, )
Arguments
-
id
Unique id of the navigation history entry.
-
url
URL of the navigation history entry.
-
user_typed_url
URL that the user typed in the url bar.
-
title
Title of the navigation history entry.
-
transition_type
Transition type.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command print_to_pdf
pub type PrintToPdfResponse {
PrintToPdfResponse(data: String)
}
Constructors
-
PrintToPdfResponse(data: String)
Arguments
-
data
Base64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)
-
Unique script identifier.
pub type ScriptIdentifier {
ScriptIdentifier(String)
}
Constructors
-
ScriptIdentifier(String)
Transition type.
pub type TransitionType {
TransitionTypeLink
TransitionTypeTyped
TransitionTypeAddressBar
TransitionTypeAutoBookmark
TransitionTypeAutoSubframe
TransitionTypeManualSubframe
TransitionTypeGenerated
TransitionTypeAutoToplevel
TransitionTypeFormSubmit
TransitionTypeReload
TransitionTypeKeyword
TransitionTypeKeywordGenerated
TransitionTypeOther
}
Constructors
-
TransitionTypeLink
-
TransitionTypeTyped
-
TransitionTypeAddressBar
-
TransitionTypeAutoBookmark
-
TransitionTypeAutoSubframe
-
TransitionTypeManualSubframe
-
TransitionTypeGenerated
-
TransitionTypeAutoToplevel
-
TransitionTypeFormSubmit
-
TransitionTypeReload
-
TransitionTypeKeyword
-
TransitionTypeKeywordGenerated
-
TransitionTypeOther
Viewport for capturing screenshot.
pub type Viewport {
Viewport(
x: Float,
y: Float,
width: Float,
height: Float,
scale: Float,
)
}
Constructors
-
Viewport( x: Float, y: Float, width: Float, height: Float, scale: Float, )
Arguments
-
x
X offset in device independent pixels (dip).
-
y
Y offset in device independent pixels (dip).
-
width
Rectangle width in device independent pixels (dip).
-
height
Rectangle height in device independent pixels (dip).
-
scale
Page scale factor.
-
Visual viewport position, dimensions, and scale.
pub type VisualViewport {
VisualViewport(
offset_x: Float,
offset_y: Float,
page_x: Float,
page_y: Float,
client_width: Float,
client_height: Float,
scale: Float,
zoom: option.Option(Float),
)
}
Constructors
-
VisualViewport( offset_x: Float, offset_y: Float, page_x: Float, page_y: Float, client_width: Float, client_height: Float, scale: Float, zoom: option.Option(Float), )
Arguments
-
offset_x
Horizontal offset relative to the layout viewport (CSS pixels).
-
offset_y
Vertical offset relative to the layout viewport (CSS pixels).
-
page_x
Horizontal offset relative to the document (CSS pixels).
-
page_y
Vertical offset relative to the document (CSS pixels).
-
client_width
Width (CSS pixels), excludes scrollbar if present.
-
client_height
Height (CSS pixels), excludes scrollbar if present.
-
scale
Scale relative to the ideal viewport (size at width=device-width).
-
zoom
Page zoom factor (CSS to device independent pixels ratio).
-
Functions
pub fn add_script_to_evaluate_on_new_document(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
source source: String,
) -> Result(
AddScriptToEvaluateOnNewDocumentResponse,
RequestError,
)
Evaluates given script in every frame upon creation (before loading frame’s scripts).
Parameters:
source
Returns:
identifier
: Identifier of the added script.
pub fn bring_to_front(
callback__: fn(String, Option(a)) -> b,
) -> b
Brings page to front (activates tab).
pub fn capture_screenshot(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
format format: Option(CaptureScreenshotFormat),
quality quality: Option(Int),
clip clip: Option(Viewport),
) -> Result(CaptureScreenshotResponse, RequestError)
Capture page screenshot.
Parameters:
format
: Image compression format (defaults to png).quality
: Compression quality from range [0..100] (jpeg only).clip
: Capture the screenshot of a given region only.
Returns:
data
: Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
pub fn close(callback__: fn(String, Option(a)) -> b) -> b
Tries to close page, running its beforeunload hooks, if any.
pub fn create_isolated_world(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
frame_id frame_id: FrameId,
world_name world_name: Option(String),
grant_univeral_access grant_univeral_access: Option(Bool),
) -> Result(CreateIsolatedWorldResponse, RequestError)
Creates an isolated world for the given frame.
Parameters:
frame_id
: Id of the frame in which the isolated world should be created.world_name
: An optional name which is reported in the Execution Context.grant_univeral_access
: Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution.
Returns:
execution_context_id
: Execution context of the isolated world.
pub fn disable(callback__: fn(String, Option(a)) -> b) -> b
Disables page domain notifications.
pub fn enable(callback__: fn(String, Option(a)) -> b) -> b
Enables page domain notifications.
pub fn get_app_manifest(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
manifest_id manifest_id: Option(String),
) -> Result(GetAppManifestResponse, RequestError)
Gets the processed manifest for this current document. This API always waits for the manifest to be loaded. If manifestId is provided, and it does not match the manifest of the current document, this API errors out. If there is not a loaded page, this API errors out immediately.
Parameters:
manifest_id
Returns:
url
: Manifest location.errors
data
: Manifest content.
pub fn get_frame_tree(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(GetFrameTreeResponse, RequestError)
Returns present frame tree structure.
frame_tree
: Present frame tree structure.
pub fn get_layout_metrics(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(GetLayoutMetricsResponse, RequestError)
Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
css_layout_viewport
: Metrics relating to the layout viewport in CSS pixels.css_visual_viewport
: Metrics relating to the visual viewport in CSS pixels.css_content_size
: Size of scrollable area in CSS pixels.
pub fn get_navigation_history(
callback__: fn(String, Option(a)) ->
Result(Dynamic, RequestError),
) -> Result(GetNavigationHistoryResponse, RequestError)
Returns navigation history for the current page.
current_index
: Index of the current navigation history entry.entries
: Array of navigation history entries.
pub fn handle_java_script_dialog(
callback__: fn(String, Option(Json)) -> a,
accept accept: Bool,
prompt_text prompt_text: Option(String),
) -> a
Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
Parameters:
accept
: Whether to accept or dismiss the dialog.prompt_text
: The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.
Returns:
pub fn navigate(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
url url: String,
referrer referrer: Option(String),
transition_type transition_type: Option(TransitionType),
frame_id frame_id: Option(FrameId),
) -> Result(NavigateResponse, RequestError)
Navigates current page to the given URL.
Parameters:
url
: URL to navigate the page to.referrer
: Referrer URL.transition_type
: Intended transition type.frame_id
: Frame id to navigate, if not specified navigates the top frame.
Returns:
frame_id
: Frame id that has navigated (or failed to navigate)loader_id
: Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.error_text
: User friendly error message, present if and only if navigation has failed.
pub fn navigate_to_history_entry(
callback__: fn(String, Option(Json)) -> a,
entry_id entry_id: Int,
) -> a
Navigates current page to the given history entry.
Parameters:
entry_id
: Unique id of the entry to navigate to.
Returns:
pub fn print_to_pdf(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
landscape landscape: Option(Bool),
display_header_footer display_header_footer: Option(Bool),
print_background print_background: Option(Bool),
scale scale: Option(Float),
paper_width paper_width: Option(Float),
paper_height paper_height: Option(Float),
margin_top margin_top: Option(Float),
margin_bottom margin_bottom: Option(Float),
margin_left margin_left: Option(Float),
margin_right margin_right: Option(Float),
page_ranges page_ranges: Option(String),
header_template header_template: Option(String),
footer_template footer_template: Option(String),
prefer_css_page_size prefer_css_page_size: Option(Bool),
) -> Result(PrintToPdfResponse, RequestError)
Print page as PDF.
Parameters:
landscape
: Paper orientation. Defaults to false.display_header_footer
: Display header and footer. Defaults to false.print_background
: Print background graphics. Defaults to false.scale
: Scale of the webpage rendering. Defaults to 1.paper_width
: Paper width in inches. Defaults to 8.5 inches.paper_height
: Paper height in inches. Defaults to 11 inches.margin_top
: Top margin in inches. Defaults to 1cm (~0.4 inches).margin_bottom
: Bottom margin in inches. Defaults to 1cm (~0.4 inches).margin_left
: Left margin in inches. Defaults to 1cm (~0.4 inches).margin_right
: Right margin in inches. Defaults to 1cm (~0.4 inches).page_ranges
: Paper ranges to print, one based, e.g., ‘1-5, 8, 11-13’. Pages are printed in the document order, not in the order specified, and no more than once. Defaults to empty string, which implies the entire document is printed. The page numbers are quietly capped to actual page count of the document, and ranges beyond the end of the document are ignored. If this results in no pages to print, an error is reported. It is an error to specify a range with start greater than end.header_template
: HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:date
: formatted print datetitle
: document titleurl
: document locationpageNumber
: current page numbertotalPages
: total pages in the document
For example, <span class=title></span>
would generate span containing the title.
footer_template
: HTML template for the print footer. Should use the same format as theheaderTemplate
.prefer_css_page_size
: Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
Returns:
data
: Base64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)
pub fn reload(
callback__: fn(String, Option(Json)) -> a,
ignore_cache ignore_cache: Option(Bool),
script_to_evaluate_on_load script_to_evaluate_on_load: Option(
String,
),
) -> a
Reloads given page optionally ignoring the cache.
Parameters:
ignore_cache
: If true, browser cache is ignored (as if the user pressed Shift+refresh).script_to_evaluate_on_load
: If set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.
Returns:
pub fn remove_script_to_evaluate_on_new_document(
callback__: fn(String, Option(Json)) -> a,
identifier identifier: ScriptIdentifier,
) -> a
Removes given script from the list.
Parameters:
identifier
Returns:
pub fn reset_navigation_history(
callback__: fn(String, Option(a)) -> b,
) -> b
Resets navigation history for the current page.
pub fn set_bypass_csp(
callback__: fn(String, Option(Json)) -> a,
enabled enabled: Bool,
) -> a
Enable page Content Security Policy by-passing.
Parameters:
enabled
: Whether to bypass page CSP.
Returns:
pub fn set_document_content(
callback__: fn(String, Option(Json)) -> a,
frame_id frame_id: FrameId,
html html: String,
) -> a
Sets given markup as the document’s HTML.
Parameters:
frame_id
: Frame id to set HTML for.html
: HTML content to set.
Returns:
pub fn set_intercept_file_chooser_dialog(
callback__: fn(String, Option(Json)) -> a,
enabled enabled: Bool,
) -> a
Intercept file chooser requests and transfer control to protocol clients.
When file chooser interception is enabled, native file chooser dialog is not shown.
Instead, a protocol event Page.fileChooserOpened
is emitted.
Parameters:
enabled
Returns:
pub fn set_lifecycle_events_enabled(
callback__: fn(String, Option(Json)) -> a,
enabled enabled: Bool,
) -> a
Controls whether page will emit lifecycle events.
Parameters:
enabled
: If true, starts emitting lifecycle events.
Returns:
pub fn stop_loading(callback__: fn(String, Option(a)) -> b) -> b
Force the page stop all navigations and pending resource fetches.