-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsI-enhancementSomething could be betterSomething could be better
Description
Feature and motivation
Currently, IJavascriptEngine has a private DevToolsSession which cannot be disposed of, leaving it open until the end of execution. I would like to be able to dispose this session. I opened #11594 to achieve this.
Usage example
My code currently looks like
public async Task<ReadOnlyCollection<ConsoleLog>> ScanConsoleAsync(System.Action action)
{
var consoleMessages = new List<ConsoleLog>();
var monitor = new JavaScriptEngine(Context.WebDriver);
monitor.JavaScriptConsoleApiCalled += StartMonitoring;
await monitor.StartEventMonitoring();
action.Invoke();
monitor.StopEventMonitoring();
monitor.JavaScriptConsoleApiCalled -= StartMonitoring;
return consoleMessages.AsReadOnly();
void StartMonitoring(object? _, JavaScriptConsoleApiCalledEventArgs e) => consoleMessages.Add(new ConsoleLog(e.MessageType, e.MessageContent, e.MessageTimeStamp));
}
public sealed record ConsoleLog(string Type, string Text, DateTime Timestamp);and this change would simply have me add using to the class's invocation.
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsI-enhancementSomething could be betterSomething could be better