public interface Target
| Modifier and Type | Method and Description |
|---|---|
void |
activateTarget(String targetId)
Activates (focuses) the target.
|
String |
attachToBrowserTarget()
Attaches to the browser target, only uses flat sessionId mode.
|
String |
attachToTarget(String targetId)
Attaches to the target with given id.
|
String |
attachToTarget(String targetId,
Boolean flatten)
Attaches to the target with given id.
|
Boolean |
closeTarget(String targetId)
Closes the target.
|
String |
createBrowserContext()
Creates a new empty BrowserContext.
|
String |
createTarget(String url)
Creates a new page.
|
String |
createTarget(String url,
Integer width,
Integer height,
String browserContextId,
Boolean enableBeginFrameControl,
Boolean newWindow,
Boolean background)
Creates a new page.
|
void |
detachFromTarget()
Detaches session with given id.
|
void |
detachFromTarget(String sessionId,
String targetId)
Detaches session with given id.
|
void |
disposeBrowserContext(String browserContextId)
Deletes a BrowserContext.
|
void |
exposeDevToolsProtocol(String targetId)
Inject object to the target's main frame that provides a communication channel with browser
target.
|
void |
exposeDevToolsProtocol(String targetId,
String bindingName)
Inject object to the target's main frame that provides a communication channel with browser
target.
|
List<String> |
getBrowserContexts()
Returns all browser contexts created with `Target.createBrowserContext` method.
|
TargetInfo |
getTargetInfo()
Returns information about a target.
|
TargetInfo |
getTargetInfo(String targetId)
Returns information about a target.
|
List<TargetInfo> |
getTargets()
Retrieves a list of available targets.
|
EventListener |
onAttachedToTarget(EventHandler<AttachedToTarget> eventListener)
Issued when attached to target because of auto-attach or `attachToTarget` command.
|
EventListener |
onDetachedFromTarget(EventHandler<DetachedFromTarget> eventListener)
Issued when detached from target for any reason (including `detachFromTarget` command).
|
EventListener |
onReceivedMessageFromTarget(EventHandler<ReceivedMessageFromTarget> eventListener)
Notifies about a new protocol message received from the session (as reported in
`attachedToTarget` event).
|
EventListener |
onTargetCrashed(EventHandler<TargetCrashed> eventListener)
Issued when a target has crashed.
|
EventListener |
onTargetCreated(EventHandler<TargetCreated> eventListener)
Issued when a possible inspection target is created.
|
EventListener |
onTargetDestroyed(EventHandler<TargetDestroyed> eventListener)
Issued when a target is destroyed.
|
EventListener |
onTargetInfoChanged(EventHandler<TargetInfoChanged> eventListener)
Issued when some information about a target has changed.
|
void |
sendMessageToTarget(String message)
Sends protocol message over session with given id.
|
void |
sendMessageToTarget(String message,
String sessionId,
String targetId)
Sends protocol message over session with given id.
|
void |
setAutoAttach(Boolean autoAttach,
Boolean waitForDebuggerOnStart)
Controls whether to automatically attach to new targets which are considered to be related to
this one.
|
void |
setAutoAttach(Boolean autoAttach,
Boolean waitForDebuggerOnStart,
Boolean flatten)
Controls whether to automatically attach to new targets which are considered to be related to
this one.
|
void |
setDiscoverTargets(Boolean discover)
Controls whether to discover available targets and notify via
`targetCreated/targetInfoChanged/targetDestroyed` events.
|
void |
setRemoteLocations(List<RemoteLocation> locations)
Enables target discovery for the specified locations, when `setDiscoverTargets` was set to
`true`.
|
void activateTarget(String targetId)
targetId - String attachToTarget(String targetId)
targetId - String attachToTarget(String targetId, Boolean flatten)
targetId - flatten - Enables "flat" access to the session via specifying sessionId attribute in the
commands.String attachToBrowserTarget()
Boolean closeTarget(String targetId)
targetId - void exposeDevToolsProtocol(String targetId)
Injected object will be available as `window[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.
targetId - void exposeDevToolsProtocol(String targetId, String bindingName)
Injected object will be available as `window[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.
targetId - bindingName - Binding name, 'cdp' if not specified.String createBrowserContext()
List<String> getBrowserContexts()
String createTarget(String url)
url - The initial URL the page will be navigated to.String createTarget(String url, Integer width, Integer height, String browserContextId, Boolean enableBeginFrameControl, Boolean newWindow, Boolean background)
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).newWindow - Whether to create a new Window or Tab (chrome-only, false by default).background - Whether to create the target in background or foreground (chrome-only, false
by default).void detachFromTarget()
void detachFromTarget(String sessionId, @Deprecated String targetId)
sessionId - Session to detach.targetId - Deprecated.void disposeBrowserContext(String browserContextId)
browserContextId - TargetInfo getTargetInfo()
TargetInfo getTargetInfo(String targetId)
targetId - List<TargetInfo> getTargets()
void sendMessageToTarget(String message)
message - void sendMessageToTarget(String message, String sessionId, @Deprecated String targetId)
message - sessionId - Identifier of the session.targetId - Deprecated.void setAutoAttach(Boolean autoAttach, Boolean waitForDebuggerOnStart)
autoAttach - Whether to auto-attach to related targets.waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use
`Runtime.runIfWaitingForDebugger` to run paused targets.void setAutoAttach(Boolean autoAttach, Boolean waitForDebuggerOnStart, Boolean flatten)
autoAttach - Whether to auto-attach to related targets.waitForDebuggerOnStart - Whether to pause new targets when attaching to them. Use
`Runtime.runIfWaitingForDebugger` to run paused targets.flatten - Enables "flat" access to the session via specifying sessionId attribute in the
commands.void setDiscoverTargets(Boolean discover)
discover - Whether to discover available targets.void setRemoteLocations(List<RemoteLocation> locations)
locations - List of remote locations.EventListener onAttachedToTarget(EventHandler<AttachedToTarget> eventListener)
EventListener onDetachedFromTarget(EventHandler<DetachedFromTarget> eventListener)
EventListener onReceivedMessageFromTarget(EventHandler<ReceivedMessageFromTarget> eventListener)
EventListener onTargetCreated(EventHandler<TargetCreated> eventListener)
EventListener onTargetDestroyed(EventHandler<TargetDestroyed> eventListener)
EventListener onTargetCrashed(EventHandler<TargetCrashed> eventListener)
EventListener onTargetInfoChanged(EventHandler<TargetInfoChanged> eventListener)
Copyright © 2020. All rights reserved.