Class TargetAdapter
Represents an adapter for the Target domain to simplify the command interface.
public class TargetAdapter
- Inheritance
-
TargetAdapter
- Inherited Members
Constructors
TargetAdapter(IDevToolsSession)
Initializes a new instance of the TargetAdapter class.
public TargetAdapter(IDevToolsSession session)
Parameters
sessionIDevToolsSessionThe IDevToolsSession to be used with this adapter.
Exceptions
- ArgumentNullException
If
sessionis null.
Properties
Session
Gets the DevToolsSession associated with the adapter.
public IDevToolsSession Session { get; }
Property Value
Methods
ActivateTarget(ActivateTargetCommandSettings, CancellationToken, int?, bool)
Activates (focuses) the target.
public Task<ActivateTargetCommandResponse?> ActivateTarget(ActivateTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandActivateTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
AttachToBrowserTarget(AttachToBrowserTargetCommandSettings?, CancellationToken, int?, bool)
Attaches to the browser target, only uses flat sessionId mode.
public Task<AttachToBrowserTargetCommandResponse> AttachToBrowserTarget(AttachToBrowserTargetCommandSettings? command = null, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandAttachToBrowserTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
AttachToTarget(AttachToTargetCommandSettings, CancellationToken, int?, bool)
Attaches to the target with given id.
public Task<AttachToTargetCommandResponse> AttachToTarget(AttachToTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandAttachToTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
AutoAttachRelated(AutoAttachRelatedCommandSettings, CancellationToken, int?, bool)
Adds the specified target to the list of targets that will be monitored for any related target
creation (such as child frames, child workers and new versions of service worker) and reported
through attachedToTarget. The specified target is also auto-attached.
This cancels the effect of any previous setAutoAttach and is also cancelled by subsequent
setAutoAttach. Only available at the Browser target.
public Task<AutoAttachRelatedCommandResponse?> AutoAttachRelated(AutoAttachRelatedCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandAutoAttachRelatedCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
CloseTarget(CloseTargetCommandSettings, CancellationToken, int?, bool)
Closes the target. If the target is a page that gets closed too.
public Task<CloseTargetCommandResponse> CloseTarget(CloseTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandCloseTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
CreateBrowserContext(CreateBrowserContextCommandSettings, CancellationToken, int?, bool)
Creates a new empty BrowserContext. Similar to an incognito profile but you can have more than one.
public Task<CreateBrowserContextCommandResponse> CreateBrowserContext(CreateBrowserContextCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandCreateBrowserContextCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
CreateTarget(CreateTargetCommandSettings, CancellationToken, int?, bool)
Creates a new page.
public Task<CreateTargetCommandResponse> CreateTarget(CreateTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandCreateTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
DetachFromTarget(DetachFromTargetCommandSettings, CancellationToken, int?, bool)
Detaches session with given id.
public Task<DetachFromTargetCommandResponse?> DetachFromTarget(DetachFromTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandDetachFromTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
DisposeBrowserContext(DisposeBrowserContextCommandSettings, CancellationToken, int?, bool)
Deletes a BrowserContext. All the belonging pages will be closed without calling their beforeunload hooks.
public Task<DisposeBrowserContextCommandResponse?> DisposeBrowserContext(DisposeBrowserContextCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandDisposeBrowserContextCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
ExposeDevToolsProtocol(ExposeDevToolsProtocolCommandSettings, CancellationToken, int?, bool)
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 following API:
binding.send(json)- a method to send messages over the remote debugging protocolbinding.onmessage = json => handleMessage(json)- a callback that will be called for the protocol notifications and command responses.
public Task<ExposeDevToolsProtocolCommandResponse?> ExposeDevToolsProtocol(ExposeDevToolsProtocolCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandExposeDevToolsProtocolCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
GetBrowserContexts(GetBrowserContextsCommandSettings?, CancellationToken, int?, bool)
Returns all browser contexts created with Target.createBrowserContext method.
public Task<GetBrowserContextsCommandResponse> GetBrowserContexts(GetBrowserContextsCommandSettings? command = null, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandGetBrowserContextsCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
GetDevToolsTarget(GetDevToolsTargetCommandSettings, CancellationToken, int?, bool)
Gets the targetId of the DevTools page target opened for the given target (if any).
public Task<GetDevToolsTargetCommandResponse> GetDevToolsTarget(GetDevToolsTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandGetDevToolsTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
GetTargetInfo(GetTargetInfoCommandSettings, CancellationToken, int?, bool)
Returns information about a target.
public Task<GetTargetInfoCommandResponse> GetTargetInfo(GetTargetInfoCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandGetTargetInfoCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
GetTargets(GetTargetsCommandSettings, CancellationToken, int?, bool)
Retrieves a list of available targets.
public Task<GetTargetsCommandResponse> GetTargets(GetTargetsCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandGetTargetsCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
OpenDevTools(OpenDevToolsCommandSettings, CancellationToken, int?, bool)
Opens a DevTools window for the target.
public Task<OpenDevToolsCommandResponse> OpenDevTools(OpenDevToolsCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandOpenDevToolsCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
SendMessageToTarget(SendMessageToTargetCommandSettings, CancellationToken, int?, bool)
Sends protocol message over session with given id. Consider using flat mode instead; see commands attachToTarget, setAutoAttach, and crbug.com/991325.
public Task<SendMessageToTargetCommandResponse?> SendMessageToTarget(SendMessageToTargetCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandSendMessageToTargetCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
SetAutoAttach(SetAutoAttachCommandSettings, CancellationToken, int?, bool)
Controls whether to automatically attach to new targets which are considered
to be directly related to this one (for example, iframes or workers).
When turned on, attaches to all existing related targets as well. When turned off,
automatically detaches from all currently attached targets.
This also clears all targets added by autoAttachRelated from the list of targets to watch
for creation of related targets.
You might want to call this recursively for auto-attached targets to attach
to all available targets.
public Task<SetAutoAttachCommandResponse?> SetAutoAttach(SetAutoAttachCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandSetAutoAttachCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
SetDiscoverTargets(SetDiscoverTargetsCommandSettings, CancellationToken, int?, bool)
Controls whether to discover available targets and notify via
targetCreated/targetInfoChanged/targetDestroyed events.
public Task<SetDiscoverTargetsCommandResponse?> SetDiscoverTargets(SetDiscoverTargetsCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandSetDiscoverTargetsCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
SetRemoteLocations(SetRemoteLocationsCommandSettings, CancellationToken, int?, bool)
Enables target discovery for the specified locations, when setDiscoverTargets was set to
true.
public Task<SetRemoteLocationsCommandResponse?> SetRemoteLocations(SetRemoteLocationsCommandSettings command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandSetRemoteLocationsCommandSettingscancellationTokenCancellationTokenmillisecondsTimeoutint?throwExceptionIfResponseNotReceivedbool
Returns
Events
AttachedToTarget
Issued when attached to target because of auto-attach or attachToTarget command.
public event EventHandler<AttachedToTargetEventArgs>? AttachedToTarget
Event Type
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.
public event EventHandler<DetachedFromTargetEventArgs>? DetachedFromTarget
Event Type
ReceivedMessageFromTarget
Notifies about a new protocol message received from the session (as reported in
attachedToTarget event).
public event EventHandler<ReceivedMessageFromTargetEventArgs>? ReceivedMessageFromTarget
Event Type
TargetCrashed
Issued when a target has crashed.
public event EventHandler<TargetCrashedEventArgs>? TargetCrashed
Event Type
TargetCreated
Issued when a possible inspection target is created.
public event EventHandler<TargetCreatedEventArgs>? TargetCreated
Event Type
TargetDestroyed
Issued when a target is destroyed.
public event EventHandler<TargetDestroyedEventArgs>? TargetDestroyed
Event Type
TargetInfoChanged
Issued when some information about a target has changed. This only happens between
targetCreated and targetDestroyed.
public event EventHandler<TargetInfoChangedEventArgs>? TargetInfoChanged