Methods

Chrome DevTools

Page.addScriptToEvaluateOnNewDocument #

Evaluates given script in every frame upon creation (before loading frame's scripts).

Parameters

source
string
worldName
Optional
string

If 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.

Experimental
includeCommandLineAPI
Optional
boolean

Specifies whether command line API should be available to the script, defaults to false.

Experimental
runImmediately
Optional
boolean

If true, runs the script immediately on existing execution contexts or worlds. Default: false.

Experimental

Return object

identifier
ScriptIdentifier

Identifier of the added script.


Chrome DevTools

Page.bringToFront #

Brings page to front (activates tab).


Chrome DevTools

Page.captureScreenshot #

Capture page screenshot.

Parameters

format
Optional
string

Image compression format (defaults to png).

Allowed values: jpeg, png, webp

quality
Optional
integer

Compression quality from range [0..100] (jpeg only).

clip
Optional
Viewport

Capture the screenshot of a given region only.

fromSurface
Optional
boolean

Capture the screenshot from the surface, rather than the view. Defaults to true.

Experimental
captureBeyondViewport
Optional
boolean

Capture the screenshot beyond the viewport. Defaults to false.

Experimental
optimizeForSpeed
Optional
boolean

Optimize image encoding for speed, not for resulting size (defaults to false)

Experimental

Return object

data
string

Base64-encoded image data. (Encoded as a base64 string when passed over JSON)


Chrome DevTools

Page.close #

Tries to close page, running its beforeunload hooks, if any.


Chrome DevTools

Page.createIsolatedWorld #

Creates an isolated world for the given frame.

Parameters

frameId
FrameId

Id of the frame in which the isolated world should be created.

worldName
Optional
string

An optional name which is reported in the Execution Context.

grantUniveralAccess
Optional
boolean

Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution.

Return object

executionContextId
Runtime.ExecutionContextId

Execution context of the isolated world.


Chrome DevTools

Page.disable #

Disables page domain notifications.


Chrome DevTools

Page.enable #

Enables page domain notifications.


Chrome DevTools

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

manifestId
Optional
string

Return object

url
string

Manifest location.

errors
data
Optional
string

Manifest content.

parsed
Optional
AppManifestParsedProperties

Parsed manifest properties. Deprecated, use manifest instead.

ExperimentalDeprecated
manifest
WebAppManifestExperimental

Chrome DevTools

Page.getFrameTree #

Returns present frame tree structure.

Return object

frameTree
FrameTree

Present frame tree structure.


Chrome DevTools

Page.getLayoutMetrics #

Returns metrics relating to the layouting of the page, such as viewport bounds/scale.

Return object

layoutViewport
LayoutViewport

Deprecated metrics relating to the layout viewport. Is in device pixels. Use cssLayoutViewport instead.

Deprecated
visualViewport
VisualViewport

Deprecated metrics relating to the visual viewport. Is in device pixels. Use cssVisualViewport instead.

Deprecated
contentSize
DOM.Rect

Deprecated size of scrollable area. Is in DP. Use cssContentSize instead.

Deprecated
cssLayoutViewport
LayoutViewport

Metrics relating to the layout viewport in CSS pixels.

cssVisualViewport
VisualViewport

Metrics relating to the visual viewport in CSS pixels.

cssContentSize
DOM.Rect

Size of scrollable area in CSS pixels.


Chrome DevTools

Page.getNavigationHistory #

Returns navigation history for the current page.

Return object

currentIndex
integer

Index of the current navigation history entry.

entries
array[ NavigationEntry ]

Array of navigation history entries.


Chrome DevTools

Page.handleJavaScriptDialog #

Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).

Parameters

accept
boolean

Whether to accept or dismiss the dialog.

promptText
Optional
string

The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.


Chrome DevTools

Page.navigate #

Navigates current page to the given URL.

Parameters

url
string

URL to navigate the page to.

referrer
Optional
string

Referrer URL.

transitionType
Optional
TransitionType

Intended transition type.

frameId
Optional
FrameId

Frame id to navigate, if not specified navigates the top frame.

referrerPolicy
Optional
ReferrerPolicy

Referrer-policy used for the navigation.

Experimental

Return object

frameId
FrameId

Frame id that has navigated (or failed to navigate)

loaderId
Optional
Network.LoaderId

Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.

errorText
Optional
string

User friendly error message, present if and only if navigation has failed.


Chrome DevTools

Page.navigateToHistoryEntry #

Navigates current page to the given history entry.

Parameters

entryId
integer

Unique id of the entry to navigate to.


Chrome DevTools

Page.printToPDF #

Print page as PDF.

