Class Target
- java.lang.Object
-
- org.openqa.selenium.devtools.target.Target
-
public class Target extends java.lang.Object
Supports additional targets discovery and allows to attach to them.
-
-
Constructor Summary
Constructors Constructor Description Target()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Command<java.lang.Void>
activateTarget(TargetID targetId)
Activates (focuses) the target.static Event<AttachedToTarget>
attachedToTarget()
static Command<SessionID>
attachToBrowserTarget()
Attaches to the browser target, only uses flat sessionId mode.static Command<SessionID>
attachToTarget(TargetID targetId, java.util.Optional<java.lang.Boolean> flatten)
Attaches to the target with given id.static Command<java.lang.Boolean>
closeTarget(TargetID targetId)
Closes the target.static Command<BrowserContextID>
createBrowserContext()
Creates a new empty BrowserContext.static Command<TargetID>
createTarget(java.lang.String url, java.util.Optional<java.lang.Integer> width, java.util.Optional<java.lang.Integer> height, java.util.Optional<BrowserContextID> browserContextId, java.util.Optional<java.lang.Boolean> enableBeginFrameControl, java.util.Optional<java.lang.Boolean> newWindow, java.util.Optional<java.lang.Boolean> background)
Creates a new page.static Event<DetachedFromTarget>
detachedFromTarget()
static Command<java.lang.Void>
detachFromTarget(java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
Detaches session with given id.static Command<java.lang.Void>
disposeBrowserContext(BrowserContextID browserContextId)
Deletes a BrowserContext.static Command<java.lang.Void>
exposeDevToolsProtocol(TargetID targetId, java.util.Optional<java.lang.String> bindingName)
Inject object to the target's main frame that provides a communication channel with browser target.static Command<java.util.List<BrowserContextID>>
getBrowserContexts()
Returns all browser contexts created with `Target.createBrowserContext` method.static Command<TargetInfo>
getTargetInfo(java.util.Optional<TargetID> targetId)
Returns information about a target.static Command<java.util.List<TargetInfo>>
getTargets()
Retrieves a list of available targets.static Event<ReceivedMessageFromTarget>
receivedMessageFromTarget()
static Command<java.lang.Void>
sendMessageToTarget(java.lang.String message, java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
Sends protocol message over session with given id.static Command<java.lang.Void>
setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart, java.util.Optional<java.lang.Boolean> flatten)
Controls whether to automatically attach to new targets which are considered to be related to this one.static Command<java.lang.Void>
setDiscoverTargets(java.lang.Boolean discover)
Controls whether to discover available targets and notify via `targetCreated/targetInfoChanged/targetDestroyed` events.static Command<java.lang.Void>
setRemoteLocations(java.util.List<RemoteLocation> locations)
Enables target discovery for the specified locations, when `setDiscoverTargets` was set to `true`.static Event<TargetCrashed>
targetCrashed()
static Event<TargetInfo>
targetCreated()
static Event<TargetID>
targetDestroyed()
static Event<TargetInfo>
targetInfoChanged()
-
-
-
Method Detail
-
activateTarget
public static Command<java.lang.Void> activateTarget(TargetID targetId)
Activates (focuses) the target.
-
attachToTarget
public static Command<SessionID> attachToTarget(TargetID targetId, java.util.Optional<java.lang.Boolean> flatten)
Attaches to the target with given id.
-
attachToBrowserTarget
@Beta public static Command<SessionID> attachToBrowserTarget()
Attaches to the browser target, only uses flat sessionId mode.
-
closeTarget
public static Command<java.lang.Boolean> closeTarget(TargetID targetId)
Closes the target. If the target is a page that gets closed too.
-
exposeDevToolsProtocol
@Beta public static Command<java.lang.Void> exposeDevToolsProtocol(TargetID targetId, java.util.Optional<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 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.
-
createBrowserContext
@Beta public static Command<BrowserContextID> createBrowserContext()
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
-
getBrowserContexts
@Beta public static Command<java.util.List<BrowserContextID>> getBrowserContexts()
Returns all browser contexts created with `Target.createBrowserContext` method.
-
createTarget
public static Command<TargetID> createTarget(java.lang.String url, java.util.Optional<java.lang.Integer> width, java.util.Optional<java.lang.Integer> height, java.util.Optional<BrowserContextID> browserContextId, java.util.Optional<java.lang.Boolean> enableBeginFrameControl, java.util.Optional<java.lang.Boolean> newWindow, java.util.Optional<java.lang.Boolean> background)
Creates a new page.
-
detachFromTarget
public static Command<java.lang.Void> detachFromTarget(java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
Detaches session with given id.
-
disposeBrowserContext
@Beta public static Command<java.lang.Void> disposeBrowserContext(BrowserContextID browserContextId)
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
-
getTargetInfo
@Beta public static Command<TargetInfo> getTargetInfo(java.util.Optional<TargetID> targetId)
Returns information about a target.
-
getTargets
public static Command<java.util.List<TargetInfo>> getTargets()
Retrieves a list of available targets.
-
sendMessageToTarget
public static Command<java.lang.Void> sendMessageToTarget(java.lang.String message, java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
Sends protocol message over session with given id.
-
setAutoAttach
@Beta public static Command<java.lang.Void> setAutoAttach(java.lang.Boolean autoAttach, java.lang.Boolean waitForDebuggerOnStart, java.util.Optional<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.
-
setDiscoverTargets
public static Command<java.lang.Void> setDiscoverTargets(java.lang.Boolean discover)
Controls whether to discover available targets and notify via `targetCreated/targetInfoChanged/targetDestroyed` events.
-
setRemoteLocations
@Beta public static Command<java.lang.Void> setRemoteLocations(java.util.List<RemoteLocation> locations)
Enables target discovery for the specified locations, when `setDiscoverTargets` was set to `true`.
-
attachedToTarget
public static Event<AttachedToTarget> attachedToTarget()
-
detachedFromTarget
public static Event<DetachedFromTarget> detachedFromTarget()
-
receivedMessageFromTarget
public static Event<ReceivedMessageFromTarget> receivedMessageFromTarget()
-
targetCreated
public static Event<TargetInfo> targetCreated()
-
targetCrashed
public static Event<TargetCrashed> targetCrashed()
-
targetInfoChanged
public static Event<TargetInfo> targetInfoChanged()
-
-