Class 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 Deprecated Methods 
      Modifier and Type Method Description
      static org.openqa.selenium.devtools.Command<java.lang.Void> activateTarget​(TargetID targetId)
      Activates (focuses) the target.
      static org.openqa.selenium.devtools.Event<AttachedToTarget> attachedToTarget()  
      static org.openqa.selenium.devtools.Command<SessionID> attachToBrowserTarget()
      Attaches to the browser target, only uses flat sessionId mode.
      static org.openqa.selenium.devtools.Command<SessionID> attachToTarget​(TargetID targetId, java.util.Optional<java.lang.Boolean> flatten)
      Attaches to the target with given id.
      static org.openqa.selenium.devtools.Command<java.lang.Boolean> closeTarget​(TargetID targetId)
      Closes the target.
      static org.openqa.selenium.devtools.Command<BrowserContextID> createBrowserContext​(java.util.Optional<java.lang.Boolean> disposeOnDetach, java.util.Optional<java.lang.String> proxyServer, java.util.Optional<java.lang.String> proxyBypassList)
      Creates a new empty BrowserContext.
      static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Event<DetachedFromTarget> detachedFromTarget()  
      static org.openqa.selenium.devtools.Command<java.lang.Void> detachFromTarget​(java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
      Detaches session with given id.
      static org.openqa.selenium.devtools.Command<java.lang.Void> disposeBrowserContext​(BrowserContextID browserContextId)
      Deletes a BrowserContext.
      static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Command<java.util.List<BrowserContextID>> getBrowserContexts()
      Returns all browser contexts created with `Target.createBrowserContext` method.
      static org.openqa.selenium.devtools.Command<TargetInfo> getTargetInfo​(java.util.Optional<TargetID> targetId)
      Returns information about a target.
      static org.openqa.selenium.devtools.Command<java.util.List<TargetInfo>> getTargets()
      Retrieves a list of available targets.
      static org.openqa.selenium.devtools.Event<ReceivedMessageFromTarget> receivedMessageFromTarget()  
      static org.openqa.selenium.devtools.Command<java.lang.Void> sendMessageToTarget​(java.lang.String message, java.util.Optional<SessionID> sessionId, java.util.Optional<TargetID> targetId)
      Deprecated.
      static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Command<java.lang.Void> setDiscoverTargets​(java.lang.Boolean discover)
      Controls whether to discover available targets and notify via `targetCreated/targetInfoChanged/targetDestroyed` events.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setRemoteLocations​(java.util.List<RemoteLocation> locations)
      Enables target discovery for the specified locations, when `setDiscoverTargets` was set to `true`.
      static org.openqa.selenium.devtools.Event<TargetCrashed> targetCrashed()  
      static org.openqa.selenium.devtools.Event<TargetInfo> targetCreated()  
      static org.openqa.selenium.devtools.Event<TargetID> targetDestroyed()  
      static org.openqa.selenium.devtools.Event<TargetInfo> targetInfoChanged()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Target

        public Target()
    • Method Detail

      • activateTarget

        public static org.openqa.selenium.devtools.Command<java.lang.Void> activateTarget​(TargetID targetId)
        Activates (focuses) the target.
      • attachToTarget

        public static org.openqa.selenium.devtools.Command<SessionID> attachToTarget​(TargetID targetId,
                                                                                     java.util.Optional<java.lang.Boolean> flatten)
        Attaches to the target with given id.
      • attachToBrowserTarget

        @Beta
        public static org.openqa.selenium.devtools.Command<SessionID> attachToBrowserTarget()
        Attaches to the browser target, only uses flat sessionId mode.
      • closeTarget

        public static org.openqa.selenium.devtools.Command<java.lang.Boolean> closeTarget​(TargetID targetId)
        Closes the target. If the target is a page that gets closed too.
      • exposeDevToolsProtocol

        @Beta
        public static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Command<BrowserContextID> createBrowserContext​(java.util.Optional<java.lang.Boolean> disposeOnDetach,
                                                                                                  java.util.Optional<java.lang.String> proxyServer,
                                                                                                  java.util.Optional<java.lang.String> proxyBypassList)
        Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
      • getBrowserContexts

        @Beta
        public static org.openqa.selenium.devtools.Command<java.util.List<BrowserContextID>> getBrowserContexts()
        Returns all browser contexts created with `Target.createBrowserContext` method.
      • createTarget

        public static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Command<java.lang.Void> detachFromTarget​(java.util.Optional<SessionID> sessionId,
                                                                                            java.util.Optional<TargetID> targetId)
        Detaches session with given id.
      • disposeBrowserContext

        @Beta
        public static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Command<TargetInfo> getTargetInfo​(java.util.Optional<TargetID> targetId)
        Returns information about a target.
      • getTargets

        public static org.openqa.selenium.devtools.Command<java.util.List<TargetInfo>> getTargets()
        Retrieves a list of available targets.
      • sendMessageToTarget

        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> sendMessageToTarget​(java.lang.String message,
                                                                                               java.util.Optional<SessionID> sessionId,
                                                                                               java.util.Optional<TargetID> targetId)
        Deprecated.
        Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.
      • setAutoAttach

        @Beta
        public static org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.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 org.openqa.selenium.devtools.Event<AttachedToTarget> attachedToTarget()
      • detachedFromTarget

        public static org.openqa.selenium.devtools.Event<DetachedFromTarget> detachedFromTarget()
      • receivedMessageFromTarget

        public static org.openqa.selenium.devtools.Event<ReceivedMessageFromTarget> receivedMessageFromTarget()
      • targetCreated

        public static org.openqa.selenium.devtools.Event<TargetInfo> targetCreated()
      • targetDestroyed

        public static org.openqa.selenium.devtools.Event<TargetID> targetDestroyed()
      • targetCrashed

        public static org.openqa.selenium.devtools.Event<TargetCrashed> targetCrashed()
      • targetInfoChanged

        public static org.openqa.selenium.devtools.Event<TargetInfo> targetInfoChanged()