Package io.webfolder.cdp.command
Interface Target
-
public interface Target
Supports additional targets discovery and allows to attach to them
-
-
Method Summary
Modifier and Type Method Description void
activateTarget(java.lang.String targetId)
Activates (focuses) the target.java.lang.String
attachToBrowserTarget()
Attaches to the browser target, only uses flat sessionId mode.java.lang.String
attachToTarget(java.lang.String targetId)
Attaches to the target with given id.java.lang.String
attachToTarget(java.lang.String targetId, java.lang.Boolean flatten)
Attaches to the target with given id.java.lang.Boolean
closeTarget(java.lang.String targetId)
Closes the target.java.lang.String
createBrowserContext()
Creates a new empty BrowserContext.java.lang.String
createTarget(java.lang.String url)
Creates a new page.java.lang.String
createTarget(java.lang.String url, java.lang.Integer width, java.lang.Integer height, java.lang.String browserContextId, java.lang.Boolean enableBeginFrameControl)
Creates a new page.void
detachFromTarget()
Detaches session with given id.void
detachFromTarget(java.lang.String sessionId, java.lang.String targetId)
Detaches session with given id.void
disposeBrowserContext(java.lang.String browserContextId)
Deletes a BrowserContext.void
exposeDevToolsProtocol(java.lang.String targetId)
Inject object to the target's main frame that provides a communication channel with browser target.void
exposeDevToolsProtocol(java.lang.String targetId, java.lang.String bindingName)
Inject object to the target's main frame that provides a communication channel with browser target.java.util.List<java.lang.String>
getBrowserContexts()
Returns all browser contexts created withTarget.createBrowserContext
method.TargetInfo
getTargetInfo()
Returns information about a target.TargetInfo
getTargetInfo(java.lang.String targetId)
Returns information about a target.java.util.List<TargetInfo>
getTargets()
Retrieves a list of available targets.void
sendMessageToTarget(java.lang.String message)
Sends protocol message over session with given id.void
sendMessageToTarget(java.lang.String message, java.lang.String sessionId, java.lang.String targetId)
Sends protocol message over session with given id.void
setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart)
Controls whether to automatically attach to new targets which are considered to be related to this one.void
setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart, java.lang.Boolean flatten)
Controls whether to automatically attach to new targets which are considered to be related to this one.void
setDiscoverTargets(java.lang.Boolean discover)
Controls whether to discover available targets and notify viatargetCreated/targetInfoChanged/targetDestroyed
events.void
setRemoteLocations(java.util.List<RemoteLocation> locations)
Enables target discovery for the specified locations, whensetDiscoverTargets
was set totrue
.
-
-
-
Method Detail
-
activateTarget
void activateTarget(java.lang.String targetId)
Activates (focuses) the target.
-
attachToTarget
java.lang.String attachToTarget(java.lang.String targetId, java.lang.Boolean flatten)
Attaches to the target with given id.- Parameters:
flatten
- Enables "flat" access to the session via specifying sessionId attribute in the commands.- Returns:
- Id assigned to the session.
-
attachToBrowserTarget
java.lang.String attachToBrowserTarget()
Attaches to the browser target, only uses flat sessionId mode.- Returns:
- Id assigned to the session.
-
closeTarget
java.lang.Boolean closeTarget(java.lang.String targetId)
Closes the target. If the target is a page that gets closed too.
-
exposeDevToolsProtocol
void exposeDevToolsProtocol(java.lang.String targetId, java.lang.String bindingName)
Inject object to the target's main frame that provides a communication channel with browser target. Injected object will be available aswindow[bindingName]
. The object has the follwing API: -binding.send(json)
- a method to send messages over the remote debugging protocol -binding.onmessage = json => handleMessage(json)
- a callback that will be called for the protocol notifications and command responses.- Parameters:
bindingName
- Binding name, 'cdp' if not specified.
-
createBrowserContext
java.lang.String createBrowserContext()
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.- Returns:
- The id of the context created.
-
getBrowserContexts
java.util.List<java.lang.String> getBrowserContexts()
Returns all browser contexts created withTarget.createBrowserContext
method.- Returns:
- An array of browser context ids.
-
createTarget
java.lang.String createTarget(java.lang.String url, java.lang.Integer width, java.lang.Integer height, java.lang.String browserContextId, java.lang.Boolean enableBeginFrameControl)
Creates a new page.- Parameters:
url
- The initial URL the page will be navigated to.width
- Frame width in DIP (headless chrome only).height
- Frame height in DIP (headless chrome only).browserContextId
- The browser context to create the page in.enableBeginFrameControl
- Whether BeginFrames for this target will be controlled via DevTools (headless chrome only, not supported on MacOS yet, false by default).- Returns:
- The id of the page opened.
-
detachFromTarget
void detachFromTarget(java.lang.String sessionId, java.lang.String targetId)
Detaches session with given id.- Parameters:
sessionId
- Session to detach.targetId
- Deprecated.
-
disposeBrowserContext
void disposeBrowserContext(java.lang.String browserContextId)
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
-
getTargetInfo
TargetInfo getTargetInfo(java.lang.String targetId)
Returns information about a target.
-
getTargets
java.util.List<TargetInfo> getTargets()
Retrieves a list of available targets.- Returns:
- The list of targets.
-
sendMessageToTarget
void sendMessageToTarget(java.lang.String message, java.lang.String sessionId, java.lang.String targetId)
Sends protocol message over session with given id.- Parameters:
sessionId
- Identifier of the session.targetId
- Deprecated.
-
setAutoAttach
void setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart, java.lang.Boolean flatten)
Controls whether to automatically attach to new targets which are considered to be related to this one. When turned on, attaches to all existing related targets as well. When turned off, automatically detaches from all currently attached targets.- Parameters:
autoAttach
- Whether to auto-attach to related targets.waitForDebuggerOnStart
- Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets.flatten
- Enables "flat" access to the session via specifying sessionId attribute in the commands.
-
setDiscoverTargets
void setDiscoverTargets(java.lang.Boolean discover)
Controls whether to discover available targets and notify viatargetCreated/targetInfoChanged/targetDestroyed
events.- Parameters:
discover
- Whether to discover available targets.
-
setRemoteLocations
void setRemoteLocations(java.util.List<RemoteLocation> locations)
Enables target discovery for the specified locations, whensetDiscoverTargets
was set totrue
.- Parameters:
locations
- List of remote locations.
-
attachToTarget
java.lang.String attachToTarget(java.lang.String targetId)
Attaches to the target with given id.- Returns:
- Id assigned to the session.
-
exposeDevToolsProtocol
void exposeDevToolsProtocol(java.lang.String targetId)
Inject object to the target's main frame that provides a communication channel with browser target. Injected object will be available aswindow[bindingName]
. The object has the follwing API: -binding.send(json)
- a method to send messages over the remote debugging protocol -binding.onmessage = json => handleMessage(json)
- a callback that will be called for the protocol notifications and command responses.
-
createTarget
java.lang.String createTarget(java.lang.String url)
Creates a new page.- Parameters:
url
- The initial URL the page will be navigated to.- Returns:
- The id of the page opened.
-
detachFromTarget
void detachFromTarget()
Detaches session with given id.
-
getTargetInfo
TargetInfo getTargetInfo()
Returns information about a target.
-
sendMessageToTarget
void sendMessageToTarget(java.lang.String message)
Sends protocol message over session with given id.
-
setAutoAttach
void setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart)
Controls whether to automatically attach to new targets which are considered to be related to this one. When turned on, attaches to all existing related targets as well. When turned off, automatically detaches from all currently attached targets.- Parameters:
autoAttach
- Whether to auto-attach to related targets.waitForDebuggerOnStart
- Whether to pause new targets when attaching to them. UseRuntime.runIfWaitingForDebugger
to run paused targets.
-
-