Parameters

landscape
Optional
boolean

Paper orientation. Defaults to false.

displayHeaderFooter
Optional
boolean

Display header and footer. Defaults to false.

printBackground
Optional
boolean

Print background graphics. Defaults to false.

scale
Optional
number

Scale of the webpage rendering. Defaults to 1.

paperWidth
Optional
number

Paper width in inches. Defaults to 8.5 inches.

paperHeight
Optional
number

Paper height in inches. Defaults to 11 inches.

marginTop
Optional
number

Top margin in inches. Defaults to 1cm (~0.4 inches).

marginBottom
Optional
number

Bottom margin in inches. Defaults to 1cm (~0.4 inches).

marginLeft
Optional
number

Left margin in inches. Defaults to 1cm (~0.4 inches).

marginRight
Optional
number

Right margin in inches. Defaults to 1cm (~0.4 inches).

pageRanges
Optional
string

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.

headerTemplate
Optional
string

HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:

  • date: formatted print date
  • title: document title
  • url: document location
  • pageNumber: current page number
  • totalPages: total pages in the document

For example, <span class=title></span> would generate span containing the title.

footerTemplate
Optional
string

HTML template for the print footer. Should use the same format as the headerTemplate.

preferCSSPageSize
Optional
boolean

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.

transferMode
Optional
string

return as stream

Allowed values: ReturnAsBase64, ReturnAsStream

Experimental
generateTaggedPDF
Optional
boolean

Whether or not to generate tagged (accessible) PDF. Defaults to embedder choice.

Experimental
generateDocumentOutline
Optional
boolean

Whether or not to embed the document outline into the PDF.

Experimental

Return object

data
string

Base64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)

stream
Optional
IO.StreamHandle

A handle of the stream that holds resulting PDF data.

Experimental

React NativeChrome DevTools

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

ignoreCache
Optional
boolean

If true, browser cache is ignored (as if the user pressed Shift+refresh).

scriptToEvaluateOnLoad
Optional
string

If set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.

loaderId
Optional
Network.LoaderId

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.

Experimental

Chrome DevTools

Page.removeScriptToEvaluateOnNewDocument #

Removes given script from the list.

Parameters

identifier

Chrome DevTools

Page.resetNavigationHistory #

Resets navigation history for the current page.


Chrome DevTools

Page.setBypassCSP #

Enable page Content Security Policy by-passing.

Parameters

enabled
boolean

Whether to bypass page CSP.


Chrome DevTools

Page.setDocumentContent #

Sets given markup as the document's HTML.

Parameters

frameId
FrameId

Frame id to set HTML for.

html
string

HTML content to set.


Chrome DevTools

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
boolean

Chrome DevTools

Page.setLifecycleEventsEnabled #

Controls whether page will emit lifecycle events.

Parameters

enabled
boolean

If true, starts emitting lifecycle events.


Chrome DevTools

Page.stopLoading #

Force the page stop all navigations and pending resource fetches.

Events

Chrome DevTools

Page.domContentEventFired #

Parameters


Chrome DevTools

Page.fileChooserOpened #

Emitted only when page.interceptFileChooser is enabled.

Parameters

frameId
FrameId

Id of the frame containing input node.

Experimental
mode
string

Input mode.

Allowed values: selectSingle, selectMultiple

backendNodeId
Optional
DOM.BackendNodeId

Input node id. Only present for file choosers opened via an <input type="file"> element.

Experimental

Chrome DevTools

Page.frameAttached #

Fired when frame has been attached to its parent.

Parameters

frameId
FrameId

Id of the frame that has been attached.

parentFrameId
FrameId

Parent frame identifier.

stack
Optional
Runtime.StackTrace

JavaScript stack trace of when frame was attached, only set if frame initiated from script.


Chrome DevTools

Page.frameDetached #

Fired when frame has been detached from its parent.

Parameters

frameId
FrameId

Id of the frame that has been detached.

reason
string

Allowed values: remove, swap

Experimental

Chrome DevTools

Page.frameNavigated #

Fired once navigation of the frame has completed. Frame is now associated with the new loader.

Parameters

frame
Frame

Frame object.

type
NavigationTypeExperimental

Chrome DevTools

Page.interstitialHidden #

Fired when interstitial page was hidden


Chrome DevTools

Page.interstitialShown #

Fired when interstitial page was shown


Chrome DevTools

Page.javascriptDialogClosed #

Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.

Parameters

result
boolean

Whether dialog was confirmed.

userInput
string

User input in case of prompt.


Chrome DevTools

Page.javascriptDialogOpening #

Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.

Parameters

url
string

Frame url.

message
string

