Page Domain
Actions and events related to the inspected page belong to the page domain.
Methods
- Page.addScriptToEvaluateOnNewDocument
- Page.bringToFront
- Page.captureScreenshot
- Page.close
- Page.createIsolatedWorld
- Page.disable
- Page.enable
- Page.getAppManifest
- Page.getFrameTree
- Page.getLayoutMetrics
- Page.getNavigationHistory
- Page.handleJavaScriptDialog
- Page.navigate
- Page.navigateToHistoryEntry
- Page.printToPDF
- Page.reload
- Page.removeScriptToEvaluateOnNewDocument
- Page.resetNavigationHistory
- Page.setBypassCSP
- Page.setDocumentContent
- Page.setInterceptFileChooserDialog
- Page.setLifecycleEventsEnabled
- Page.stopLoading
Events
- Page.domContentEventFired
- Page.fileChooserOpened
- Page.frameAttached
- Page.frameDetached
- Page.frameNavigated
- Page.interstitialHidden
- Page.interstitialShown
- Page.javascriptDialogClosed
- Page.javascriptDialogOpening
- Page.lifecycleEvent
- Page.loadEventFired
- Page.windowOpen
Types
Methods
Page.addScriptToEvaluateOnNewDocument #
Evaluates given script in every frame upon creation (before loading frame's scripts).
Parameters
source stringworldNameOptional
stringIf specified, creates an isolated world with the given name and evaluates given script in it. This world name will be used as the ExecutionContextDescription::name when the corresponding event is emitted.
includeCommandLineAPIOptional
booleanSpecifies whether command line API should be available to the script, defaults to false.
runImmediatelyOptional
booleanIf true, runs the script immediately on existing execution contexts or worlds. Default: false.
Return object
identifier Identifier of the added script.
Page.captureScreenshot #
Capture page screenshot.
Parameters
formatOptional
stringImage compression format (defaults to png).
Allowed values: jpeg, png, webp
qualityOptional
integerCompression quality from range [0..100] (jpeg only).
clipOptional
Capture the screenshot of a given region only.
fromSurfaceOptional
booleanCapture the screenshot from the surface, rather than the view. Defaults to true.
captureBeyondViewportOptional
booleanCapture the screenshot beyond the viewport. Defaults to false.
optimizeForSpeedOptional
booleanOptimize image encoding for speed, not for resulting size (defaults to false)
Return object
data stringBase64-encoded image data. (Encoded as a base64 string when passed over JSON)
Page.createIsolatedWorld #
Creates an isolated world for the given frame.
Parameters
frameId Id of the frame in which the isolated world should be created.
worldNameOptional
stringAn optional name which is reported in the Execution Context.
grantUniveralAccessOptional
booleanWhether or not universal access should be granted to the isolated world. This is a powerful option, use with caution.
Return object
executionContextId Execution context of the isolated world.
Page.enable #
Enables page domain notifications.
Parameters
enableFileChooserOpenedEventOptional
booleanIf true, the Page.fileChooserOpened event will be emitted regardless of the state set by
Page.setInterceptFileChooserDialog command (default: false).
Page.getAppManifest #
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
manifestIdOptional
stringReturn object
url stringManifest location.
errors array[ AppManifestError ]dataOptional
stringManifest content.
parsedOptional
Parsed manifest properties. Deprecated, use manifest instead.
manifest Page.getFrameTree #
Returns present frame tree structure.
Return object
frameTree Present frame tree structure.
Page.getLayoutMetrics #
Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
Return object
layoutViewport Deprecated metrics relating to the layout viewport. Is in device pixels. Use cssLayoutViewport instead.
visualViewport Deprecated metrics relating to the visual viewport. Is in device pixels. Use cssVisualViewport instead.
contentSize cssLayoutViewport Metrics relating to the layout viewport in CSS pixels.
cssVisualViewport Metrics relating to the visual viewport in CSS pixels.
cssContentSize Size of scrollable area in CSS pixels.
Page.getNavigationHistory #
Returns navigation history for the current page.
Return object
currentIndex integerIndex of the current navigation history entry.
entries array[ NavigationEntry ]Array of navigation history entries.
Page.handleJavaScriptDialog #
Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
Parameters
accept booleanWhether to accept or dismiss the dialog.
promptTextOptional
stringThe text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.
Page.navigate #
Navigates current page to the given URL.
Parameters
url stringURL to navigate the page to.
referrerOptional
stringReferrer URL.
transitionTypeOptional
Intended transition type.
frameIdOptional
Frame id to navigate, if not specified navigates the top frame.
referrerPolicyOptional
Return object
frameId Frame id that has navigated (or failed to navigate)
loaderIdOptional
Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.
errorTextOptional
stringUser friendly error message, present if and only if navigation has failed.
isDownloadOptional
booleanWhether the navigation resulted in a download.
Page.navigateToHistoryEntry #
Navigates current page to the given history entry.
Parameters
entryId integerUnique id of the entry to navigate to.
Page.printToPDF #
Print page as PDF.
Parameters
landscapeOptional
booleanPaper orientation. Defaults to false.
displayHeaderFooterOptional
booleanDisplay header and footer. Defaults to false.
printBackgroundOptional
booleanPrint background graphics. Defaults to false.
scaleOptional
numberScale of the webpage rendering. Defaults to 1.
paperWidthOptional
numberPaper width in inches. Defaults to 8.5 inches.
paperHeightOptional
numberPaper height in inches. Defaults to 11 inches.
marginTopOptional
numberTop margin in inches. Defaults to 1cm (~0.4 inches).
marginBottomOptional
numberBottom margin in inches. Defaults to 1cm (~0.4 inches).
marginLeftOptional
numberLeft margin in inches. Defaults to 1cm (~0.4 inches).
marginRightOptional
numberRight margin in inches. Defaults to 1cm (~0.4 inches).
pageRangesOptional
stringPaper 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.
headerTemplateOptional
stringHTML 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.
footerTemplateOptional
stringHTML template for the print footer. Should use the same format as the headerTemplate.
preferCSSPageSizeOptional
booleanWhether 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.
transferModeOptional
stringreturn as stream
Allowed values: ReturnAsBase64, ReturnAsStream
generateTaggedPDFOptional
booleanWhether or not to generate tagged (accessible) PDF. Defaults to embedder choice.
generateDocumentOutlineOptional
booleanWhether or not to embed the document outline into the PDF.
Return object
data stringBase64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)
streamOptional
Page.reload #
Reloads given page optionally ignoring the cache.
It isn't clear what the ignoreCache parameter of @cdp Page.reload should mean in React Native. We parse it, but don't do anything with it yet.
TODO: Implement scriptToEvaluateOnLoad parameter of @cdp Page.reload.
Parameters
ignoreCacheOptional
booleanIf true, browser cache is ignored (as if the user pressed Shift+refresh).
scriptToEvaluateOnLoadOptional
stringIf set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.
loaderIdOptional
If set, an error will be thrown if the target page's main frame's loader id does not match the provided id. This prevents accidentally reloading an unintended target in case there's a racing navigation.
Page.setBypassCSP #
Enable page Content Security Policy by-passing.
Parameters
enabled booleanWhether to bypass page CSP.
Page.setDocumentContent #
Sets given markup as the document's HTML.
Parameters
frameId Frame id to set HTML for.
html stringHTML content to set.
Page.setInterceptFileChooserDialog #
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 booleancancelOptional
booleanIf true, cancels the dialog by emitting relevant events (if any) in addition to not showing it if the interception is enabled (default: false).
Page.setLifecycleEventsEnabled #
Controls whether page will emit lifecycle events.
Parameters
enabled booleanIf true, starts emitting lifecycle events.
Events
Page.fileChooserOpened #
Emitted only when page.interceptFileChooser is enabled.
Parameters
frameId mode stringInput mode.
Allowed values: selectSingle, selectMultiple
backendNodeIdOptional
Input node id. Only present for file choosers opened via an <input type="file"> element.
Page.frameAttached #
Fired when frame has been attached to its parent.
Parameters
frameId Id of the frame that has been attached.
parentFrameId Parent frame identifier.
stackOptional
JavaScript stack trace of when frame was attached, only set if frame initiated from script.
Page.frameDetached #
Fired when frame has been detached from its parent.
Parameters
frameId Id of the frame that has been detached.
reason stringAllowed values: remove, swap
Page.frameNavigated #
Fired once navigation of the frame has completed. Frame is now associated with the new loader.
Parameters
frame Frame object.
type Page.javascriptDialogClosed #
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.
Parameters
frameId result booleanWhether dialog was confirmed.
userInput stringUser input in case of prompt.
Page.javascriptDialogOpening #
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.
Parameters
url stringFrame url.
frameId message stringMessage that will be displayed by the dialog.
type Dialog type.
hasBrowserHandler booleanTrue iff browser is capable showing or acting on the given dialog. When browser has no dialog handler for given target, calling alert while Page domain is engaged will stall the page execution. Execution can be resumed via calling Page.handleJavaScriptDialog.
defaultPromptOptional
stringDefault dialog prompt.
Page.lifecycleEvent #
Fired for lifecycle events (navigation, load, paint, etc) in the current target (including local frames).
Parameters
frameId Id of the frame.
loaderId Loader identifier. Empty string if the request is fetched from worker.
name stringtimestamp Page.windowOpen #
Fired when a new window is going to be opened, via window.open(), link click, form submission, etc.
Parameters
url stringThe URL for the new window.
windowName stringWindow name.
windowFeatures array[ string ]An array of enabled window features.
userGesture booleanWhether or not it was triggered by user gesture.
Types
Page.AppManifestError #
Error while paring app manifest.
Type: object
Properties
message stringError message.
critical integerIf critical, this is a non-recoverable parse error.
line integerError line.
column integerError column.
Page.DialogType #
Javascript dialog type.
Type: string
Allowed values: alert, confirm, prompt, beforeunload
Page.Frame #
Information about the Frame on the page.
Type: object
Properties
id Frame unique identifier.
parentIdOptional
Parent frame identifier.
loaderId Identifier of the loader associated with this frame.
nameOptional
stringFrame's name as specified in the tag.
url stringFrame document's URL without fragment.
urlFragmentOptional
stringFrame document's URL fragment including the '#'.
domainAndRegistry stringFrame document's registered domain, taking the public suffixes list into account. Extracted from the Frame's url. Example URLs: http://www.google.com/file.html -> "google.com" http://a.b.co.uk/file.html -> "b.co.uk"
securityOrigin stringFrame document's security origin.
securityOriginDetailsOptional
mimeType stringFrame document's mimeType as determined by the browser.
unreachableUrlOptional
stringIf the frame failed to load, this contains the URL that could not be loaded. Note that unlike url above, this URL may contain a fragment.
adFrameStatusOptional
secureContextType Indicates whether the main document is a secure context and explains why that is the case.
crossOriginIsolatedContextType Indicates whether this is a cross origin isolated context.
gatedAPIFeatures Page.FrameTree #
Information about the Frame hierarchy.
Type: object
Properties
frame Frame information for this tree item.
childFramesOptional
array[ FrameTree ]Child frames.
Page.LayoutViewport #
Layout viewport position and dimensions.
Type: object
Properties
pageX integerHorizontal offset relative to the document (CSS pixels).
pageY integerVertical offset relative to the document (CSS pixels).
clientWidth integerWidth (CSS pixels), excludes scrollbar if present.
clientHeight integerHeight (CSS pixels), excludes scrollbar if present.
Page.NavigationEntry #
Navigation history entry.
Type: object
Properties
id integerUnique id of the navigation history entry.
url stringURL of the navigation history entry.
userTypedURL stringURL that the user typed in the url bar.
title stringTitle of the navigation history entry.
transitionType Transition type.
Page.TransitionType #
Transition type.
Type: string
Allowed values: link, typed, address_bar, auto_bookmark, auto_subframe, manual_subframe, generated, auto_toplevel, form_submit, reload, keyword, keyword_generated, other
Page.Viewport #
Viewport for capturing screenshot.
Type: object
Properties
x numberX offset in device independent pixels (dip).
y numberY offset in device independent pixels (dip).
width numberRectangle width in device independent pixels (dip).
height numberRectangle height in device independent pixels (dip).
scale numberPage scale factor.
Page.VisualViewport #
Visual viewport position, dimensions, and scale.
Type: object
Properties
offsetX numberHorizontal offset relative to the layout viewport (CSS pixels).
offsetY numberVertical offset relative to the layout viewport (CSS pixels).
pageX numberHorizontal offset relative to the document (CSS pixels).
pageY numberVertical offset relative to the document (CSS pixels).
clientWidth numberWidth (CSS pixels), excludes scrollbar if present.
clientHeight numberHeight (CSS pixels), excludes scrollbar if present.
scale numberScale relative to the ideal viewport (size at width=device-width).
zoomOptional
numberPage zoom factor (CSS to device independent pixels ratio).