public interface Page
| Modifier and Type | Method and Description |
|---|---|
void |
addCompilationCache(String url,
String data)
Seeds compilation cache for given url.
|
String |
addScriptToEvaluateOnLoad(String scriptSource)
Deprecated.
|
String |
addScriptToEvaluateOnNewDocument(String source)
Evaluates given script in every frame upon creation (before loading frame's scripts).
|
String |
addScriptToEvaluateOnNewDocument(String source,
String worldName)
Evaluates given script in every frame upon creation (before loading frame's scripts).
|
void |
bringToFront()
Brings page to front (activates tab).
|
String |
captureScreenshot()
Capture page screenshot.
|
String |
captureScreenshot(CaptureScreenshotFormat format,
Integer quality,
Viewport clip,
Boolean fromSurface)
Capture page screenshot.
|
String |
captureSnapshot()
Returns a snapshot of the page as a string.
|
String |
captureSnapshot(CaptureSnapshotFormat format)
Returns a snapshot of the page as a string.
|
void |
clearCompilationCache()
Clears seeded compilation cache.
|
void |
close()
Tries to close page, running its beforeunload hooks, if any.
|
void |
crash()
Crashes renderer on the IO thread, generates minidumps.
|
Integer |
createIsolatedWorld(String frameId)
Creates an isolated world for the given frame.
|
Integer |
createIsolatedWorld(String frameId,
String worldName,
Boolean grantUniveralAccess)
Creates an isolated world for the given frame.
|
void |
disable()
Disables page domain notifications.
|
void |
enable()
Enables page domain notifications.
|
void |
generateTestReport(String message)
Generates a report for testing.
|
void |
generateTestReport(String message,
String group)
Generates a report for testing.
|
AppManifest |
getAppManifest() |
FrameTree |
getFrameTree()
Returns present frame tree structure.
|
List<String> |
getInstallabilityErrors() |
LayoutMetrics |
getLayoutMetrics()
Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
|
NavigationHistory |
getNavigationHistory()
Returns navigation history for the current page.
|
ResourceContent |
getResourceContent(String frameId,
String url)
Returns content of the given resource.
|
FrameResourceTree |
getResourceTree()
Returns present frame / resource tree structure.
|
void |
handleFileChooser(HandleFileChooserAction action)
Accepts or cancels an intercepted file chooser dialog.
|
void |
handleFileChooser(HandleFileChooserAction action,
List<String> files)
Accepts or cancels an intercepted file chooser dialog.
|
void |
handleJavaScriptDialog(Boolean accept)
Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
|
void |
handleJavaScriptDialog(Boolean accept,
String promptText)
Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
|
Navigate |
navigate(String url)
Navigates current page to the given URL.
|
Navigate |
navigate(String url,
String referrer,
TransitionType transitionType,
String frameId)
Navigates current page to the given URL.
|
void |
navigateToHistoryEntry(Integer entryId)
Navigates current page to the given history entry.
|
EventListener |
onCompilationCacheProduced(EventHandler<CompilationCacheProduced> eventListener)
Issued for every compilation cache generated.
|
EventListener |
onDomContentEventFired(EventHandler<DomContentEventFired> eventListener) |
EventListener |
onDownloadWillBegin(EventHandler<DownloadWillBegin> eventListener)
Fired when page is about to start a download.
|
EventListener |
onFileChooserOpened(EventHandler<FileChooserOpened> eventListener)
Emitted only when `page.interceptFileChooser` is enabled.
|
EventListener |
onFrameAttached(EventHandler<FrameAttached> eventListener)
Fired when frame has been attached to its parent.
|
EventListener |
onFrameClearedScheduledNavigation(EventHandler<FrameClearedScheduledNavigation> eventListener)
Deprecated.
|
EventListener |
onFrameDetached(EventHandler<FrameDetached> eventListener)
Fired when frame has been detached from its parent.
|
EventListener |
onFrameNavigated(EventHandler<FrameNavigated> eventListener)
Fired once navigation of the frame has completed.
|
EventListener |
onFrameRequestedNavigation(EventHandler<FrameRequestedNavigation> eventListener)
Fired when a renderer-initiated navigation is requested.
|
EventListener |
onFrameResized(EventHandler<FrameResized> eventListener) |
EventListener |
onFrameScheduledNavigation(EventHandler<FrameScheduledNavigation> eventListener)
Deprecated.
|
EventListener |
onFrameStartedLoading(EventHandler<FrameStartedLoading> eventListener)
Fired when frame has started loading.
|
EventListener |
onFrameStoppedLoading(EventHandler<FrameStoppedLoading> eventListener)
Fired when frame has stopped loading.
|
EventListener |
onInterstitialHidden(EventHandler<InterstitialHidden> eventListener)
Fired when interstitial page was hidden
|
EventListener |
onInterstitialShown(EventHandler<InterstitialShown> eventListener)
Fired when interstitial page was shown
|
EventListener |
onJavascriptDialogClosed(EventHandler<JavascriptDialogClosed> eventListener)
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been
closed.
|
EventListener |
onJavascriptDialogOpening(EventHandler<JavascriptDialogOpening> eventListener)
Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about
to open.
|
EventListener |
onLifecycleEvent(EventHandler<LifecycleEvent> eventListener)
Fired for top level page lifecycle events such as navigation, load, paint, etc.
|
EventListener |
onLoadEventFired(EventHandler<LoadEventFired> eventListener) |
EventListener |
onNavigatedWithinDocument(EventHandler<NavigatedWithinDocument> eventListener)
Fired when same-document navigation happens, e.g.
|
EventListener |
onScreencastFrame(EventHandler<ScreencastFrame> eventListener)
Compressed image data requested by the `startScreencast`.
|
EventListener |
onScreencastVisibilityChanged(EventHandler<ScreencastVisibilityChanged> eventListener)
Fired when the page with currently enabled screencast was shown or hidden `.
|
EventListener |
onWindowOpen(EventHandler<WindowOpen> eventListener)
Fired when a new window is going to be opened, via window.open(), link click, form submission,
etc.
|
PrintToPDF |
printToPDF()
Print page as PDF.
|
PrintToPDF |
printToPDF(Boolean landscape,
Boolean displayHeaderFooter,
Boolean printBackground,
Double scale,
Double paperWidth,
Double paperHeight,
Double marginTop,
Double marginBottom,
Double marginLeft,
Double marginRight,
String pageRanges,
Boolean ignoreInvalidPageRanges,
String headerTemplate,
String footerTemplate,
Boolean preferCSSPageSize,
PrintToPDFTransferMode transferMode)
Print page as PDF.
|
void |
reload()
Reloads given page optionally ignoring the cache.
|
void |
reload(Boolean ignoreCache,
String scriptToEvaluateOnLoad)
Reloads given page optionally ignoring the cache.
|
void |
removeScriptToEvaluateOnLoad(String identifier)
Deprecated.
|
void |
removeScriptToEvaluateOnNewDocument(String identifier)
Removes given script from the list.
|
void |
resetNavigationHistory()
Resets navigation history for the current page.
|
void |
screencastFrameAck(Integer sessionId)
Acknowledges that a screencast frame has been received by the frontend.
|
List<SearchMatch> |
searchInResource(String frameId,
String url,
String query)
Searches for given string in resource content.
|
List<SearchMatch> |
searchInResource(String frameId,
String url,
String query,
Boolean caseSensitive,
Boolean isRegex)
Searches for given string in resource content.
|
void |
setAdBlockingEnabled(Boolean enabled)
Enable Chrome's experimental ad filter on all sites.
|
void |
setBypassCSP(Boolean enabled)
Enable page Content Security Policy by-passing.
|
void |
setDocumentContent(String frameId,
String html)
Sets given markup as the document's HTML.
|
void |
setDownloadBehavior(SetDownloadBehaviorBehavior behavior)
Set the behavior when downloading a file.
|
void |
setDownloadBehavior(SetDownloadBehaviorBehavior behavior,
String downloadPath)
Set the behavior when downloading a file.
|
void |
setFontFamilies(FontFamilies fontFamilies)
Set generic font families.
|
void |
setFontSizes(FontSizes fontSizes)
Set default font sizes.
|
void |
setInterceptFileChooserDialog(Boolean enabled)
Intercept file chooser requests and transfer control to protocol clients.
|
void |
setLifecycleEventsEnabled(Boolean enabled)
Controls whether page will emit lifecycle events.
|
void |
setProduceCompilationCache(Boolean enabled)
Forces compilation cache to be generated for every subresource script.
|
void |
setWebLifecycleState(SetWebLifecycleStateState state)
Tries to update the web lifecycle state of the page.
|
void |
startScreencast()
Starts sending each frame using the `screencastFrame` event.
|
void |
startScreencast(StartScreencastFormat format,
Integer quality,
Integer maxWidth,
Integer maxHeight,
Integer everyNthFrame)
Starts sending each frame using the `screencastFrame` event.
|
void |
stopLoading()
Force the page stop all navigations and pending resource fetches.
|
void |
stopScreencast()
Stops sending each frame in the `screencastFrame`.
|
void |
waitForDebugger()
Pauses page execution.
|
@Deprecated String addScriptToEvaluateOnLoad(String scriptSource)
scriptSource - String addScriptToEvaluateOnNewDocument(String source)
source - String addScriptToEvaluateOnNewDocument(String source, String worldName)
source - 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.void bringToFront()
String captureScreenshot()
String captureScreenshot(CaptureScreenshotFormat format, Integer quality, Viewport clip, Boolean fromSurface)
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.String captureSnapshot()
String captureSnapshot(CaptureSnapshotFormat format)
format - Format (defaults to mhtml).Integer createIsolatedWorld(String frameId)
frameId - Id of the frame in which the isolated world should be created.Integer createIsolatedWorld(String frameId, String worldName, Boolean grantUniveralAccess)
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.void disable()
void enable()
AppManifest getAppManifest()
FrameTree getFrameTree()
LayoutMetrics getLayoutMetrics()
NavigationHistory getNavigationHistory()
void resetNavigationHistory()
ResourceContent getResourceContent(String frameId, String url)
frameId - Frame id to get resource for.url - URL of the resource to get content for.FrameResourceTree getResourceTree()
void handleJavaScriptDialog(Boolean accept)
accept - Whether to accept or dismiss the dialog.void handleJavaScriptDialog(Boolean accept, String promptText)
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.Navigate navigate(String url)
url - URL to navigate the page to.Navigate navigate(String url, String referrer, TransitionType transitionType, String frameId)
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.void navigateToHistoryEntry(Integer entryId)
entryId - Unique id of the entry to navigate to.PrintToPDF printToPDF()
PrintToPDF printToPDF(Boolean landscape, Boolean displayHeaderFooter, Boolean printBackground, Double scale, Double paperWidth, Double paperHeight, Double marginTop, Double marginBottom, Double marginLeft, Double marginRight, String pageRanges, Boolean ignoreInvalidPageRanges, String headerTemplate, String footerTemplate, Boolean preferCSSPageSize, PrintToPDFTransferMode transferMode)
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, e.g., '1-5, 8, 11-13'. Defaults to the empty string,
which means print all pages.ignoreInvalidPageRanges - Whether to silently ignore invalid but successfully parsed page
ranges, such as '3-2'. Defaults to false.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 streamvoid reload()
void reload(Boolean ignoreCache, String scriptToEvaluateOnLoad)
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.@Deprecated void removeScriptToEvaluateOnLoad(String identifier)
identifier - void removeScriptToEvaluateOnNewDocument(String identifier)
identifier - void screencastFrameAck(Integer sessionId)
sessionId - Frame number.List<SearchMatch> searchInResource(String frameId, String url, String query)
frameId - Frame id for resource to search in.url - URL of the resource to search in.query - String to search for.List<SearchMatch> searchInResource(String frameId, String url, String query, Boolean caseSensitive, Boolean isRegex)
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.void setAdBlockingEnabled(Boolean enabled)
enabled - Whether to block ads.void setBypassCSP(Boolean enabled)
enabled - Whether to bypass page CSP.void setFontFamilies(FontFamilies fontFamilies)
fontFamilies - Specifies font families to set. If a font family is not specified, it won't
be changed.void setFontSizes(FontSizes fontSizes)
fontSizes - Specifies font sizes to set. If a font size is not specified, it won't be
changed.void setDocumentContent(String frameId, String html)
frameId - Frame id to set HTML for.html - HTML content to set.void setDownloadBehavior(SetDownloadBehaviorBehavior behavior)
behavior - Whether to allow all or deny all download requests, or use default Chrome
behavior if available (otherwise deny).void setDownloadBehavior(SetDownloadBehaviorBehavior behavior, String downloadPath)
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 requred if behavior
is set to 'allow'void setLifecycleEventsEnabled(Boolean enabled)
enabled - If true, starts emitting lifecycle events.void startScreencast()
void startScreencast(StartScreencastFormat format, Integer quality, Integer maxWidth, Integer maxHeight, Integer everyNthFrame)
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.void stopLoading()
void crash()
void close()
void setWebLifecycleState(SetWebLifecycleStateState state)
state - Target lifecycle statevoid stopScreencast()
void setProduceCompilationCache(Boolean enabled)
enabled - void addCompilationCache(String url, String data)
url - data - Base64-encoded datavoid clearCompilationCache()
void generateTestReport(String message)
message - Message to be displayed in the report.void generateTestReport(String message, String group)
message - Message to be displayed in the report.group - Specifies the endpoint group to deliver the report to.void waitForDebugger()
void setInterceptFileChooserDialog(Boolean enabled)
enabled - void handleFileChooser(HandleFileChooserAction action)
action - void handleFileChooser(HandleFileChooserAction action, List<String> files)
action - files - Array of absolute file paths to set, only respected with `accept` action.EventListener onDomContentEventFired(EventHandler<DomContentEventFired> eventListener)
EventListener onFileChooserOpened(EventHandler<FileChooserOpened> eventListener)
EventListener onFrameAttached(EventHandler<FrameAttached> eventListener)
@Deprecated EventListener onFrameClearedScheduledNavigation(EventHandler<FrameClearedScheduledNavigation> eventListener)
EventListener onFrameDetached(EventHandler<FrameDetached> eventListener)
EventListener onFrameNavigated(EventHandler<FrameNavigated> eventListener)
EventListener onFrameResized(EventHandler<FrameResized> eventListener)
EventListener onFrameRequestedNavigation(EventHandler<FrameRequestedNavigation> eventListener)
@Deprecated EventListener onFrameScheduledNavigation(EventHandler<FrameScheduledNavigation> eventListener)
EventListener onFrameStartedLoading(EventHandler<FrameStartedLoading> eventListener)
EventListener onFrameStoppedLoading(EventHandler<FrameStoppedLoading> eventListener)
EventListener onDownloadWillBegin(EventHandler<DownloadWillBegin> eventListener)
EventListener onInterstitialHidden(EventHandler<InterstitialHidden> eventListener)
EventListener onInterstitialShown(EventHandler<InterstitialShown> eventListener)
EventListener onJavascriptDialogClosed(EventHandler<JavascriptDialogClosed> eventListener)
EventListener onJavascriptDialogOpening(EventHandler<JavascriptDialogOpening> eventListener)
EventListener onLifecycleEvent(EventHandler<LifecycleEvent> eventListener)
EventListener onLoadEventFired(EventHandler<LoadEventFired> eventListener)
EventListener onNavigatedWithinDocument(EventHandler<NavigatedWithinDocument> eventListener)
EventListener onScreencastFrame(EventHandler<ScreencastFrame> eventListener)
EventListener onScreencastVisibilityChanged(EventHandler<ScreencastVisibilityChanged> eventListener)
EventListener onWindowOpen(EventHandler<WindowOpen> eventListener)
EventListener onCompilationCacheProduced(EventHandler<CompilationCacheProduced> eventListener)
Copyright © 2020. All rights reserved.