Skip to content

Commit 2b67ece

Browse files
committed
[dotnet] Add ability to disconnect a CDP session
1 parent 301132d commit 2b67ece

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

dotnet/src/webdriver/Chromium/ChromiumDriver.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
216216
return this.devToolsSession;
217217
}
218218

219+
public void TerminateDevToolsSession()
220+
{
221+
if (this.devToolsSession != null)
222+
{
223+
this.devToolsSession.Dispose();
224+
this.devToolsSession = null;
225+
}
226+
}
227+
219228
protected override void Dispose(bool disposing)
220229
{
221230
if (disposing)

dotnet/src/webdriver/DevTools/IDevTools.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public interface IDevTools
3535
/// <param name="protocolVersion">The specific version of the Developer Tools debugging protocol to use.</param>
3636
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
3737
DevToolsSession GetDevToolsSession(int protocolVersion);
38+
39+
void TerminateDevToolsSession();
3840
}
3941
}

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
300300
return this.devToolsSession;
301301
}
302302

303+
public void TerminateDevToolsSession()
304+
{
305+
if (this.devToolsSession != null)
306+
{
307+
this.devToolsSession.Dispose();
308+
this.devToolsSession = null;
309+
}
310+
}
311+
303312
/// <summary>
304313
/// In derived classes, the <see cref="PrepareEnvironment"/> method prepares the environment for test execution.
305314
/// </summary>

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,15 @@ public DevToolsSession GetDevToolsSession(int protocolVersion)
444444
return this.devToolsSession;
445445
}
446446

447+
public void TerminateDevToolsSession()
448+
{
449+
if (this.devToolsSession != null)
450+
{
451+
this.devToolsSession.Dispose();
452+
this.devToolsSession = null;
453+
}
454+
}
455+
447456
private static ICapabilities ConvertOptionsToCapabilities(DriverOptions options)
448457
{
449458
if (options == null)

0 commit comments

Comments
 (0)