Class DevToolsSession
Represents a WebSocket connection to a running DevTools instance that can be used to send commands and recieve events.
public class DevToolsSession : IDevToolsSession, IDisposable
- Inheritance
-
DevToolsSession
- Implements
- Inherited Members
Constructors
DevToolsSession(string)
Initializes a new instance of the DevToolsSession class, using the specified WebSocket endpoint.
[Obsolete("Use DevToolsSession(string endpointAddress, DevToolsOptions options)")]
public DevToolsSession(string endpointAddress)
Parameters
endpointAddress
string
DevToolsSession(string, DevToolsOptions)
Initializes a new instance of the DevToolsSession class, using the specified WebSocket endpoint and specified DevTools options.
public DevToolsSession(string endpointAddress, DevToolsOptions options)
Parameters
endpointAddress
stringoptions
DevToolsOptions
Exceptions
Fields
AutoDetectDevToolsProtocolVersion
A value indicating that the version of the DevTools protocol in use by the browser should be automatically detected.
public const int AutoDetectDevToolsProtocolVersion = 0
Field Value
Properties
ActiveSessionId
Gets or sets the active session ID of the connection.
public string ActiveSessionId { get; }
Property Value
CommandTimeout
Gets or sets the time to wait for a command to complete. Default is 30 seconds.
public TimeSpan CommandTimeout { get; set; }
Property Value
Domains
Gets the version-independent domain implementation for this Developer Tools connection
public DevToolsDomains Domains { get; }
Property Value
EndpointAddress
Gets the endpoint address of the session.
public string EndpointAddress { get; }
Property Value
Methods
Dispose()
Releases all resources associated with this DevToolsSession.
public void Dispose()
Dispose(bool)
Releases all resources associated with this DevToolsSession.
protected void Dispose(bool disposing)
Parameters
GetVersionSpecificDomains<T>()
Gets the version-specific implementation of domains for this DevTools session.
public T GetVersionSpecificDomains<T>() where T : DevToolsSessionDomains
Returns
- T
The version-specific DevTools Protocol domain implementation.
Type Parameters
T
A DevToolsSessionDomains object containing the version-specific DevTools Protocol domain implementations.
SendCommand(string, string, JsonNode, CancellationToken, int?, bool)
Returns a JsonNode based on a command created with the specified command name and params.
public Task<JsonElement?> SendCommand(string commandName, string sessionId, JsonNode commandParameters, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandName
stringThe name of the command to send.
sessionId
stringThe sessionId of the command.
commandParameters
JsonNodeThe parameters of the command as a JsonNode object
cancellationToken
CancellationTokenA CancellationToken object to allow for cancellation of the command.
millisecondsTimeout
int?The execution timeout of the command in milliseconds.
throwExceptionIfResponseNotReceived
booltrue to throw an exception if a response is not received; otherwise, false.
Returns
- Task<JsonElement?>
The command response object implementing the ICommandResponse<T> interface.
SendCommand(string, JsonNode, CancellationToken, int?, bool)
Returns a JsonNode based on a command created with the specified command name and params.
public Task<JsonElement?> SendCommand(string commandName, JsonNode commandParameters, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)
Parameters
commandName
stringThe name of the command to send.
commandParameters
JsonNodeThe parameters of the command as a JsonNode object
cancellationToken
CancellationTokenA CancellationToken object to allow for cancellation of the command.
millisecondsTimeout
int?The execution timeout of the command in milliseconds.
throwExceptionIfResponseNotReceived
booltrue to throw an exception if a response is not received; otherwise, false.
Returns
- Task<JsonElement?>
The command response object implementing the ICommandResponse<T> interface.
SendCommand<TCommand>(TCommand, string, CancellationToken, int?, bool)
Sends the specified command and returns the associated command response.
public Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, string sessionId, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand
Parameters
command
TCommandThe command to be sent.
sessionId
stringThe target session of the command
cancellationToken
CancellationTokenA CancellationToken object to allow for cancellation of the command.
millisecondsTimeout
int?The execution timeout of the command in milliseconds.
throwExceptionIfResponseNotReceived
booltrue to throw an exception if a response is not received; otherwise, false.
Returns
- Task<ICommandResponse<TCommand>>
The command response object implementing the ICommandResponse<T> interface.
Type Parameters
TCommand
A command object implementing the ICommand interface.
SendCommand<TCommand>(TCommand, CancellationToken, int?, bool)
Sends the specified command and returns the associated command response.
public Task<ICommandResponse<TCommand>> SendCommand<TCommand>(TCommand command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand
Parameters
command
TCommandThe command to be sent.
cancellationToken
CancellationTokenA CancellationToken object to allow for cancellation of the command.
millisecondsTimeout
int?The execution timeout of the command in milliseconds.
throwExceptionIfResponseNotReceived
booltrue to throw an exception if a response is not received; otherwise, false.
Returns
- Task<ICommandResponse<TCommand>>
The command response object implementing the ICommandResponse<T> interface.
Type Parameters
TCommand
A command object implementing the ICommand interface.
SendCommand<TCommand, TCommandResponse>(TCommand, CancellationToken, int?, bool)
Sends the specified command and returns the associated command response.
public Task<TCommandResponse> SendCommand<TCommand, TCommandResponse>(TCommand command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand where TCommandResponse : ICommandResponse<TCommand>
Parameters
command
TCommandThe command to send.
cancellationToken
CancellationTokenA CancellationToken object to allow for cancellation of the command.
millisecondsTimeout
int?The execution timeout of the command in milliseconds.
throwExceptionIfResponseNotReceived
booltrue to throw an exception if a response is not received; otherwise, false.
Returns
- Task<TCommandResponse>
The command response object implementing the ICommandResponse<T> interface.
Type Parameters
TCommand
A command object implementing the ICommand interface.
TCommandResponse
A response object implementing the ICommandResponse interface.
Events
DevToolsEventReceived
Event raised an event notification is received from the DevTools session.
public event EventHandler<DevToolsEventReceivedEventArgs> DevToolsEventReceived
Event Type
LogMessage
Event raised when the DevToolsSession logs informational messages.
public event EventHandler<DevToolsSessionLogMessageEventArgs> LogMessage