Class Page


  • public class Page
    extends java.lang.Object
    Actions and events related to the inspected page belong to the page domain.
    • Constructor Detail

      • Page

        public Page()
    • Method Detail

      • addScriptToEvaluateOnLoad

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<ScriptIdentifier> addScriptToEvaluateOnLoad​(java.lang.String scriptSource)
        Deprecated.
        Deprecated, please use addScriptToEvaluateOnNewDocument instead.
      • addScriptToEvaluateOnNewDocument

        public static org.openqa.selenium.devtools.Command<ScriptIdentifier> addScriptToEvaluateOnNewDocument​(java.lang.String source,
                                                                                                              java.util.Optional<java.lang.String> worldName)
        Evaluates given script in every frame upon creation (before loading frame's scripts).
      • bringToFront

        public static org.openqa.selenium.devtools.Command<java.lang.Void> bringToFront()
        Brings page to front (activates tab).
      • captureScreenshot

        public static org.openqa.selenium.devtools.Command<java.lang.String> captureScreenshot​(java.util.Optional<Page.CaptureScreenshotFormat> format,
                                                                                               java.util.Optional<java.lang.Integer> quality,
                                                                                               java.util.Optional<Viewport> clip,
                                                                                               java.util.Optional<java.lang.Boolean> fromSurface)
        Capture page screenshot.
      • captureSnapshot

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.String> captureSnapshot​(java.util.Optional<Page.CaptureSnapshotFormat> 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.
      • clearDeviceMetricsOverride

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearDeviceMetricsOverride()
        Deprecated.
        Clears the overriden device metrics.
      • clearDeviceOrientationOverride

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearDeviceOrientationOverride()
        Deprecated.
        Clears the overridden Device Orientation.
      • clearGeolocationOverride

        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearGeolocationOverride()
        Deprecated.
        Clears the overriden Geolocation Position and Error.
      • createIsolatedWorld

        public static org.openqa.selenium.devtools.Command<ExecutionContextId> createIsolatedWorld​(FrameId frameId,
                                                                                                   java.util.Optional<java.lang.String> worldName,
                                                                                                   java.util.Optional<java.lang.Boolean> grantUniveralAccess)
        Creates an isolated world for the given frame.
      • deleteCookie

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> deleteCookie​(java.lang.String cookieName,
                                                                                        java.lang.String url)
        Deprecated.
        Deletes browser cookie with given name, domain and path.
      • disable

        public static org.openqa.selenium.devtools.Command<java.lang.Void> disable()
        Disables page domain notifications.
      • enable

        public static org.openqa.selenium.devtools.Command<java.lang.Void> enable()
        Enables page domain notifications.
      • getInstallabilityErrors

        @Beta
        public static org.openqa.selenium.devtools.Command<java.util.List<InstallabilityError>> getInstallabilityErrors()
      • getManifestIcons

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.String> getManifestIcons()
      • getCookies

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.util.List<Cookie>> getCookies()
        Deprecated.
        Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the `cookies` field.
      • getFrameTree

        public static org.openqa.selenium.devtools.Command<FrameTree> getFrameTree()
        Returns present frame tree structure.
      • getLayoutMetrics

        public static org.openqa.selenium.devtools.Command<Page.GetLayoutMetricsResponse> getLayoutMetrics()
        Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
      • getNavigationHistory

        public static org.openqa.selenium.devtools.Command<Page.GetNavigationHistoryResponse> getNavigationHistory()
        Returns navigation history for the current page.
      • resetNavigationHistory

        public static org.openqa.selenium.devtools.Command<java.lang.Void> resetNavigationHistory()
        Resets navigation history for the current page.
      • getResourceContent

        @Beta
        public static org.openqa.selenium.devtools.Command<Page.GetResourceContentResponse> getResourceContent​(FrameId frameId,
                                                                                                               java.lang.String url)
        Returns content of the given resource.
      • getResourceTree

        @Beta
        public static org.openqa.selenium.devtools.Command<FrameResourceTree> getResourceTree()
        Returns present frame / resource tree structure.
      • handleJavaScriptDialog

        public static org.openqa.selenium.devtools.Command<java.lang.Void> handleJavaScriptDialog​(java.lang.Boolean accept,
                                                                                                  java.util.Optional<java.lang.String> promptText)
        Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
      • navigate

        public static org.openqa.selenium.devtools.Command<Page.NavigateResponse> navigate​(java.lang.String url,
                                                                                           java.util.Optional<java.lang.String> referrer,
                                                                                           java.util.Optional<TransitionType> transitionType,
                                                                                           java.util.Optional<FrameId> frameId,
                                                                                           java.util.Optional<ReferrerPolicy> referrerPolicy)
        Navigates current page to the given URL.
      • navigateToHistoryEntry

        public static org.openqa.selenium.devtools.Command<java.lang.Void> navigateToHistoryEntry​(java.lang.Integer entryId)
        Navigates current page to the given history entry.
      • printToPDF

        public static org.openqa.selenium.devtools.Command<Page.PrintToPDFResponse> printToPDF​(java.util.Optional<java.lang.Boolean> landscape,
                                                                                               java.util.Optional<java.lang.Boolean> displayHeaderFooter,
                                                                                               java.util.Optional<java.lang.Boolean> printBackground,
                                                                                               java.util.Optional<java.lang.Number> scale,
                                                                                               java.util.Optional<java.lang.Number> paperWidth,
                                                                                               java.util.Optional<java.lang.Number> paperHeight,
                                                                                               java.util.Optional<java.lang.Number> marginTop,
                                                                                               java.util.Optional<java.lang.Number> marginBottom,
                                                                                               java.util.Optional<java.lang.Number> marginLeft,
                                                                                               java.util.Optional<java.lang.Number> marginRight,
                                                                                               java.util.Optional<java.lang.String> pageRanges,
                                                                                               java.util.Optional<java.lang.Boolean> ignoreInvalidPageRanges,
                                                                                               java.util.Optional<java.lang.String> headerTemplate,
                                                                                               java.util.Optional<java.lang.String> footerTemplate,
                                                                                               java.util.Optional<java.lang.Boolean> preferCSSPageSize,
                                                                                               java.util.Optional<Page.PrintToPDFTransferMode> transferMode)
        Print page as PDF.
      • reload

        public static org.openqa.selenium.devtools.Command<java.lang.Void> reload​(java.util.Optional<java.lang.Boolean> ignoreCache,
                                                                                  java.util.Optional<java.lang.String> scriptToEvaluateOnLoad)
        Reloads given page optionally ignoring the cache.
      • removeScriptToEvaluateOnLoad

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> removeScriptToEvaluateOnLoad​(ScriptIdentifier identifier)
        Deprecated.
        Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
      • removeScriptToEvaluateOnNewDocument

        public static org.openqa.selenium.devtools.Command<java.lang.Void> removeScriptToEvaluateOnNewDocument​(ScriptIdentifier identifier)
        Removes given script from the list.
      • screencastFrameAck

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> screencastFrameAck​(java.lang.Integer sessionId)
        Acknowledges that a screencast frame has been received by the frontend.
      • searchInResource

        @Beta
        public static org.openqa.selenium.devtools.Command<java.util.List<SearchMatch>> searchInResource​(FrameId frameId,
                                                                                                         java.lang.String url,
                                                                                                         java.lang.String query,
                                                                                                         java.util.Optional<java.lang.Boolean> caseSensitive,
                                                                                                         java.util.Optional<java.lang.Boolean> isRegex)
        Searches for given string in resource content.
      • setAdBlockingEnabled

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setAdBlockingEnabled​(java.lang.Boolean enabled)
        Enable Chrome's experimental ad filter on all sites.
      • setBypassCSP

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setBypassCSP​(java.lang.Boolean enabled)
        Enable page Content Security Policy by-passing.
      • setDeviceMetricsOverride

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDeviceMetricsOverride​(java.lang.Integer width,
                                                                                                    java.lang.Integer height,
                                                                                                    java.lang.Number deviceScaleFactor,
                                                                                                    java.lang.Boolean mobile,
                                                                                                    java.util.Optional<java.lang.Number> scale,
                                                                                                    java.util.Optional<java.lang.Integer> screenWidth,
                                                                                                    java.util.Optional<java.lang.Integer> screenHeight,
                                                                                                    java.util.Optional<java.lang.Integer> positionX,
                                                                                                    java.util.Optional<java.lang.Integer> positionY,
                                                                                                    java.util.Optional<java.lang.Boolean> dontSetVisibleSize,
                                                                                                    java.util.Optional<ScreenOrientation> screenOrientation,
                                                                                                    java.util.Optional<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).
      • setDeviceOrientationOverride

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDeviceOrientationOverride​(java.lang.Number alpha,
                                                                                                        java.lang.Number beta,
                                                                                                        java.lang.Number gamma)
        Deprecated.
        Overrides the Device Orientation.
      • setFontFamilies

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setFontFamilies​(FontFamilies fontFamilies)
        Set generic font families.
      • setFontSizes

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setFontSizes​(FontSizes fontSizes)
        Set default font sizes.
      • setDocumentContent

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDocumentContent​(FrameId frameId,
                                                                                              java.lang.String html)
        Sets given markup as the document's HTML.
      • setDownloadBehavior

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDownloadBehavior​(Page.SetDownloadBehaviorBehavior behavior,
                                                                                               java.util.Optional<java.lang.String> downloadPath)
        Deprecated.
        Set the behavior when downloading a file.
      • setGeolocationOverride

        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setGeolocationOverride​(java.util.Optional<java.lang.Number> latitude,
                                                                                                  java.util.Optional<java.lang.Number> longitude,
                                                                                                  java.util.Optional<java.lang.Number> accuracy)
        Deprecated.
        Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
      • setLifecycleEventsEnabled

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setLifecycleEventsEnabled​(java.lang.Boolean enabled)
        Controls whether page will emit lifecycle events.
      • setTouchEmulationEnabled

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setTouchEmulationEnabled​(java.lang.Boolean enabled,
                                                                                                    java.util.Optional<Page.SetTouchEmulationEnabledConfiguration> configuration)
        Deprecated.
        Toggles mouse event-based touch event emulation.
      • startScreencast

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> startScreencast​(java.util.Optional<Page.StartScreencastFormat> format,
                                                                                           java.util.Optional<java.lang.Integer> quality,
                                                                                           java.util.Optional<java.lang.Integer> maxWidth,
                                                                                           java.util.Optional<java.lang.Integer> maxHeight,
                                                                                           java.util.Optional<java.lang.Integer> everyNthFrame)
        Starts sending each frame using the `screencastFrame` event.
      • stopLoading

        public static org.openqa.selenium.devtools.Command<java.lang.Void> stopLoading()
        Force the page stop all navigations and pending resource fetches.
      • crash

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> crash()
        Crashes renderer on the IO thread, generates minidumps.
      • close

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> close()
        Tries to close page, running its beforeunload hooks, if any.
      • setWebLifecycleState

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setWebLifecycleState​(Page.SetWebLifecycleStateState 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/
      • stopScreencast

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> stopScreencast()
        Stops sending each frame in the `screencastFrame`.
      • setProduceCompilationCache

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setProduceCompilationCache​(java.lang.Boolean enabled)
        Forces compilation cache to be generated for every subresource script.
      • addCompilationCache

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> addCompilationCache​(java.lang.String url,
                                                                                               java.lang.String data)
        Seeds compilation cache for given url. Compilation cache does not survive cross-process navigation.
      • clearCompilationCache

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearCompilationCache()
        Clears seeded compilation cache.
      • generateTestReport

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> generateTestReport​(java.lang.String message,
                                                                                              java.util.Optional<java.lang.String> group)
        Generates a report for testing.
      • waitForDebugger

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> waitForDebugger()
        Pauses page execution. Can be resumed using generic Runtime.runIfWaitingForDebugger.
      • setInterceptFileChooserDialog

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setInterceptFileChooserDialog​(java.lang.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.
      • domContentEventFired

        public static org.openqa.selenium.devtools.Event<MonotonicTime> domContentEventFired()
      • fileChooserOpened

        public static org.openqa.selenium.devtools.Event<FileChooserOpened> fileChooserOpened()
      • frameAttached

        public static org.openqa.selenium.devtools.Event<FrameAttached> frameAttached()
      • frameClearedScheduledNavigation

        public static org.openqa.selenium.devtools.Event<FrameId> frameClearedScheduledNavigation()
      • frameDetached

        public static org.openqa.selenium.devtools.Event<FrameId> frameDetached()
      • frameNavigated

        public static org.openqa.selenium.devtools.Event<Frame> frameNavigated()
      • frameResized

        public static org.openqa.selenium.devtools.Event<java.lang.Void> frameResized()
      • frameRequestedNavigation

        public static org.openqa.selenium.devtools.Event<FrameRequestedNavigation> frameRequestedNavigation()
      • frameScheduledNavigation

        public static org.openqa.selenium.devtools.Event<FrameScheduledNavigation> frameScheduledNavigation()
      • frameStartedLoading

        public static org.openqa.selenium.devtools.Event<FrameId> frameStartedLoading()
      • frameStoppedLoading

        public static org.openqa.selenium.devtools.Event<FrameId> frameStoppedLoading()
      • downloadWillBegin

        public static org.openqa.selenium.devtools.Event<DownloadWillBegin> downloadWillBegin()
      • downloadProgress

        public static org.openqa.selenium.devtools.Event<DownloadProgress> downloadProgress()
      • interstitialHidden

        public static org.openqa.selenium.devtools.Event<java.lang.Void> interstitialHidden()
      • interstitialShown

        public static org.openqa.selenium.devtools.Event<java.lang.Void> interstitialShown()
      • javascriptDialogClosed

        public static org.openqa.selenium.devtools.Event<JavascriptDialogClosed> javascriptDialogClosed()
      • javascriptDialogOpening

        public static org.openqa.selenium.devtools.Event<JavascriptDialogOpening> javascriptDialogOpening()
      • lifecycleEvent

        public static org.openqa.selenium.devtools.Event<LifecycleEvent> lifecycleEvent()
      • loadEventFired

        public static org.openqa.selenium.devtools.Event<MonotonicTime> loadEventFired()
      • navigatedWithinDocument

        public static org.openqa.selenium.devtools.Event<NavigatedWithinDocument> navigatedWithinDocument()
      • screencastFrame

        public static org.openqa.selenium.devtools.Event<ScreencastFrame> screencastFrame()
      • screencastVisibilityChanged

        public static org.openqa.selenium.devtools.Event<java.lang.Boolean> screencastVisibilityChanged()
      • windowOpen

        public static org.openqa.selenium.devtools.Event<WindowOpen> windowOpen()
      • compilationCacheProduced

        public static org.openqa.selenium.devtools.Event<CompilationCacheProduced> compilationCacheProduced()