Interface PageAsync


public interface PageAsync
Actions and events related to the inspected page belong to the page domain.
  • Method Details

    • addCompilationCache

      CompletableFuture<Void> addCompilationCache(String url, String data)
      Seeds compilation cache for given url. Compilation cache does not survive cross-process navigation.
      Parameters:
      data - Base64-encoded data (Encoded as a base64 string when passed over JSON)
    • addScriptToEvaluateOnLoad

      @Deprecated CompletableFuture<String> addScriptToEvaluateOnLoad(String scriptSource)
      Deprecated.
      Deprecated, please use addScriptToEvaluateOnNewDocument instead.
      Returns:
      Identifier of the added script.
    • addScriptToEvaluateOnNewDocument

      CompletableFuture<String> addScriptToEvaluateOnNewDocument(String source)
      Evaluates given script in every frame upon creation (before loading frame's scripts).
      Returns:
      Identifier of the added script.
    • addScriptToEvaluateOnNewDocument

      CompletableFuture<String> addScriptToEvaluateOnNewDocument(String source, String worldName, Boolean includeCommandLineAPI)
      Evaluates given script in every frame upon creation (before loading frame's scripts).
      Parameters:
      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.
      Returns:
      Identifier of the added script.
    • bringToFront

      CompletableFuture<Void> bringToFront()
      Brings page to front (activates tab).
    • captureScreenshot

      CompletableFuture<byte[]> captureScreenshot()
      Capture page screenshot.
      Returns:
      Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
    • captureScreenshot

      CompletableFuture<byte[]> captureScreenshot(ImageFormat format, Integer quality, Viewport clip, Boolean fromSurface, Boolean captureBeyondViewport)
      Capture page screenshot.
      Parameters:
      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.
      Returns:
      Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
    • captureSnapshot

      CompletableFuture<String> captureSnapshot()
      Returns a snapshot of the page as a string. For MHTML format, the serialization includes iframes, shadow DOM, external resources, and element-inline styles.
      Returns:
      Serialized page data.
    • captureSnapshot

      CompletableFuture<String> captureSnapshot(SnapshotType format)
      Returns a snapshot of the page as a string. For MHTML format, the serialization includes iframes, shadow DOM, external resources, and element-inline styles.
      Parameters:
      format - Format (defaults to mhtml).
      Returns:
      Serialized page data.
    • clearCompilationCache

      CompletableFuture<Void> clearCompilationCache()
      Clears seeded compilation cache.
    • clearDeviceMetricsOverride

      @Deprecated CompletableFuture<Void> clearDeviceMetricsOverride()
      Deprecated.
      Clears the overridden device metrics.
    • clearDeviceOrientationOverride

      @Deprecated CompletableFuture<Void> clearDeviceOrientationOverride()
      Deprecated.
      Clears the overridden Device Orientation.
    • clearGeolocationOverride

      @Deprecated CompletableFuture<Void> clearGeolocationOverride()
      Deprecated.
      Clears the overridden Geolocation Position and Error.
    • close

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

      Crashes renderer on the IO thread, generates minidumps.
    • createIsolatedWorld

      CompletableFuture<Integer> createIsolatedWorld(String frameId)
      Creates an isolated world for the given frame.
      Parameters:
      frameId - Id of the frame in which the isolated world should be created.
      Returns:
      Execution context of the isolated world.
    • createIsolatedWorld

      CompletableFuture<Integer> createIsolatedWorld(String frameId, String worldName, Boolean grantUniveralAccess)
      Creates an isolated world for the given frame.
      Parameters:
      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

      @Deprecated CompletableFuture<Void> deleteCookie(String cookieName, String url)
      Deprecated.
      Deletes browser cookie with given name, domain and path.
      Parameters:
      cookieName - Name of the cookie to remove.
      url - URL to match cooke domain and path.
    • disable

      Disables page domain notifications.
    • enable

      Enables page domain notifications.
    • generateTestReport

      CompletableFuture<Void> generateTestReport(String message)
      Generates a report for testing.
      Parameters:
      message - Message to be displayed in the report.
    • generateTestReport

      CompletableFuture<Void> generateTestReport(String message, String group)
      Generates a report for testing.
      Parameters:
      message - Message to be displayed in the report.
      group - Specifies the endpoint group to deliver the report to.
    • getAppId

      Returns the unique (PWA) app id. Only returns values if the feature flag 'WebAppEnableManifestId' is enabled
      Returns:
      GetAppIdResult
    • getAppManifest

      Returns:
      GetAppManifestResult
    • getCookies

      Deprecated.
      Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the cookies field.
      Returns:
      Array of cookie objects.
    • getFrameTree

      CompletableFuture<FrameTree> getFrameTree()
      Returns present frame tree structure.
      Returns:
      Present frame tree structure.
    • getInstallabilityErrors

      CompletableFuture<List<InstallabilityError>> getInstallabilityErrors()
    • getLayoutMetrics

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

      CompletableFuture<String> getManifestIcons()
    • getNavigationHistory

      Returns navigation history for the current page.
      Returns:
      GetNavigationHistoryResult
    • getOriginTrials

      CompletableFuture<List<OriginTrial>> getOriginTrials(String frameId)
      Get Origin Trials on given frame.
    • getPermissionsPolicyState

      CompletableFuture<List<PermissionsPolicyFeatureState>> getPermissionsPolicyState(String frameId)
      Get Permissions Policy state on given frame.
    • getResourceContent

      CompletableFuture<GetResourceContentResult> getResourceContent(String frameId, String url)
      Returns content of the given resource.
      Parameters:
      frameId - Frame id to get resource for.
      url - URL of the resource to get content for.
      Returns:
      GetResourceContentResult
    • getResourceTree

      Returns present frame / resource tree structure.
      Returns:
      Present frame / resource tree structure.
    • handleJavaScriptDialog

      CompletableFuture<Void> handleJavaScriptDialog(Boolean accept)
      Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
      Parameters:
      accept - Whether to accept or dismiss the dialog.
    • handleJavaScriptDialog

      CompletableFuture<Void> handleJavaScriptDialog(Boolean accept, String promptText)
      Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
      Parameters:
      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.
    • printToPDF

      Print page as PDF.
      Returns:
      PrintToPDFResult
    • printToPDF

      CompletableFuture<PrintToPDFResult> printToPDF(Boolean landscape, Boolean displayHeaderFooter, Boolean printBackground, Double scale, Double paperWidth, Double paperHeight, Double marginTop, Double marginBottom, Double marginLeft, Double marginRight, String pageRanges, String headerTemplate, String footerTemplate, Boolean preferCSSPageSize, TransferMode transferMode)
      Print page as PDF.
      Parameters:
      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: - date: formatted print date - title: document title - url: document location - pageNumber: current page number - totalPages: total pages in the document For example, would generate span containing the title.
      footerTemplate - HTML template for the print footer. Should use the same format as the headerTemplate.
      preferCSSPageSize - 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 - return as stream
      Returns:
      PrintToPDFResult
    • produceCompilationCache

      CompletableFuture<Void> produceCompilationCache(List<CompilationCacheParams> scripts)
      Requests backend to produce compilation cache for the specified scripts. scripts are appeneded 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

      Reloads given page optionally ignoring the cache.
    • reload

      CompletableFuture<Void> reload(Boolean ignoreCache, String scriptToEvaluateOnLoad)
      Reloads given page optionally ignoring the cache.
      Parameters:
      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.
    • removeScriptToEvaluateOnLoad

      @Deprecated CompletableFuture<Void> removeScriptToEvaluateOnLoad(String identifier)
      Deprecated.
      Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
    • removeScriptToEvaluateOnNewDocument

      CompletableFuture<Void> removeScriptToEvaluateOnNewDocument(String identifier)
      Removes given script from the list.
    • resetNavigationHistory

      CompletableFuture<Void> resetNavigationHistory()
      Resets navigation history for the current page.
    • screencastFrameAck

      CompletableFuture<Void> screencastFrameAck(Integer sessionId)
      Acknowledges that a screencast frame has been received by the frontend.
      Parameters:
      sessionId - Frame number.
    • searchInResource

      CompletableFuture<List<SearchMatch>> searchInResource(String frameId, String url, String query)
      Searches for given string in resource content.
      Parameters:
      frameId - Frame id for resource to search in.
      url - URL of the resource to search in.
      query - String to search for.
      Returns:
      List of search matches.
    • searchInResource

      CompletableFuture<List<SearchMatch>> searchInResource(String frameId, String url, String query, Boolean caseSensitive, Boolean isRegex)
      Searches for given string in resource content.
      Parameters:
      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

      CompletableFuture<Void> setAdBlockingEnabled(Boolean enabled)
      Enable Chrome's experimental ad filter on all sites.
      Parameters:
      enabled - Whether to block ads.
    • setBypassCSP

      CompletableFuture<Void> setBypassCSP(Boolean enabled)
      Enable page Content Security Policy by-passing.
      Parameters:
      enabled - Whether to bypass page CSP.
    • setDeviceMetricsOverride

      @Deprecated CompletableFuture<Void> setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile)
      Deprecated.
      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).
      Parameters:
      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.
    • setDeviceMetricsOverride

      @Deprecated CompletableFuture<Void> setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile, Double scale, Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport)
      Deprecated.
      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).
      Parameters:
      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

      @Deprecated CompletableFuture<Void> setDeviceOrientationOverride(Double alpha, Double beta, Double gamma)
      Deprecated.
      Overrides the Device Orientation.
      Parameters:
      alpha - Mock alpha
      beta - Mock beta
      gamma - Mock gamma
    • setDocumentContent

      CompletableFuture<Void> setDocumentContent(String frameId, String html)
      Sets given markup as the document's HTML.
      Parameters:
      frameId - Frame id to set HTML for.
      html - HTML content to set.
    • setDownloadBehavior

      @Deprecated CompletableFuture<Void> setDownloadBehavior(DownloadBehavior behavior)
      Deprecated.
      Set the behavior when downloading a file.
      Parameters:
      behavior - Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny).
    • setDownloadBehavior

      @Deprecated CompletableFuture<Void> setDownloadBehavior(DownloadBehavior behavior, String downloadPath)
      Deprecated.
      Set the behavior when downloading a file.
      Parameters:
      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

      CompletableFuture<Void> setFontFamilies(FontFamilies fontFamilies)
      Set generic font families.
      Parameters:
      fontFamilies - Specifies font families to set. If a font family is not specified, it won't be changed.
    • setFontFamilies

      CompletableFuture<Void> setFontFamilies(FontFamilies fontFamilies, List<ScriptFontFamilies> forScripts)
      Set generic font families.
      Parameters:
      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

      CompletableFuture<Void> setFontSizes(FontSizes fontSizes)
      Set default font sizes.
      Parameters:
      fontSizes - Specifies font sizes to set. If a font size is not specified, it won't be changed.
    • setGeolocationOverride

      @Deprecated CompletableFuture<Void> setGeolocationOverride()
      Deprecated.
      Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
    • setGeolocationOverride

      @Deprecated CompletableFuture<Void> setGeolocationOverride(Double latitude, Double longitude, Double accuracy)
      Deprecated.
      Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
      Parameters:
      latitude - Mock latitude
      longitude - Mock longitude
      accuracy - Mock accuracy
    • setInterceptFileChooserDialog

      CompletableFuture<Void> setInterceptFileChooserDialog(Boolean enabled)
      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

      CompletableFuture<Void> setLifecycleEventsEnabled(Boolean enabled)
      Controls whether page will emit lifecycle events.
      Parameters:
      enabled - If true, starts emitting lifecycle events.
    • setSPCTransactionMode

      CompletableFuture<Void> setSPCTransactionMode(SPCTransactionMode mode)
      Sets the Secure Payment Confirmation transaction mode. https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode
    • setTouchEmulationEnabled

      @Deprecated CompletableFuture<Void> setTouchEmulationEnabled(Boolean enabled)
      Deprecated.
      Toggles mouse event-based touch event emulation.
      Parameters:
      enabled - Whether the touch event emulation should be enabled.
    • setTouchEmulationEnabled

      @Deprecated CompletableFuture<Void> setTouchEmulationEnabled(Boolean enabled, Platform configuration)
      Deprecated.
      Toggles mouse event-based touch event emulation.
      Parameters:
      enabled - Whether the touch event emulation should be enabled.
      configuration - Touch/gesture events configuration. Default: current platform.
    • setWebLifecycleState

      CompletableFuture<Void> setWebLifecycleState(WebLifecycleState state)
      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/
      Parameters:
      state - Target lifecycle state
    • startScreencast

      CompletableFuture<Void> startScreencast()
      Starts sending each frame using the screencastFrame event.
    • startScreencast

      CompletableFuture<Void> startScreencast(ImageFormat format, Integer quality, Integer maxWidth, Integer maxHeight, Integer everyNthFrame)
      Starts sending each frame using the screencastFrame event.
      Parameters:
      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

      CompletableFuture<Void> stopLoading()
      Force the page stop all navigations and pending resource fetches.
    • stopScreencast

      CompletableFuture<Void> stopScreencast()
      Stops sending each frame in the screencastFrame.
    • waitForDebugger

      CompletableFuture<Void> waitForDebugger()
      Pauses page execution. Can be resumed using generic Runtime.runIfWaitingForDebugger.