Skip to content

Commit

Permalink
[dotnet] Add ability to disconnect a CDP session
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Sep 21, 2021
1 parent 301132d commit 2b67ece
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dotnet/src/webdriver/Chromium/ChromiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
return this.devToolsSession;
}

public void TerminateDevToolsSession()
{
if (this.devToolsSession != null)
{
this.devToolsSession.Dispose();
this.devToolsSession = null;
}
}

protected override void Dispose(bool disposing)
{
if (disposing)
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/DevTools/IDevTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ public interface IDevTools
/// <param name="protocolVersion">The specific version of the Developer Tools debugging protocol to use.</param>
/// <returns>The active session to use to communicate with the Developer Tools debugging protocol.</returns>
DevToolsSession GetDevToolsSession(int protocolVersion);

void TerminateDevToolsSession();
}
}
9 changes: 9 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ public DevToolsSession GetDevToolsSession(int devToolsProtocolVersion)
return this.devToolsSession;
}

public void TerminateDevToolsSession()
{
if (this.devToolsSession != null)
{
this.devToolsSession.Dispose();
this.devToolsSession = null;
}
}

/// <summary>
/// In derived classes, the <see cref="PrepareEnvironment"/> method prepares the environment for test execution.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions dotnet/src/webdriver/Remote/RemoteWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ public DevToolsSession GetDevToolsSession(int protocolVersion)
return this.devToolsSession;
}

public void TerminateDevToolsSession()
{
if (this.devToolsSession != null)
{
this.devToolsSession.Dispose();
this.devToolsSession = null;
}
}

private static ICapabilities ConvertOptionsToCapabilities(DriverOptions options)
{
if (options == null)
Expand Down

0 comments on commit 2b67ece

Please sign in to comment.