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. Is only available if Page.setGenerateCompilationCache is enabled.
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.interceptFileChooser is enabled.
no setter
onFrameAttached Stream<FrameAttachedEvent>
Fired when frame has been attached to its parent.
no setter
onFrameClearedScheduledNavigation Stream<FrameId>
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
onFrameNavigated Stream<FrameNavigatedEvent>
Fired once navigation of the frame has completed. Frame is now associated with the new loader.
no setter
onFrameRequestedNavigation Stream<FrameRequestedNavigationEvent>
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
onFrameScheduledNavigation Stream<FrameScheduledNavigationEvent>
Fired when frame schedules a potential navigation.
no setter
onFrameStartedLoading Stream<FrameId>
Fired when frame has started loading.
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 top level page lifecycle events such as navigation, load, paint, etc.
no setter
onLoadEventFired Stream<MonotonicTime>
no setter
onNavigatedWithinDocument Stream<NavigatedWithinDocumentEvent>
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. data Base64-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). worldName 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. includeCommandLineAPI Specifies whether command line API should be available to the script, defaults to false. runImmediately If 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. 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. fromSurface Capture the screenshot from the surface, rather than the view. Defaults to true. captureBeyondViewport Capture the screenshot beyond the viewport. Defaults to false. optimizeForSpeed Optimize 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. format Format (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. frameId Id of the frame in which the isolated world should be created. worldName An optional name which is reported in the Execution Context. grantUniveralAccess Whether 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. cookieName Name of the cookie to remove. url URL to match cooke domain and path.
disable() Future<void>
Disables page domain notifications.
enable() Future<void>
Enables page domain notifications.
generateTestReport(String message, {String? group}) Future<void>
Generates a report for testing. message Message to be displayed in the report. group Specifies the endpoint group to deliver the report to.
getAdScriptId(FrameId frameId) Future<AdScriptId>
Returns: Identifies the bottom-most script which caused the frame to be labelled as an ad. Only sent if frame is labelled as an ad and id is 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.
getNavigationHistory() Future<GetNavigationHistoryResult>
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. frameId Frame id to get resource for. url URL 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). accept Whether to accept or dismiss the dialog. promptText The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.
Navigates current page to the given URL. url URL to navigate the page to. referrer Referrer URL. transitionType Intended transition type. frameId Frame id to navigate, if not specified navigates the top frame. referrerPolicy Referrer-policy used for the navigation.
Navigates current page to the given history entry. entryId Unique 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? displayHeaderFooter, bool? printBackground, num? scale, num? paperWidth, num? paperHeight, num? marginTop, num? marginBottom, num? marginLeft, num? marginRight, String? pageRanges, String? headerTemplate, String? footerTemplate, bool? preferCSSPageSize, String? transferMode, bool? generateTaggedPDF, bool? generateDocumentOutline}) Future<PrintToPDFResult>
Print page as PDF. landscape Paper orientation. Defaults to false. displayHeaderFooter Display header and footer. Defaults to false. printBackground Print background graphics. Defaults to false. scale Scale of the webpage rendering. Defaults to 1. paperWidth Paper width in inches. Defaults to 8.5 inches. paperHeight Paper height in inches. Defaults to 11 inches. marginTop Top margin in inches. Defaults to 1cm (~0.4 inches). marginBottom Bottom margin in inches. Defaults to 1cm (~0.4 inches). marginLeft Left margin in inches. Defaults to 1cm (~0.4 inches). marginRight Right margin in inches. Defaults to 1cm (~0.4 inches). pageRanges 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 HTML 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. scripts are 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. ignoreCache If true, browser cache is ignored (as if the user pressed Shift+refresh). scriptToEvaluateOnLoad 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 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.
removeScriptToEvaluateOnLoad(ScriptIdentifier identifier) Future<void>
Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
removeScriptToEvaluateOnNewDocument(ScriptIdentifier identifier) Future<void>
Removes given script from the list.
resetNavigationHistory() Future<void>
Resets navigation history for the current page.
screencastFrameAck(int sessionId) Future<void>
Acknowledges that a screencast frame has been received by the frontend. sessionId Frame number.
searchInResource(FrameId frameId, String url, String query, {bool? caseSensitive, bool? isRegex}) Future<List<SearchMatch>>
Searches for given string in resource content. frameId Frame id for resource to search in. url URL of the resource to search in. query String to search for. caseSensitive If true, search is case sensitive. isRegex If 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. enabled Whether to block ads.
setBypassCSP(bool enabled) Future<void>
Enable page Content Security Policy by-passing. enabled Whether 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). width Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. height Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. deviceScaleFactor Overriding device scale factor value. 0 disables the override. mobile Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. scale Scale to apply to resulting view image. screenWidth Overriding screen width value in pixels (minimum 0, maximum 10000000). screenHeight Overriding screen height value in pixels (minimum 0, maximum 10000000). positionX Overriding view X position on screen in pixels (minimum 0, maximum 10000000). positionY Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). dontSetVisibleSize Do not set visible view size, rely upon explicit setVisibleSize call. screenOrientation Screen orientation override. viewport The viewport dimensions and scale. If not set, the override is cleared.
setDeviceOrientationOverride(num alpha, num beta, num gamma) Future<void>
Overrides the Device Orientation. alpha Mock alpha beta Mock beta gamma Mock gamma
setDocumentContent(FrameId frameId, String html) Future<void>
Sets given markup as the document's HTML. frameId Frame id to set HTML for. html HTML content to set.
setDownloadBehavior(String behavior, {String? downloadPath}) Future<void>
Set the behavior when downloading a file. behavior Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). downloadPath The 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. fontFamilies Specifies font families to set. If a font family is not specified, it won't be changed. forScripts Specifies font families to set for individual scripts.
setFontSizes(FontSizes fontSizes) Future<void>
Set default font sizes. fontSizes Specifies 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. latitude Mock latitude longitude Mock longitude accuracy Mock accuracy
setInterceptFileChooserDialog(bool enabled) 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.fileChooserOpened is emitted.
setLifecycleEventsEnabled(bool enabled) Future<void>
Controls whether page will emit lifecycle events. enabled If true, starts emitting lifecycle events.
setPrerenderingAllowed(bool isAllowed) Future<void>
Enable/disable prerendering manually.
setRPHRegistrationMode(AutoResponseMode mode) Future<void>
Extensions for Custom Handlers API: https://html.spec.whatwg.org/multipage/system-state.html#rph-automation
setSPCTransactionMode(AutoResponseMode 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. enabled Whether the touch event emulation should be enabled. configuration Touch/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/ state Target lifecycle state
startScreencast({String? format, int? quality, int? maxWidth, int? maxHeight, int? everyNthFrame}) Future<void>
Starts sending each frame using the screencastFrame event. format Image compression format. quality Compression quality from range 0..100. maxWidth Maximum screenshot width. maxHeight Maximum screenshot height. everyNthFrame Send 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