blob: 37698630bb94d0c66cdfc95f2d1860c6d1864859 [file] [log] [blame] [edit]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Class DevToolsSession </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Class DevToolsSession ">
<meta name="description" content="Represents a WebSocket connection to a running DevTools instance that can be used to send commands and receive events.">
<link rel="icon" href="../images/favicon.ico">
<link rel="stylesheet" href="../public/docfx.min.css">
<link rel="stylesheet" href="../public/main.css">
<meta name="docfx:navrel" content="../toc.html">
<meta name="docfx:tocrel" content="toc.html">
<meta name="docfx:rel" content="../">
<meta name="docfx:docurl" content="https://github.com/SeleniumHQ/selenium/new/trunk/apiSpec/new?filename=OpenQA_Selenium_DevTools_DevToolsSession.md&amp;value=---%0Auid%3A%20OpenQA.Selenium.DevTools.DevToolsSession%0Asummary%3A%20&#39;*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax&#39;%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">
<meta name="loc:inThisArticle" content="In this article">
<meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<meta name="loc:tocFilter" content="Filter by title">
<meta name="loc:nextArticle" content="Next">
<meta name="loc:prevArticle" content="Previous">
<meta name="loc:themeLight" content="Light">
<meta name="loc:themeDark" content="Dark">
<meta name="loc:themeAuto" content="Auto">
<meta name="loc:changeTheme" content="Change theme">
<meta name="loc:copy" content="Copy">
<meta name="loc:downloadPdf" content="Download PDF">
<script type="module" src="./../public/docfx.min.js"></script>
<script>
const theme = localStorage.getItem('theme') || 'auto'
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
</script>
</head>
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../images/logo.svg" alt="Selenium .NET API">
Selenium .NET API
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
</form>
</div>
</div>
</div>
</nav>
</header>
<main class="container-xxl">
<div class="toc-offcanvas">
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<nav class="toc" id="toc"></nav>
</div>
</div>
</div>
<div class="content">
<div class="actionbar">
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
<i class="bi bi-list"></i>
</button>
<nav id="breadcrumb"></nav>
</div>
<article data-uid="OpenQA.Selenium.DevTools.DevToolsSession">
<h1 id="OpenQA_Selenium_DevTools_DevToolsSession" data-uid="OpenQA.Selenium.DevTools.DevToolsSession" class="text-break">
Class DevToolsSession <a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L37"><i class="bi bi-code-slash"></i></a>
</h1>
<div class="facts text-secondary">
<dl><dt>Namespace</dt><dd><a class="xref" href="OpenQA.html">OpenQA</a>.<a class="xref" href="OpenQA.Selenium.html">Selenium</a>.<a class="xref" href="OpenQA.Selenium.DevTools.html">DevTools</a></dd></dl>
<dl><dt>Assembly</dt><dd>WebDriver.dll</dd></dl>
</div>
<div class="markdown summary"><p>Represents a WebSocket connection to a running DevTools instance that can be used to send
commands and receive events.</p>
</div>
<div class="markdown conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public class DevToolsSession : IDevToolsSession, IDisposable</code></pre>
</div>
<dl class="typelist inheritance">
<dt>Inheritance</dt>
<dd>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
<div><span class="xref">DevToolsSession</span></div>
</dd>
</dl>
<dl class="typelist implements">
<dt>Implements</dt>
<dd>
<div><a class="xref" href="OpenQA.Selenium.DevTools.IDevToolsSession.html">IDevToolsSession</a></div>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></div>
</dd>
</dl>
<dl class="typelist inheritedMembers">
<dt>Inherited Members</dt>
<dd>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
</div>
</dd></dl>
<h2 class="section" id="constructors">Constructors
</h2>
<a id="OpenQA_Selenium_DevTools_DevToolsSession__ctor_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.#ctor*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession__ctor_System_String_OpenQA_Selenium_DevTools_DevToolsOptions_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.#ctor(System.String,OpenQA.Selenium.DevTools.DevToolsOptions)">
DevToolsSession(string, DevToolsOptions)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L71"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Initializes a new instance of the DevToolsSession class, using the specified WebSocket endpoint and specified DevTools options.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DevToolsSession(string endpointAddress, DevToolsOptions options)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>endpointAddress</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd></dd>
<dt><code>options</code> <a class="xref" href="OpenQA.Selenium.DevTools.DevToolsOptions.html">DevToolsOptions</a></dt>
<dd></dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></dt>
<dd><p>If <code class="paramref">options</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>, or <code class="paramref">endpointAddress</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a> or <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string.empty">Empty</a>.</p>
</dd>
</dl>
<h2 class="section" id="fields">Fields
</h2>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_AutoDetectDevToolsProtocolVersion" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.AutoDetectDevToolsProtocolVersion">
AutoDetectDevToolsProtocolVersion
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L47"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>A value indicating that the version of the DevTools protocol in use
by the browser should be automatically detected.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public const int AutoDetectDevToolsProtocolVersion = 0</code></pre>
</div>
<h4 class="section">Field Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
<dd></dd>
</dl>
<h2 class="section" id="properties">Properties
</h2>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_ActiveSessionId_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.ActiveSessionId*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_ActiveSessionId" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.ActiveSessionId">
ActiveSessionId
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L106"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Gets or sets the active session ID of the connection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public string? ActiveSessionId { get; }</code></pre>
</div>
<h4 class="section">Property Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd></dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_CommandTimeout_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.CommandTimeout*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_CommandTimeout" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.CommandTimeout">
CommandTimeout
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L101"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Gets or sets the time to wait for a command to complete. Default is 30 seconds.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TimeSpan CommandTimeout { get; set; }</code></pre>
</div>
<h4 class="section">Property Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.timespan">TimeSpan</a></dt>
<dd></dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_Domains_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Domains*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_Domains" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Domains">
Domains
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L116"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Gets the version-independent domain implementation for this Developer Tools connection</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DevToolsDomains Domains { get; }</code></pre>
</div>
<h4 class="section">Property Value</h4>
<dl class="parameters">
<dt><a class="xref" href="OpenQA.Selenium.DevTools.DevToolsDomains.html">DevToolsDomains</a></dt>
<dd></dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_EndpointAddress_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.EndpointAddress*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_EndpointAddress" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.EndpointAddress">
EndpointAddress
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L111"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Gets the endpoint address of the session.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public string? EndpointAddress { get; }</code></pre>
</div>
<h4 class="section">Property Value</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd></dd>
</dl>
<h2 class="section" id="methods">Methods
</h2>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_Dispose_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Dispose*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_Dispose" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Dispose">
Dispose()
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L328"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Releases all resources associated with this <a class="xref" href="OpenQA.Selenium.DevTools.DevToolsSession.html">DevToolsSession</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Dispose()</code></pre>
</div>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_Dispose_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Dispose*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_Dispose_System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.Dispose(System.Boolean)">
Dispose(bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L384"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Releases all resources associated with this <a class="xref" href="OpenQA.Selenium.DevTools.DevToolsSession.html">DevToolsSession</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected void Dispose(bool disposing)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>disposing</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> if the Dispose method was explicitly called; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_GetVersionSpecificDomains_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.GetVersionSpecificDomains*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_GetVersionSpecificDomains__1" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.GetVersionSpecificDomains``1">
GetVersionSpecificDomains&lt;T&gt;()
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L125"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Gets the version-specific implementation of domains for this DevTools session.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public T GetVersionSpecificDomains&lt;T&gt;() where T : DevToolsSessionDomains</code></pre>
</div>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><span class="xref">T</span></dt>
<dd><p>The version-specific DevTools Protocol domain implementation.</p>
</dd>
</dl>
<h4 class="section">Type Parameters</h4>
<dl class="parameters">
<dt><code>T</code></dt>
<dd><p>A <a class="xref" href="OpenQA.Selenium.DevTools.DevToolsSessionDomains.html">DevToolsSessionDomains</a> object containing the version-specific DevTools Protocol domain implementations.</p>
</dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.invalidoperationexception">InvalidOperationException</a></dt>
<dd><p>If the provided <code class="typeparamref">T</code> is not the right protocol version which is running.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_System_String_System_String_System_Text_Json_Nodes_JsonNode_System_Threading_CancellationToken_System_Nullable_System_Int32__System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand(System.String,System.String,System.Text.Json.Nodes.JsonNode,System.Threading.CancellationToken,System.Nullable{System.Int32},System.Boolean)">
SendCommand(string, string?, JsonNode, CancellationToken, int?, bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L268"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Returns a JsonNode based on a command created with the specified command name and params.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Task&lt;JsonElement?&gt; SendCommand(string commandName, string? sessionId, JsonNode commandParameters, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>commandName</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The name of the command to send.</p>
</dd>
<dt><code>sessionId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The sessionId of the command.</p>
</dd>
<dt><code>commandParameters</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonnode">JsonNode</a></dt>
<dd><p>The parameters of the command as a JsonNode object</p>
</dd>
<dt><code>cancellationToken</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></dt>
<dd><p>A CancellationToken object to allow for cancellation of the command.</p>
</dd>
<dt><code>millisecondsTimeout</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd><p>The execution timeout of the command in milliseconds.</p>
</dd>
<dt><code>throwExceptionIfResponseNotReceived</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> to throw an exception if a response is not received; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.jsonelement">JsonElement</a>?&gt;</dt>
<dd><p>The command response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse&lt;T&gt;</a> interface.</p>
</dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></dt>
<dd><p>If <code class="paramref">commandName</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_System_String_System_Text_Json_Nodes_JsonNode_System_Threading_CancellationToken_System_Nullable_System_Int32__System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand(System.String,System.Text.Json.Nodes.JsonNode,System.Threading.CancellationToken,System.Nullable{System.Int32},System.Boolean)">
SendCommand(string, JsonNode, CancellationToken, int?, bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L246"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Returns a JsonNode based on a command created with the specified command name and params.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Task&lt;JsonElement?&gt; SendCommand(string commandName, JsonNode commandParameters, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>commandName</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The name of the command to send.</p>
</dd>
<dt><code>commandParameters</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.nodes.jsonnode">JsonNode</a></dt>
<dd><p>The parameters of the command as a JsonNode object</p>
</dd>
<dt><code>cancellationToken</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></dt>
<dd><p>A CancellationToken object to allow for cancellation of the command.</p>
</dd>
<dt><code>millisecondsTimeout</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd><p>The execution timeout of the command in milliseconds.</p>
</dd>
<dt><code>throwExceptionIfResponseNotReceived</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> to throw an exception if a response is not received; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.json.jsonelement">JsonElement</a>?&gt;</dt>
<dd><p>The command response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse&lt;T&gt;</a> interface.</p>
</dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></dt>
<dd><p>If <code class="paramref">commandName</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand__1___0_System_String_System_Threading_CancellationToken_System_Nullable_System_Int32__System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand``1(``0,System.String,System.Threading.CancellationToken,System.Nullable{System.Int32},System.Boolean)">
SendCommand&lt;TCommand&gt;(TCommand, string, CancellationToken, int?, bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L181"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Sends the specified command and returns the associated command response.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Task&lt;ICommandResponse&lt;TCommand&gt;?&gt; SendCommand&lt;TCommand&gt;(TCommand command, string sessionId, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>command</code> <span class="xref">TCommand</span></dt>
<dd><p>The command to be sent.</p>
</dd>
<dt><code>sessionId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The target session of the command</p>
</dd>
<dt><code>cancellationToken</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></dt>
<dd><p>A CancellationToken object to allow for cancellation of the command.</p>
</dd>
<dt><code>millisecondsTimeout</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd><p>The execution timeout of the command in milliseconds.</p>
</dd>
<dt><code>throwExceptionIfResponseNotReceived</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> to throw an exception if a response is not received; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;<a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse</a>&lt;TCommand&gt;&gt;</dt>
<dd><p>The command response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse&lt;T&gt;</a> interface.</p>
</dd>
</dl>
<h4 class="section">Type Parameters</h4>
<dl class="parameters">
<dt><code>TCommand</code></dt>
<dd><p>A command object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommand.html">ICommand</a> interface.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand__1___0_System_Threading_CancellationToken_System_Nullable_System_Int32__System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand``1(``0,System.Threading.CancellationToken,System.Nullable{System.Int32},System.Boolean)">
SendCommand&lt;TCommand&gt;(TCommand, CancellationToken, int?, bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L147"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Sends the specified command and returns the associated command response.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Task&lt;ICommandResponse&lt;TCommand&gt;?&gt; SendCommand&lt;TCommand&gt;(TCommand command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>command</code> <span class="xref">TCommand</span></dt>
<dd><p>The command to be sent.</p>
</dd>
<dt><code>cancellationToken</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></dt>
<dd><p>A CancellationToken object to allow for cancellation of the command.</p>
</dd>
<dt><code>millisecondsTimeout</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd><p>The execution timeout of the command in milliseconds.</p>
</dd>
<dt><code>throwExceptionIfResponseNotReceived</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> to throw an exception if a response is not received; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;<a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse</a>&lt;TCommand&gt;&gt;</dt>
<dd><p>The command response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse&lt;T&gt;</a> interface.</p>
</dd>
</dl>
<h4 class="section">Type Parameters</h4>
<dl class="parameters">
<dt><code>TCommand</code></dt>
<dd><p>A command object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommand.html">ICommand</a> interface.</p>
</dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></dt>
<dd><p>If <code class="paramref">command</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>.</p>
</dd>
</dl>
<a id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand*"></a>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_SendCommand__2___0_System_Threading_CancellationToken_System_Nullable_System_Int32__System_Boolean_" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.SendCommand``2(``0,System.Threading.CancellationToken,System.Nullable{System.Int32},System.Boolean)">
SendCommand&lt;TCommand, TCommandResponse&gt;(TCommand, CancellationToken, int?, bool)
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L216"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Sends the specified command and returns the associated command response.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public Task&lt;TCommandResponse?&gt; SendCommand&lt;TCommand, TCommandResponse&gt;(TCommand command, CancellationToken cancellationToken = default, int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) where TCommand : ICommand where TCommandResponse : ICommandResponse&lt;TCommand&gt;</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>command</code> <span class="xref">TCommand</span></dt>
<dd><p>The command to send.</p>
</dd>
<dt><code>cancellationToken</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken">CancellationToken</a></dt>
<dd><p>A CancellationToken object to allow for cancellation of the command.</p>
</dd>
<dt><code>millisecondsTimeout</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>?</dt>
<dd><p>The execution timeout of the command in milliseconds.</p>
</dd>
<dt><code>throwExceptionIfResponseNotReceived</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
<dd><p><a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">true</a> to throw an exception if a response is not received; otherwise, <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool">false</a>.</p>
</dd>
</dl>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a>&lt;TCommandResponse&gt;</dt>
<dd><p>The command response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse-1.html">ICommandResponse&lt;T&gt;</a> interface.</p>
</dd>
</dl>
<h4 class="section">Type Parameters</h4>
<dl class="parameters">
<dt><code>TCommand</code></dt>
<dd><p>A command object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommand.html">ICommand</a> interface.</p>
</dd>
<dt><code>TCommandResponse</code></dt>
<dd><p>A response object implementing the <a class="xref" href="OpenQA.Selenium.DevTools.ICommandResponse.html">ICommandResponse</a> interface.</p>
</dd>
</dl>
<h4 class="section">Exceptions</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></dt>
<dd><p>If <code class="paramref">command</code> is <a href="https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null">null</a>.</p>
</dd>
</dl>
<h2 class="section" id="events">Events
</h2>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_DevToolsEventReceived" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.DevToolsEventReceived">
DevToolsEventReceived
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L96"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Event raised an event notification is received from the DevTools session.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public event EventHandler&lt;DevToolsEventReceivedEventArgs&gt;? DevToolsEventReceived</code></pre>
</div>
<h4 class="section">Event Type</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.eventhandler-1">EventHandler</a>&lt;<a class="xref" href="OpenQA.Selenium.DevTools.DevToolsEventReceivedEventArgs.html">DevToolsEventReceivedEventArgs</a>&gt;</dt>
<dd></dd>
</dl>
<h3 id="OpenQA_Selenium_DevTools_DevToolsSession_LogMessage" data-uid="OpenQA.Selenium.DevTools.DevToolsSession.LogMessage">
LogMessage
<a class="header-action link-secondary" title="View source" href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L91"><i class="bi bi-code-slash"></i></a>
</h3>
<div class="markdown level1 summary"><p>Event raised when the DevToolsSession logs informational messages.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public event EventHandler&lt;DevToolsSessionLogMessageEventArgs&gt;? LogMessage</code></pre>
</div>
<h4 class="section">Event Type</h4>
<dl class="parameters">
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.eventhandler-1">EventHandler</a>&lt;<a class="xref" href="OpenQA.Selenium.DevTools.DevToolsSessionLogMessageEventArgs.html">DevToolsSessionLogMessageEventArgs</a>&gt;</dt>
<dd></dd>
</dl>
</article>
<div class="contribution d-print-none">
<a href="https://github.com/SeleniumHQ/selenium/blob/trunk/dotnet/src/webdriver/DevTools/DevToolsSession.cs/#L37" class="edit-link">Edit this page</a>
</div>
</div>
<div class="affix">
<nav id="affix"></nav>
</div>
</main>
<div class="container-xxl search-results" id="search-results"></div>
<footer class="border-top text-secondary">
<div class="container-xxl">
<div class="flex-fill">
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
</div>
</div>
</footer>
</body>
</html>