Chrome DevTools Protocol

Methods

Page.addScriptToEvaluateOnNewDocument

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

parameters
source
string
worldName
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
Return Object
identifier
ScriptIdentifier

Identifier of the added script.

Page.bringToFront

Brings page to front (activates tab).

Page.captureScreenshot

Capture page screenshot.

parameters
format
string

Image compression format (defaults to png).

Allowed Values: jpeg, png
quality
integer

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

clip
Viewport

Capture the screenshot of a given region only.

fromSurface
boolean

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

Experimental
Return Object
data
string

Base64-encoded image data.

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
string

An optional name which is reported in the Execution Context.

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

Page.disable

Disables page domain notifications.

Page.enable

Enables page domain notifications.

Page.getAppManifest

Return Object
url
string

Manifest location.

errors
array[ AppManifestError ]
data
string

Manifest content.

parsed
AppManifestParsedProperties

Parsed manifest properties

Experimental

Page.getFrameTree

Returns present frame tree structure.

Return Object
frameTree
FrameTree

Present frame tree structure.

Page.getLayoutMetrics

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

Return Object
layoutViewport
LayoutViewport

Metrics relating to the layout viewport.

visualViewport
VisualViewport

Metrics relating to the visual viewport.

contentSize
DOM.Rect

Size of scrollable area.

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.

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
string

The 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
string

URL to navigate the page to.

referrer
string

Referrer URL.

transitionType
TransitionType

Intended transition type.

frameId
FrameId

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

referrerPolicy
ReferrerPolicy

Referrer-policy used for the navigation.

Experimental
Return Object
frameId
FrameId

Frame id that has navigated (or failed to navigate)

loaderId
Network.LoaderId

Loader identifier.

errorText
string

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

Page.navigateToHistoryEntry

Navigates current page to the given history entry.

parameters
entryId
integer

Unique id of the entry to navigate to.

Page.printToPDF

Print page as PDF.

parameters
landscape
boolean

Paper orientation. Defaults to false.

displayHeaderFooter
boolean

Display header and footer. Defaults to false.

printBackground
boolean

Print background graphics. Defaults to false.

scale
number

Scale of the webpage rendering. Defaults to 1.

paperWidth
number

Paper width in inches. Defaults to 8.5 inches.

paperHeight
number

Paper height in inches. Defaults to 11 inches.

marginTop
number

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

marginBottom
number

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

marginLeft
number

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

marginRight
number

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

pageRanges
string

Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.

ignoreInvalidPageRanges
boolean

Whether to silently ignore invalid but successfully parsed page ranges, such as '3-2'. Defaults to false.

headerTemplate
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
string

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

preferCSSPageSize
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
string

return as stream

Allowed Values: ReturnAsBase64, ReturnAsStream
Experimental
Return Object
data
string

Base64-encoded pdf data. Empty if |returnAsStream| is specified.

stream
IO.StreamHandle

A handle of the stream that holds resulting PDF data.

Experimental

Page.reload

Reloads given page optionally ignoring the cache.

parameters
ignoreCache
boolean

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

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

Page.removeScriptToEvaluateOnNewDocument

Removes given script from the list.

parameters
identifier
ScriptIdentifier

Page.resetNavigationHistory

Resets navigation history for the current page.

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.

Page.stopLoading

Force the page stop all navigations and pending resource fetches.

Events

Page.domContentEventFired

parameters
timestamp
Network.MonotonicTime

Page.fileChooserOpened

Emitted only when page.interceptFileChooser is enabled.

parameters
frameId
FrameId

Id of the frame containing input node.

Experimental
backendNodeId
DOM.BackendNodeId

Input node id.

Experimental
mode
string

Input mode.

Allowed Values: selectSingle, selectMultiple

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
Runtime.StackTrace

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
FrameId

Id of the frame that has been detached.

Page.frameNavigated

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

parameters
frame
Frame

Frame object.

Page.interstitialHidden

Fired when interstitial page was hidden

Page.interstitialShown

Fired when interstitial page was shown

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.

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
string

Default dialog prompt.

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
timestamp
Network.MonotonicTime

Page.loadEventFired

parameters
timestamp
Network.MonotonicTime

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

Page.AppManifestError

Error while paring app manifest.

Type: object

properties
message
string

Error message.

critical
integer

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

line
integer

Error line.

column
integer

Error column.

Page.DialogType

Javascript dialog type.

Allowed Values: alert, confirm, prompt, beforeunload

Type: string

Page.Frame

Information about the Frame on the page.

Type: object

properties
id
FrameId

Frame unique identifier.

parentId
string

Parent frame identifier.

loaderId
Network.LoaderId

Identifier of the loader associated with this frame.

name
string

Frame's name as specified in the tag.

url
string

Frame document's URL without fragment.

urlFragment
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
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
adFrameType
AdFrameType

Indicates whether this frame was tagged as an ad.

Experimental

Page.FrameId

Unique frame identifier.

Type: string

Page.FrameTree

Information about the Frame hierarchy.

Type: object

properties
frame
Frame

Frame information for this tree item.

childFrames
array[ FrameTree ]

Child frames.

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.

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.

Page.ScriptIdentifier

Unique script identifier.

Type: string

Page.TransitionType

Transition type.

Allowed Values: link, typed, address_bar, auto_bookmark, auto_subframe, manual_subframe, generated, auto_toplevel, form_submit, reload, keyword, keyword_generated, other

Type: string

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.

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
number

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