Message that will be displayed by the dialog.

type
DialogType

Dialog type.

hasBrowserHandler
boolean

True 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.

defaultPrompt
Optional
string

Default dialog prompt.


Chrome DevTools

Page.lifecycleEvent #

Fired for top level page lifecycle events such as navigation, load, paint, etc.

Parameters

frameId
FrameId

Id of the frame.

loaderId
Network.LoaderId

Loader identifier. Empty string if the request is fetched from worker.

name
string

Chrome DevTools

Page.loadEventFired #

Parameters


Chrome DevTools

Page.windowOpen #

Fired when a new window is going to be opened, via window.open(), link click, form submission, etc.

Parameters

url
string

The URL for the new window.

windowName
string

Window name.

windowFeatures
array[ string ]

An array of enabled window features.

userGesture
boolean

Whether or not it was triggered by user gesture.

Types

Chrome DevTools

Page.AppManifestError #

Error while paring app manifest.

Type: object

Properties

message
string

Error message.

critical
integer

If critical, this is a non-recoverable parse error.

line
integer

Error line.

column
integer

Error column.


Chrome DevTools

Page.DialogType #

Javascript dialog type.

Type: string

Allowed values: alert, confirm, prompt, beforeunload


Chrome DevTools

Page.Frame #

Information about the Frame on the page.

Type: object

Properties

id
FrameId

Frame unique identifier.

parentId
Optional
FrameId

Parent frame identifier.

loaderId
Network.LoaderId

Identifier of the loader associated with this frame.

name
Optional
string

Frame's name as specified in the tag.

url
string

Frame document's URL without fragment.

urlFragment
Optional
string

Frame document's URL fragment including the '#'.

Experimental
domainAndRegistry
string

Frame 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"

Experimental
securityOrigin
string

Frame document's security origin.

mimeType
string

Frame document's mimeType as determined by the browser.

unreachableUrl
Optional
string

If 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.

Experimental
adFrameStatus
Optional
AdFrameStatus

Indicates whether this frame was tagged as an ad and why.

Experimental
secureContextType
SecureContextType

Indicates whether the main document is a secure context and explains why that is the case.

Experimental
crossOriginIsolatedContextType
CrossOriginIsolatedContextType

Indicates whether this is a cross origin isolated context.

Experimental
gatedAPIFeatures
array[ GatedAPIFeatures ]

Indicated which gated APIs / features are available.

Experimental

Chrome DevTools

Page.FrameId #

Unique frame identifier.

Type: string


Chrome DevTools

Page.FrameTree #

Information about the Frame hierarchy.

Type: object

Properties

frame
Frame

Frame information for this tree item.

childFrames
Optional
array[ FrameTree ]

Child frames.


Chrome DevTools

Page.LayoutViewport #

Layout viewport position and dimensions.

Type: object

Properties

pageX
integer

Horizontal offset relative to the document (CSS pixels).

pageY
integer

Vertical offset relative to the document (CSS pixels).

clientWidth
integer

Width (CSS pixels), excludes scrollbar if present.

clientHeight
integer

Height (CSS pixels), excludes scrollbar if present.


Chrome DevTools

Page.NavigationEntry #

Navigation history entry.

Type: object

Properties

id
integer

Unique id of the navigation history entry.

url
string

URL of the navigation history entry.

userTypedURL
string

URL that the user typed in the url bar.

title
string

Title of the navigation history entry.

transitionType
TransitionType

Transition type.


Chrome DevTools

Page.ScriptIdentifier #

Unique script identifier.

Type: string


Chrome DevTools

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


Chrome DevTools

Page.Viewport #

Viewport for capturing screenshot.

Type: object

Properties

x
number

X offset in device independent pixels (dip).

y
number

Y offset in device independent pixels (dip).

width
number

Rectangle width in device independent pixels (dip).

height
number

Rectangle height in device independent pixels (dip).

scale
number

Page scale factor.


Chrome DevTools

Page.VisualViewport #

Visual viewport position, dimensions, and scale.

Type: object

Properties

offsetX
number

Horizontal offset relative to the layout viewport (CSS pixels).

offsetY
number

Vertical offset relative to the layout viewport (CSS pixels).

pageX
number

Horizontal offset relative to the document (CSS pixels).

pageY
number

Vertical offset relative to the document (CSS pixels).

clientWidth
number

Width (CSS pixels), excludes scrollbar if present.

clientHeight
number

Height (CSS pixels), excludes scrollbar if present.

scale
number

Scale relative to the ideal viewport (size at width=device-width).

zoom
Optional
number

Page zoom factor (CSS to device independent pixels ratio).