PageApi class
Actions and events related to the inspected page belong to the page domain.
Constructors
- PageApi(Client _client)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onBackForwardCacheNotUsed
→ Stream<
BackForwardCacheNotUsedEvent> -
Fired for failed bfcache history navigations if BackForwardCache feature is enabled. Do
not assume any ordering with the Page.frameNavigated event. This event is fired only for
main-frame history navigation where the document changes (non-same-document navigations),
when bfcache navigation fails.
no setter
-
onCompilationCacheProduced
→ Stream<
CompilationCacheProducedEvent> -
Issued for every compilation cache generated.
no setter
-
onDocumentOpened
→ Stream<
FrameInfo> -
Fired when opening document to write to.
no setter
-
onDomContentEventFired
→ Stream<
MonotonicTime> -
no setter
-
onDownloadProgress
→ Stream<
DownloadProgressEvent> -
Fired when download makes progress. Last call has |done| == true.
Deprecated. Use Browser.downloadProgress instead.
no setter
-
onDownloadWillBegin
→ Stream<
DownloadWillBeginEvent> -
Fired when page is about to start a download.
Deprecated. Use Browser.downloadWillBegin instead.
no setter
-
onFileChooserOpened
→ Stream<
FileChooserOpenedEvent> -
Emitted only when
page.interceptFileChooseris enabled.no setter -
onFrameAttached
→ Stream<
FrameAttachedEvent> -
Fired when frame has been attached to its parent.
no setter
-
Fired when frame no longer has a scheduled navigation.
no setter
-
onFrameDetached
→ Stream<
FrameDetachedEvent> -
Fired when frame has been detached from its parent.
no setter
-
Fired once navigation of the frame has completed. Frame is now associated with the new loader.
no setter
-
Fired when a renderer-initiated navigation is requested.
Navigation may still be cancelled after the event is issued.
no setter
-
onFrameResized
→ Stream<
void> -
no setter
-
Fired when frame schedules a potential navigation.
no setter
-
onFrameStartedLoading
→ Stream<
FrameId> -
Fired when frame has started loading.
no setter
-
Fired when a navigation starts. This event is fired for both
renderer-initiated and browser-initiated navigations. For renderer-initiated
navigations, the event is fired after
frameRequestedNavigation. Navigation may still be cancelled after the event is issued. Multiple events can be fired for a single navigation, for example, when a same-document navigation becomes a cross-document navigation (such as in the case of a frameset).no setter -
onFrameStoppedLoading
→ Stream<
FrameId> -
Fired when frame has stopped loading.
no setter
-
onFrameSubtreeWillBeDetached
→ Stream<
FrameId> -
Fired before frame subtree is detached. Emitted before any frame of the
subtree is actually detached.
no setter
-
onInterstitialHidden
→ Stream<
void> -
Fired when interstitial page was hidden
no setter
-
onInterstitialShown
→ Stream<
void> -
Fired when interstitial page was shown
no setter
-
onJavascriptDialogClosed
→ Stream<
JavascriptDialogClosedEvent> -
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been
closed.
no setter
-
onJavascriptDialogOpening
→ Stream<
JavascriptDialogOpeningEvent> -
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to
open.
no setter
-
onLifecycleEvent
→ Stream<
LifecycleEventEvent> -
Fired for lifecycle events (navigation, load, paint, etc) in the current
target (including local frames).
no setter
-
onLoadEventFired
→ Stream<
MonotonicTime> -
no setter
-
Fired when same-document navigation happens, e.g. due to history API usage or anchor navigation.
no setter
-
onScreencastFrame
→ Stream<
ScreencastFrameEvent> -
Compressed image data requested by the
startScreencast.no setter -
onScreencastVisibilityChanged
→ Stream<
bool> -
Fired when the page with currently enabled screencast was shown or hidden `.
no setter
-
onWindowOpen
→ Stream<
WindowOpenEvent> -
Fired when a new window is going to be opened, via window.open(), link click, form submission,
etc.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addCompilationCache(
String url, String data) → Future< void> -
Seeds compilation cache for given url. Compilation cache does not survive
cross-process navigation.
dataBase64-encoded data -
addScriptToEvaluateOnLoad(
String scriptSource) → Future< ScriptIdentifier> - Deprecated, please use addScriptToEvaluateOnNewDocument instead. Returns: Identifier of the added script.
-
addScriptToEvaluateOnNewDocument(
String source, {String? worldName, bool? includeCommandLineAPI, bool? runImmediately}) → Future< ScriptIdentifier> -
Evaluates given script in every frame upon creation (before loading frame's scripts).
worldNameIf 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.includeCommandLineAPISpecifies whether command line API should be available to the script, defaults to false.runImmediatelyIf true, runs the script immediately on existing execution contexts or worlds. Default: false. Returns: Identifier of the added script. -
bringToFront(
) → Future< void> - Brings page to front (activates tab).
-
captureScreenshot(
{String? format, int? quality, Viewport? clip, bool? fromSurface, bool? captureBeyondViewport, bool? optimizeForSpeed}) → Future< String> -
Capture page screenshot.
formatImage compression format (defaults to png).qualityCompression quality from range0..100(jpeg only).clipCapture the screenshot of a given region only.fromSurfaceCapture the screenshot from the surface, rather than the view. Defaults to true.captureBeyondViewportCapture the screenshot beyond the viewport. Defaults to false.optimizeForSpeedOptimize image encoding for speed, not for resulting size (defaults to false) Returns: Base64-encoded image data. -
captureSnapshot(
{String? format}) → Future< String> -
Returns a snapshot of the page as a string. For MHTML format, the serialization includes
iframes, shadow DOM, external resources, and element-inline styles.
formatFormat (defaults to mhtml). Returns: Serialized page data. -
clearCompilationCache(
) → Future< void> - Clears seeded compilation cache.
-
clearDeviceMetricsOverride(
) → Future< void> - Clears the overridden device metrics.
-
clearDeviceOrientationOverride(
) → Future< void> - Clears the overridden Device Orientation.
-
clearGeolocationOverride(
) → Future< void> - Clears the overridden Geolocation Position and Error.
-
close(
) → Future< void> - Tries to close page, running its beforeunload hooks, if any.
-
crash(
) → Future< void> - Crashes renderer on the IO thread, generates minidumps.
-
createIsolatedWorld(
FrameId frameId, {String? worldName, bool? grantUniveralAccess}) → Future< ExecutionContextId> -
Creates an isolated world for the given frame.
frameIdId of the frame in which the isolated world should be created.worldNameAn optional name which is reported in the Execution Context.grantUniveralAccessWhether or not universal access should be granted to the isolated world. This is a powerful option, use with caution. Returns: Execution context of the isolated world. -
deleteCookie(
String cookieName, String url) → Future< void> -
Deletes browser cookie with given name, domain and path.
cookieNameName of the cookie to remove.urlURL to match cooke domain and path. -
disable(
) → Future< void> - Disables page domain notifications.
-
enable(
{bool? enableFileChooserOpenedEvent}) → Future< void> -
Enables page domain notifications.
enableFileChooserOpenedEventIf true, thePage.fileChooserOpenedevent will be emitted regardless of the state set byPage.setInterceptFileChooserDialogcommand (default: false). -
generateTestReport(
String message, {String? group}) → Future< void> -
Generates a report for testing.
messageMessage to be displayed in the report.groupSpecifies the endpoint group to deliver the report to. -
getAdScriptAncestry(
FrameId frameId) → Future< AdScriptAncestry> - Returns: The ancestry chain of ad script identifiers leading to this frame's creation, along with the root script's filterlist rule. The ancestry chain is ordered from the most immediate script (in the frame creation stack) to more distant ancestors (that created the immediately preceding script). Only sent if frame is labelled as an ad and ids are available.
-
getAppId(
) → Future< GetAppIdResult> - Returns the unique (PWA) app id. Only returns values if the feature flag 'WebAppEnableManifestId' is enabled
-
getAppManifest(
{String? manifestId}) → Future< GetAppManifestResult> - 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.
-
getFrameTree(
) → Future< FrameTree> - Returns present frame tree structure. Returns: Present frame tree structure.
-
getInstallabilityErrors(
) → Future< List< InstallabilityError> > -
getLayoutMetrics(
) → Future< GetLayoutMetricsResult> - Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
-
getManifestIcons(
) → Future< String> - Deprecated because it's not guaranteed that the returned icon is in fact the one used for PWA installation.
- Returns navigation history for the current page.
-
getOriginTrials(
FrameId frameId) → Future< List< OriginTrial> > - Get Origin Trials on given frame.
-
getPermissionsPolicyState(
FrameId frameId) → Future< List< PermissionsPolicyFeatureState> > - Get Permissions Policy state on given frame.
-
getResourceContent(
FrameId frameId, String url) → Future< GetResourceContentResult> -
Returns content of the given resource.
frameIdFrame id to get resource for.urlURL of the resource to get content for. -
getResourceTree(
) → Future< FrameResourceTree> - Returns present frame / resource tree structure. Returns: Present frame / resource tree structure.
-
handleJavaScriptDialog(
bool accept, {String? promptText}) → Future< void> -
Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
acceptWhether to accept or dismiss the dialog.promptTextThe text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog. -
Navigates current page to the given URL.
urlURL to navigate the page to.referrerReferrer URL.transitionTypeIntended transition type.frameIdFrame id to navigate, if not specified navigates the top frame.referrerPolicyReferrer-policy used for the navigation. -
Navigates current page to the given history entry.
entryIdUnique id of the entry to navigate to. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
printToPDF(
{bool? landscape, bool? printBackground, num? scale, num? paperWidth, num? paperHeight, num? marginTop, num? marginBottom, num? marginLeft, num? marginRight, String? pageRanges, String? headerTemplate, bool? preferCSSPageSize, String? transferMode, bool? generateTaggedPDF, bool? generateDocumentOutline}) → Future< PrintToPDFResult> -
Print page as PDF.
landscapePaper orientation. Defaults to false.displayHeaderFooterDisplay header and footer. Defaults to false.printBackgroundPrint background graphics. Defaults to false.scaleScale of the webpage rendering. Defaults to 1.paperWidthPaper width in inches. Defaults to 8.5 inches.paperHeightPaper height in inches. Defaults to 11 inches.marginTopTop margin in inches. Defaults to 1cm (~0.4 inches).marginBottomBottom margin in inches. Defaults to 1cm (~0.4 inches).marginLeftLeft margin in inches. Defaults to 1cm (~0.4 inches).marginRightRight margin in inches. Defaults to 1cm (~0.4 inches).pageRangesPaper 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.headerTemplateHTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: -
produceCompilationCache(
List< CompilationCacheParams> scripts) → Future<void> -
Requests backend to produce compilation cache for the specified scripts.
scriptsare appended to the list of scripts for which the cache would be produced. The list may be reset during page navigation. When script with a matching URL is encountered, the cache is optionally produced upon backend discretion, based on internal heuristics. See also:Page.compilationCacheProduced. -
reload(
{bool? ignoreCache, String? scriptToEvaluateOnLoad, LoaderId? loaderId}) → Future< void> -
Reloads given page optionally ignoring the cache.
ignoreCacheIf true, browser cache is ignored (as if the user pressed Shift+refresh).scriptToEvaluateOnLoadIf set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.loaderIdIf 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. -
removeScriptToEvaluateOnLoad(
ScriptIdentifier identifier) → Future< void> - Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
-
removeScriptToEvaluateOnNewDocument(
ScriptIdentifier identifier) → Future< void> - Removes given script from the list.
- Resets navigation history for the current page.
-
screencastFrameAck(
int sessionId) → Future< void> -
Acknowledges that a screencast frame has been received by the frontend.
sessionIdFrame number. -
searchInResource(
FrameId frameId, String url, String query, {bool? caseSensitive, bool? isRegex}) → Future< List< SearchMatch> > -
Searches for given string in resource content.
frameIdFrame id for resource to search in.urlURL of the resource to search in.queryString to search for.caseSensitiveIf true, search is case sensitive.isRegexIf true, treats string parameter as regex. Returns: List of search matches. -
setAdBlockingEnabled(
bool enabled) → Future< void> -
Enable Chrome's experimental ad filter on all sites.
enabledWhether to block ads. -
setBypassCSP(
bool enabled) → Future< void> -
Enable page Content Security Policy by-passing.
enabledWhether to bypass page CSP. -
setDeviceMetricsOverride(
int width, int height, num deviceScaleFactor, bool mobile, {num? scale, int? screenWidth, int? screenHeight, int? positionX, int? positionY, bool? dontSetVisibleSize, ScreenOrientation? screenOrientation, Viewport? viewport}) → Future< void> -
Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
query results).
widthOverriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.heightOverriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.deviceScaleFactorOverriding device scale factor value. 0 disables the override.mobileWhether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.scaleScale to apply to resulting view image.screenWidthOverriding screen width value in pixels (minimum 0, maximum 10000000).screenHeightOverriding screen height value in pixels (minimum 0, maximum 10000000).positionXOverriding view X position on screen in pixels (minimum 0, maximum 10000000).positionYOverriding view Y position on screen in pixels (minimum 0, maximum 10000000).dontSetVisibleSizeDo not set visible view size, rely upon explicit setVisibleSize call.screenOrientationScreen orientation override.viewportThe viewport dimensions and scale. If not set, the override is cleared. -
setDeviceOrientationOverride(
num alpha, num beta, num gamma) → Future< void> -
Overrides the Device Orientation.
alphaMock alphabetaMock betagammaMock gamma -
setDocumentContent(
FrameId frameId, String html) → Future< void> -
Sets given markup as the document's HTML.
frameIdFrame id to set HTML for.htmlHTML content to set. -
setDownloadBehavior(
String behavior, {String? downloadPath}) → Future< void> -
Set the behavior when downloading a file.
behaviorWhether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny).downloadPathThe default path to save downloaded files to. This is required if behavior is set to 'allow' -
setFontFamilies(
FontFamilies fontFamilies, {List< ScriptFontFamilies> ? forScripts}) → Future<void> -
Set generic font families.
fontFamiliesSpecifies font families to set. If a font family is not specified, it won't be changed.forScriptsSpecifies font families to set for individual scripts. -
setFontSizes(
FontSizes fontSizes) → Future< void> -
Set default font sizes.
fontSizesSpecifies font sizes to set. If a font size is not specified, it won't be changed. -
setGeolocationOverride(
{num? latitude, num? longitude, num? accuracy}) → Future< void> -
Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
unavailable.
latitudeMock latitudelongitudeMock longitudeaccuracyMock accuracy -
setInterceptFileChooserDialog(
bool enabled, {bool? cancel}) → Future< void> -
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.fileChooserOpenedis emitted.cancelIf true, cancels the dialog by emitting relevant events (if any) in addition to not showing it if the interception is enabled (default: false). -
setLifecycleEventsEnabled(
bool enabled) → Future< void> -
Controls whether page will emit lifecycle events.
enabledIf true, starts emitting lifecycle events. -
setPrerenderingAllowed(
bool isAllowed) → Future< void> - Enable/disable prerendering manually.
-
setRPHRegistrationMode(
String mode) → Future< void> - Extensions for Custom Handlers API: https://html.spec.whatwg.org/multipage/system-state.html#rph-automation
-
setSPCTransactionMode(
String mode) → Future< void> - Sets the Secure Payment Confirmation transaction mode. https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode
-
setTouchEmulationEnabled(
bool enabled, {String? configuration}) → Future< void> -
Toggles mouse event-based touch event emulation.
enabledWhether the touch event emulation should be enabled.configurationTouch/gesture events configuration. Default: current platform. -
setWebLifecycleState(
String state) → Future< void> -
Tries to update the web lifecycle state of the page.
It will transition the page to the given state according to:
https://github.com/WICG/web-lifecycle/
stateTarget lifecycle state -
startScreencast(
{String? format, int? quality, int? maxWidth, int? maxHeight, int? everyNthFrame}) → Future< void> -
Starts sending each frame using the
screencastFrameevent.formatImage compression format.qualityCompression quality from range0..100.maxWidthMaximum screenshot width.maxHeightMaximum screenshot height.everyNthFrameSend every n-th frame. -
stopLoading(
) → Future< void> - Force the page stop all navigations and pending resource fetches.
-
stopScreencast(
) → Future< void> -
Stops sending each frame in the
screencastFrame. -
toString(
) → String -
A string representation of this object.
inherited
-
waitForDebugger(
) → Future< void> - Pauses page execution. Can be resumed using generic Runtime.runIfWaitingForDebugger.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited