Class Target


  • public class Target
    extends java.lang.Object
    • Constructor Detail

      • Target

        public Target()
    • Method Detail

      • activateTarget

        public static Command<java.lang.Void> activateTarget​(TargetId targetId)
        Activates (focuses) the target.
      • attachToBrowserTarget

        @Beta
        public static Command<org.openqa.selenium.remote.SessionId> attachToBrowserTarget()
        Attaches to the browser target, only uses flat sessionId mode.EXPERIMENTAL
        Returns:
        SessionId
      • 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 equals to json then bing to handleMessage(json) - a callback that will be called for the protocol notifications and command responses. EXPERIMENTAL
      • createBrowserContext

        @Beta
        public static Command<BrowserContextID> createBrowserContext()
        Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.EXPERIMENTAL
      • getBrowserContexts

        @Beta
        public static Command<java.util.List<BrowserContextID>> getBrowserContexts()
        Returns all browser contexts created with Target.createBrowserContext method.EXPERIMENTAL
      • 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<org.openqa.selenium.remote.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.EXPERIMENTAL
      • getTargetInfo

        @Beta
        public static Command<TargetInfo> getTargetInfo​(java.util.Optional<TargetId> targetId)
        Returns information about a target.EXPERIMENTAL
      • getTargets

        public static Command<java.util.Set<TargetInfo>> getTargets()
        Retrieves a list of available targets.
      • sendMessageToTarget

        public static Command<java.lang.Void> sendMessageToTarget​(java.lang.String message,
                                                                  java.util.Optional<org.openqa.selenium.remote.SessionId> sessionID,
                                                                  @Deprecated
                                                                  java.util.Optional<TargetId> targetID)
        Controls whether to discover available targets and notify via targetCreated/targetInfoChanged/targetDestroyed events.
      • attachToTarget

        public static Command<org.openqa.selenium.remote.SessionId> attachToTarget​(TargetId targetId,
                                                                                   java.util.Optional<java.lang.Boolean> flatten)
        Attaches to the target with given id.
        Returns:
        SessionId
      • 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.EXPERIMENTAL
      • setDiscoverTargets

        public static Command<java.lang.Void> setDiscoverTargets​(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.EXPERIMENTAL
      • attachedToTarget

        @Beta
        public static Event<AttachToTarget> attachedToTarget()
        Issued when attached to target because of auto-attach or attachToTarget command.EXPERIMENTAL
      • detachedFromTarget

        @Beta
        public static Event<DetachedFromTarget> detachedFromTarget()
        Issued when detached from target for any reason (including detachFromTarget command). Can be issued multiple times per target if multiple sessions have been attached to it.EXPERIMENTAL
      • receivedMessageFromTarget

        public static Event<ReceivedMessageFromTarget> receivedMessageFromTarget()
        Notifies about a new protocol message received from the session (as reported in attachedToTarget event).
      • targetCreated

        public static Event<TargetInfo> targetCreated()
        Issued when a possible inspection target is created.
      • targetDestroyed

        public static Event<TargetId> targetDestroyed()
        Issued when a target is destroyed.
      • targetCrashed

        public static Event<TargetCrashed> targetCrashed()
        Issued when a target has crashed.
      • targetInfoChanged

        public static Event<TargetInfo> targetInfoChanged()
        Issued when some information about a target has changed. This only happens between targetCreated and targetDestroyed.