diff --git a/dotnet/src/webdriver/BiDi/Communication/Broker.cs b/dotnet/src/webdriver/BiDi/Communication/Broker.cs index 8a6466c9f17e4..f249631cf5ce2 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Broker.cs @@ -41,7 +41,7 @@ public class Broker : IAsyncDisposable private readonly BiDi _bidi; private readonly ITransport _transport; - private readonly ConcurrentDictionary> _pendingCommands = new(); + private readonly ConcurrentDictionary> _pendingCommands = new(); private readonly BlockingCollection _pendingEvents = []; private readonly ConcurrentDictionary> _eventHandlers = new(); @@ -176,23 +176,26 @@ private async Task ProcessEventsAwaiterAsync() } } - public async Task ExecuteCommandAsync(Command command, CommandOptions? options) + public async Task ExecuteCommandAsync(TCommand command, CommandOptions? options) + where TCommand: Command { - var result = await ExecuteCommandCoreAsync(command, options).ConfigureAwait(false); + var jsonElement = await ExecuteCommandCoreAsync(command, options).ConfigureAwait(false); - return (TResult)((JsonElement)result).Deserialize(typeof(TResult), _jsonSerializerContext)!; + return (TResult)jsonElement.Deserialize(typeof(TResult), _jsonSerializerContext)!; } - public async Task ExecuteCommandAsync(Command command, CommandOptions? options) + public async Task ExecuteCommandAsync(TCommand command, CommandOptions? options) + where TCommand: Command { await ExecuteCommandCoreAsync(command, options).ConfigureAwait(false); } - private async Task ExecuteCommandCoreAsync(Command command, CommandOptions? options) + private async Task ExecuteCommandCoreAsync(TCommand command, CommandOptions? options) + where TCommand: Command { command.Id = Interlocked.Increment(ref _currentCommandId); - var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var timeout = options?.Timeout ?? TimeSpan.FromSeconds(30); diff --git a/dotnet/src/webdriver/BiDi/Communication/Command.cs b/dotnet/src/webdriver/BiDi/Communication/Command.cs index 782992d513fe8..a2be1ab37849c 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Command.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Command.cs @@ -17,67 +17,23 @@ // under the License. // -using System.Text.Json.Serialization; - #nullable enable namespace OpenQA.Selenium.BiDi.Communication; -[JsonPolymorphic(TypeDiscriminatorPropertyName = "method")] - -[JsonDerivedType(typeof(Modules.Session.StatusCommand), "session.status")] -[JsonDerivedType(typeof(Modules.Session.SubscribeCommand), "session.subscribe")] -[JsonDerivedType(typeof(Modules.Session.UnsubscribeCommand), "session.unsubscribe")] -[JsonDerivedType(typeof(Modules.Session.NewCommand), "session.new")] -[JsonDerivedType(typeof(Modules.Session.EndCommand), "session.end")] - -[JsonDerivedType(typeof(Modules.Browser.CreateUserContextCommand), "browser.createUserContext")] -[JsonDerivedType(typeof(Modules.Browser.GetUserContextsCommand), "browser.getUserContexts")] -[JsonDerivedType(typeof(Modules.Browser.RemoveUserContextCommand), "browser.removeUserContext")] -[JsonDerivedType(typeof(Modules.Browser.CloseCommand), "browser.close")] - -[JsonDerivedType(typeof(Modules.BrowsingContext.CreateCommand), "browsingContext.create")] -[JsonDerivedType(typeof(Modules.BrowsingContext.NavigateCommand), "browsingContext.navigate")] -[JsonDerivedType(typeof(Modules.BrowsingContext.ReloadCommand), "browsingContext.reload")] -[JsonDerivedType(typeof(Modules.BrowsingContext.TraverseHistoryCommand), "browsingContext.traverseHistory")] -[JsonDerivedType(typeof(Modules.BrowsingContext.LocateNodesCommand), "browsingContext.locateNodes")] -[JsonDerivedType(typeof(Modules.BrowsingContext.ActivateCommand), "browsingContext.activate")] -[JsonDerivedType(typeof(Modules.BrowsingContext.CaptureScreenshotCommand), "browsingContext.captureScreenshot")] -[JsonDerivedType(typeof(Modules.BrowsingContext.SetViewportCommand), "browsingContext.setViewport")] -[JsonDerivedType(typeof(Modules.BrowsingContext.GetTreeCommand), "browsingContext.getTree")] -[JsonDerivedType(typeof(Modules.BrowsingContext.PrintCommand), "browsingContext.print")] -[JsonDerivedType(typeof(Modules.BrowsingContext.HandleUserPromptCommand), "browsingContext.handleUserPrompt")] -[JsonDerivedType(typeof(Modules.BrowsingContext.CloseCommand), "browsingContext.close")] - -[JsonDerivedType(typeof(Modules.Network.AddInterceptCommand), "network.addIntercept")] -[JsonDerivedType(typeof(Modules.Network.ContinueRequestCommand), "network.continueRequest")] -[JsonDerivedType(typeof(Modules.Network.ContinueResponseCommand), "network.continueResponse")] -[JsonDerivedType(typeof(Modules.Network.FailRequestCommand), "network.failRequest")] -[JsonDerivedType(typeof(Modules.Network.ProvideResponseCommand), "network.provideResponse")] -[JsonDerivedType(typeof(Modules.Network.ContinueWithAuthCommand), "network.continueWithAuth")] -[JsonDerivedType(typeof(Modules.Network.RemoveInterceptCommand), "network.removeIntercept")] -[JsonDerivedType(typeof(Modules.Network.SetCacheBehaviorCommand), "network.setCacheBehavior")] - -[JsonDerivedType(typeof(Modules.Script.AddPreloadScriptCommand), "script.addPreloadScript")] -[JsonDerivedType(typeof(Modules.Script.RemovePreloadScriptCommand), "script.removePreloadScript")] -[JsonDerivedType(typeof(Modules.Script.EvaluateCommand), "script.evaluate")] -[JsonDerivedType(typeof(Modules.Script.CallFunctionCommand), "script.callFunction")] -[JsonDerivedType(typeof(Modules.Script.DisownCommand), "script.disown")] -[JsonDerivedType(typeof(Modules.Script.GetRealmsCommand), "script.getRealms")] - -[JsonDerivedType(typeof(Modules.Input.PerformActionsCommand), "input.performActions")] -[JsonDerivedType(typeof(Modules.Input.ReleaseActionsCommand), "input.releaseActions")] - -[JsonDerivedType(typeof(Modules.Storage.GetCookiesCommand), "storage.getCookies")] -[JsonDerivedType(typeof(Modules.Storage.DeleteCookiesCommand), "storage.deleteCookies")] -[JsonDerivedType(typeof(Modules.Storage.SetCookieCommand), "storage.setCookie")] - public abstract class Command { + protected Command(string method) + { + Method = method; + } + + public string Method { get; } + public int Id { get; internal set; } } -internal abstract class Command(TCommandParameters @params) : Command +internal abstract class Command(TCommandParameters @params, string method) : Command(method) where TCommandParameters : CommandParameters { public TCommandParameters Params { get; } = @params; diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 8d55b8c89c0c6..6da7e08a01a84 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -73,23 +73,45 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Command))] [JsonSerializable(typeof(Message))] +[JsonSerializable(typeof(Modules.Session.StatusCommand))] [JsonSerializable(typeof(Modules.Session.StatusResult))] +[JsonSerializable(typeof(Modules.Session.NewCommand))] [JsonSerializable(typeof(Modules.Session.NewResult))] +[JsonSerializable(typeof(Modules.Session.EndCommand))] +[JsonSerializable(typeof(Modules.Session.SubscribeCommand))] +[JsonSerializable(typeof(Modules.Session.UnsubscribeCommand))] [JsonSerializable(typeof(Modules.Browser.CloseCommand), TypeInfoPropertyName = "Browser_CloseCommand")] +[JsonSerializable(typeof(Modules.Browser.CreateUserContextCommand))] +[JsonSerializable(typeof(Modules.Browser.GetUserContextsCommand))] [JsonSerializable(typeof(Modules.Browser.GetUserContextsResult))] +[JsonSerializable(typeof(Modules.Browser.RemoveUserContextCommand))] +[JsonSerializable(typeof(Modules.Browser.UserContextInfo))] [JsonSerializable(typeof(IReadOnlyList))] + +[JsonSerializable(typeof(Modules.BrowsingContext.ActivateCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.CaptureScreenshotCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.CaptureScreenshotResult))] [JsonSerializable(typeof(Modules.BrowsingContext.CloseCommand), TypeInfoPropertyName = "BrowsingContext_CloseCommand")] +[JsonSerializable(typeof(Modules.BrowsingContext.CreateCommand))] [JsonSerializable(typeof(Modules.BrowsingContext.CreateResult))] -[JsonSerializable(typeof(Modules.BrowsingContext.BrowsingContextInfo))] -[JsonSerializable(typeof(Modules.BrowsingContext.NavigateResult))] -[JsonSerializable(typeof(Modules.BrowsingContext.NavigationInfo))] -[JsonSerializable(typeof(Modules.BrowsingContext.TraverseHistoryResult))] -[JsonSerializable(typeof(Modules.BrowsingContext.LocateNodesResult))] -[JsonSerializable(typeof(Modules.BrowsingContext.CaptureScreenshotResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.GetTreeCommand))] [JsonSerializable(typeof(Modules.BrowsingContext.GetTreeResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.HandleUserPromptCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.LocateNodesCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.LocateNodesResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.NavigateCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.NavigateResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.PrintCommand))] [JsonSerializable(typeof(Modules.BrowsingContext.PrintResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.ReloadCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.SetViewportCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.TraverseHistoryCommand))] +[JsonSerializable(typeof(Modules.BrowsingContext.TraverseHistoryResult))] +[JsonSerializable(typeof(Modules.BrowsingContext.BrowsingContextInfo))] +[JsonSerializable(typeof(Modules.BrowsingContext.NavigationInfo))] + [JsonSerializable(typeof(Modules.BrowsingContext.UserPromptOpenedEventArgs))] [JsonSerializable(typeof(Modules.BrowsingContext.UserPromptClosedEventArgs))] [JsonSerializable(typeof(Modules.BrowsingContext.Origin), TypeInfoPropertyName = "BrowsingContext_Origin")] @@ -97,7 +119,16 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.Network.BytesValue.String), TypeInfoPropertyName = "Network_BytesValue_String")] [JsonSerializable(typeof(Modules.Network.UrlPattern.String), TypeInfoPropertyName = "Network_UrlPattern_String")] [JsonSerializable(typeof(Modules.Network.ContinueWithAuthParameters.Default), TypeInfoPropertyName = "Network_ContinueWithAuthParameters_Default")] +[JsonSerializable(typeof(Modules.Network.AddInterceptCommand))] [JsonSerializable(typeof(Modules.Network.AddInterceptResult))] +[JsonSerializable(typeof(Modules.Network.ContinueRequestCommand))] +[JsonSerializable(typeof(Modules.Network.ContinueResponseCommand))] +[JsonSerializable(typeof(Modules.Network.ContinueWithAuthCommand))] +[JsonSerializable(typeof(Modules.Network.FailRequestCommand))] +[JsonSerializable(typeof(Modules.Network.ProvideResponseCommand))] +[JsonSerializable(typeof(Modules.Network.RemoveInterceptCommand))] +[JsonSerializable(typeof(Modules.Network.SetCacheBehaviorCommand))] + [JsonSerializable(typeof(Modules.Network.BeforeRequestSentEventArgs))] [JsonSerializable(typeof(Modules.Network.ResponseStartedEventArgs))] [JsonSerializable(typeof(Modules.Network.ResponseCompletedEventArgs))] @@ -108,20 +139,32 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.Script.LocalValue.String), TypeInfoPropertyName = "Script_LocalValue_String")] [JsonSerializable(typeof(Modules.Script.Target.Realm), TypeInfoPropertyName = "Script_Target_Realm")] [JsonSerializable(typeof(Modules.Script.Target.Context), TypeInfoPropertyName = "Script_Target_Context")] + +[JsonSerializable(typeof(Modules.Script.AddPreloadScriptCommand))] [JsonSerializable(typeof(Modules.Script.AddPreloadScriptResult))] +[JsonSerializable(typeof(Modules.Script.DisownCommand))] +[JsonSerializable(typeof(Modules.Script.CallFunctionCommand))] +[JsonSerializable(typeof(Modules.Script.EvaluateCommand))] [JsonSerializable(typeof(Modules.Script.EvaluateResult))] +[JsonSerializable(typeof(Modules.Script.GetRealmsCommand))] [JsonSerializable(typeof(Modules.Script.GetRealmsResult))] +[JsonSerializable(typeof(Modules.Script.RemovePreloadScriptCommand))] + [JsonSerializable(typeof(Modules.Script.MessageEventArgs))] [JsonSerializable(typeof(Modules.Script.RealmDestroyedEventArgs))] [JsonSerializable(typeof(IReadOnlyList))] [JsonSerializable(typeof(Modules.Log.Entry))] +[JsonSerializable(typeof(Modules.Storage.GetCookiesCommand))] [JsonSerializable(typeof(Modules.Storage.GetCookiesResult))] -[JsonSerializable(typeof(Modules.Storage.DeleteCookiesResult))] +[JsonSerializable(typeof(Modules.Storage.SetCookieCommand))] [JsonSerializable(typeof(Modules.Storage.SetCookieResult))] +[JsonSerializable(typeof(Modules.Storage.DeleteCookiesCommand))] +[JsonSerializable(typeof(Modules.Storage.DeleteCookiesResult))] [JsonSerializable(typeof(Modules.Input.PerformActionsCommand))] +[JsonSerializable(typeof(Modules.Input.ReleaseActionsCommand))] [JsonSerializable(typeof(Modules.Input.Pointer.Down), TypeInfoPropertyName = "Input_Pointer_Down")] [JsonSerializable(typeof(Modules.Input.Pointer.Up), TypeInfoPropertyName = "Input_Pointer_Up")] [JsonSerializable(typeof(Modules.Input.Pointer.Move), TypeInfoPropertyName = "Input_Pointer_Move")] diff --git a/dotnet/src/webdriver/BiDi/Communication/Transport/ITransport.cs b/dotnet/src/webdriver/BiDi/Communication/Transport/ITransport.cs index 02d5cc9422645..777930655eb33 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Transport/ITransport.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Transport/ITransport.cs @@ -32,5 +32,6 @@ interface ITransport : IDisposable Task ReceiveAsJsonAsync(JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken); - Task SendAsJsonAsync(Command command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken); + Task SendAsJsonAsync(TCommand command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken) + where TCommand : Command; } diff --git a/dotnet/src/webdriver/BiDi/Communication/Transport/WebSocketTransport.cs b/dotnet/src/webdriver/BiDi/Communication/Transport/WebSocketTransport.cs index 643c4ebb2d96b..0950cd0c8f72d 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Transport/WebSocketTransport.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Transport/WebSocketTransport.cs @@ -71,9 +71,10 @@ public async Task ReceiveAsJsonAsync(JsonSerializerContext jsonSerializerC return (T)res!; } - public async Task SendAsJsonAsync(Command command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken) + public async Task SendAsJsonAsync(TCommand command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken) + where TCommand : Command { - var buffer = JsonSerializer.SerializeToUtf8Bytes(command, typeof(Command), jsonSerializerContext); + var buffer = JsonSerializer.SerializeToUtf8Bytes(command, typeof(TCommand), jsonSerializerContext); await _socketSendSemaphoreSlim.WaitAsync(cancellationToken); diff --git a/dotnet/src/webdriver/BiDi/Modules/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Modules/Browser/BrowserModule.cs index 24fc9042fab83..54e9dc69b29e3 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Browser/BrowserModule.cs @@ -34,12 +34,12 @@ public async Task CloseAsync(CloseOptions? options = null) public async Task CreateUserContextAsync(CreateUserContextOptions? options = null) { - return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(), options).ConfigureAwait(false); } public async Task GetUserContextsAsync(GetUserContextsOptions? options = null) { - return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options).ConfigureAwait(false); } public async Task RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null) diff --git a/dotnet/src/webdriver/BiDi/Modules/Browser/CloseCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Browser/CloseCommand.cs index d8564ba55681b..3ab63b72420a1 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Browser/CloseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Browser/CloseCommand.cs @@ -23,6 +23,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Browser; -internal class CloseCommand() : Command(CommandParameters.Empty); +internal class CloseCommand() + : Command(CommandParameters.Empty, "browser.close"); public record CloseOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Modules/Browser/CreateUserContextCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Browser/CreateUserContextCommand.cs index f002195a1e39d..9ef8605373c8c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Browser/CreateUserContextCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Browser/CreateUserContextCommand.cs @@ -23,6 +23,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Browser; -internal class CreateUserContextCommand() : Command(CommandParameters.Empty); +internal class CreateUserContextCommand() + : Command(CommandParameters.Empty, "browser.createUserContext"); public record CreateUserContextOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Modules/Browser/GetUserContextsCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Browser/GetUserContextsCommand.cs index afdc7a4e8a82d..1dba499137f9e 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Browser/GetUserContextsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Browser/GetUserContextsCommand.cs @@ -25,7 +25,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Browser; -internal class GetUserContextsCommand() : Command(CommandParameters.Empty); +internal class GetUserContextsCommand() + : Command(CommandParameters.Empty, "browser.getUserContexts"); public record GetUserContextsOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Modules/Browser/RemoveUserContextCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Browser/RemoveUserContextCommand.cs index e3d5408b4cf52..4c5f92a01e09e 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Browser/RemoveUserContextCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Browser/RemoveUserContextCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Browser; -internal class RemoveUserContextCommand(RemoveUserContextCommandParameters @params) : Command(@params); +internal class RemoveUserContextCommand(RemoveUserContextCommandParameters @params) + : Command(@params, "browser.removeUserContext"); internal record RemoveUserContextCommandParameters(UserContext UserContext) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ActivateCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ActivateCommand.cs index e88555d9fb3eb..70979eaf8e066 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ActivateCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ActivateCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class ActivateCommand(ActivateCommandParameters @params) : Command(@params); +internal class ActivateCommand(ActivateCommandParameters @params) + : Command(@params, "browsingContext.activate"); internal record ActivateCommandParameters(BrowsingContext Context) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextModule.cs index 22955d4e64e8a..f64b5ecf3d7d2 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextModule.cs @@ -39,7 +39,7 @@ public async Task CreateAsync(ContextType type, CreateOptions? @params.UserContext = options.UserContext; } - var createResult = await Broker.ExecuteCommandAsync(new CreateCommand(@params), options).ConfigureAwait(false); + var createResult = await Broker.ExecuteCommandAsync(new CreateCommand(@params), options).ConfigureAwait(false); return createResult.Context; } @@ -53,7 +53,7 @@ public async Task NavigateAsync(BrowsingContext context, string @params.Wait = options.Wait; } - return await Broker.ExecuteCommandAsync(new NavigateCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new NavigateCommand(@params), options).ConfigureAwait(false); } public async Task ActivateAsync(BrowsingContext context, ActivateOptions? options = null) @@ -74,7 +74,7 @@ public async Task LocateNodesAsync(BrowsingContext context, L @params.StartNodes = options.StartNodes; } - return await Broker.ExecuteCommandAsync(new LocateNodesCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new LocateNodesCommand(@params), options).ConfigureAwait(false); } public async Task CaptureScreenshotAsync(BrowsingContext context, CaptureScreenshotOptions? options = null) @@ -88,7 +88,7 @@ public async Task CaptureScreenshotAsync(BrowsingContex @params.Clip = options.Clip; } - return await Broker.ExecuteCommandAsync(new CaptureScreenshotCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new CaptureScreenshotCommand(@params), options).ConfigureAwait(false); } public async Task CloseAsync(BrowsingContext context, CloseOptions? options = null) @@ -102,7 +102,7 @@ public async Task TraverseHistoryAsync(BrowsingContext co { var @params = new TraverseHistoryCommandParameters(context, delta); - return await Broker.ExecuteCommandAsync(new TraverseHistoryCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new TraverseHistoryCommand(@params), options).ConfigureAwait(false); } public async Task ReloadAsync(BrowsingContext context, ReloadOptions? options = null) @@ -115,7 +115,7 @@ public async Task ReloadAsync(BrowsingContext context, ReloadOpt @params.Wait = options.Wait; } - return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options).ConfigureAwait(false); } public async Task SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null) @@ -141,7 +141,7 @@ public async Task> GetTreeAsync(GetTreeOption @params.Root = options.Root; } - var getTreeResult = await Broker.ExecuteCommandAsync(new GetTreeCommand(@params), options).ConfigureAwait(false); + var getTreeResult = await Broker.ExecuteCommandAsync(new GetTreeCommand(@params), options).ConfigureAwait(false); return getTreeResult.Contexts; } @@ -161,7 +161,7 @@ public async Task PrintAsync(BrowsingContext context, PrintOptions? @params.ShrinkToFit = options.ShrinkToFit; } - return await Broker.ExecuteCommandAsync(new PrintCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new PrintCommand(@params), options).ConfigureAwait(false); } public async Task HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null) diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs index 9d666f8427e53..5af6bcda53d2c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params) : Command(@params); +internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params) + : Command(@params, "browsingContext.captureScreenshot"); internal record CaptureScreenshotCommandParameters(BrowsingContext Context) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CloseCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CloseCommand.cs index f21bb5a6970c3..d335012b6569d 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CloseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CloseCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class CloseCommand(CloseCommandParameters @params) : Command(@params); +internal class CloseCommand(CloseCommandParameters @params) + : Command(@params, "browsingContext.close"); internal record CloseCommandParameters(BrowsingContext Context) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CreateCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CreateCommand.cs index 5ecd37d3b82b3..de967f4a109a2 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CreateCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CreateCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class CreateCommand(CreateCommandParameters @params) : Command(@params); +internal class CreateCommand(CreateCommandParameters @params) + : Command(@params, "browsingContext.create"); internal record CreateCommandParameters(ContextType Type) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs index 9a78608d0a15d..b271e8517012d 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class GetTreeCommand(GetTreeCommandParameters @params) : Command(@params); +internal class GetTreeCommand(GetTreeCommandParameters @params) + : Command(@params, "browsingContext.getTree"); internal record GetTreeCommandParameters : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/HandleUserPromptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/HandleUserPromptCommand.cs index 91fb94cc16ce3..4e75e6620c3b7 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/HandleUserPromptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/HandleUserPromptCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -class HandleUserPromptCommand(HandleUserPromptCommandParameters @params) : Command(@params); +class HandleUserPromptCommand(HandleUserPromptCommandParameters @params) + : Command(@params, "browsingContext.handleUserPrompt"); internal record HandleUserPromptCommandParameters(BrowsingContext Context) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs index cdf14ecbf1333..9e58c9eb92a76 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/LocateNodesCommand.cs @@ -25,7 +25,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class LocateNodesCommand(LocateNodesCommandParameters @params) : Command(@params); +internal class LocateNodesCommand(LocateNodesCommandParameters @params) + : Command(@params, "browsingContext.locateNodes"); internal record LocateNodesCommandParameters(BrowsingContext Context, Locator Locator) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/NavigateCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/NavigateCommand.cs index 42aa195edeb24..ff1714b30a5f0 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/NavigateCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/NavigateCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class NavigateCommand(NavigateCommandParameters @params) : Command(@params); +internal class NavigateCommand(NavigateCommandParameters @params) + : Command(@params, "browsingContext.navigate"); internal record NavigateCommandParameters(BrowsingContext Context, string Url) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/PrintCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/PrintCommand.cs index b4137b9b2a1a2..47046cabfae7f 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/PrintCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/PrintCommand.cs @@ -25,7 +25,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class PrintCommand(PrintCommandParameters @params) : Command(@params); +internal class PrintCommand(PrintCommandParameters @params) + : Command(@params, "browsingContext.print"); internal record PrintCommandParameters(BrowsingContext Context) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ReloadCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ReloadCommand.cs index 190cea29774c6..0ec8e4c9ff612 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ReloadCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ReloadCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class ReloadCommand(ReloadCommandParameters @params) : Command(@params); +internal class ReloadCommand(ReloadCommandParameters @params) + : Command(@params, "browsingContext.reload"); internal record ReloadCommandParameters(BrowsingContext Context) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/SetViewportCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/SetViewportCommand.cs index 5d7b904e9f339..75dc8252986b3 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/SetViewportCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/SetViewportCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class SetViewportCommand(SetViewportCommandParameters @params) : Command(@params); +internal class SetViewportCommand(SetViewportCommandParameters @params) + : Command(@params, "browsingContext.setViewport"); internal record SetViewportCommandParameters(BrowsingContext Context) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/TraverseHistoryCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/TraverseHistoryCommand.cs index ee1212b78d1c3..8ba4a6ba98cb4 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/TraverseHistoryCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/TraverseHistoryCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; -internal class TraverseHistoryCommand(TraverseHistoryCommandParameters @params) : Command(@params); +internal class TraverseHistoryCommand(TraverseHistoryCommandParameters @params) + : Command(@params, "browsingContext.traverseHistory"); internal record TraverseHistoryCommandParameters(BrowsingContext Context, long Delta) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Input/PerformActionsCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Input/PerformActionsCommand.cs index 01aeae8657bcc..bde6217fe6ee4 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Input/PerformActionsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Input/PerformActionsCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Input; -internal class PerformActionsCommand(PerformActionsCommandParameters @params) : Command(@params); +internal class PerformActionsCommand(PerformActionsCommandParameters @params) + : Command(@params, "input.performActions"); internal record PerformActionsCommandParameters(BrowsingContext.BrowsingContext Context, IEnumerable Actions) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Input/ReleaseActionsCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Input/ReleaseActionsCommand.cs index 8ff8364dac67f..8398c0d7d082f 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Input/ReleaseActionsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Input/ReleaseActionsCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Input; -internal class ReleaseActionsCommand(ReleaseActionsCommandParameters @params) : Command(@params); +internal class ReleaseActionsCommand(ReleaseActionsCommandParameters @params) + : Command(@params, "input.releaseActions"); internal record ReleaseActionsCommandParameters(BrowsingContext.BrowsingContext Context) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs index 284d0dc7fcbdf..c8d9525d9235a 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class AddInterceptCommand(AddInterceptCommandParameters @params) : Command(@params); +internal class AddInterceptCommand(AddInterceptCommandParameters @params) + : Command(@params, "network.addIntercept"); internal record AddInterceptCommandParameters(IEnumerable Phases) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueRequestCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueRequestCommand.cs index 5311b4c284b26..07533727fe15d 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueRequestCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueRequestCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class ContinueRequestCommand(ContinueRequestCommandParameters @params) : Command(@params); +internal class ContinueRequestCommand(ContinueRequestCommandParameters @params) + : Command(@params, "network.continueRequest"); internal record ContinueRequestCommandParameters(Request Request) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueResponseCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueResponseCommand.cs index f62e7a0013960..8374957a75fd1 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueResponseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueResponseCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class ContinueResponseCommand(ContinueResponseCommandParameters @params) : Command(@params); +internal class ContinueResponseCommand(ContinueResponseCommandParameters @params) + : Command(@params, "network.continueResponse"); internal record ContinueResponseCommandParameters(Request Request) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueWithAuthCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueWithAuthCommand.cs index ffe88f270b653..a3bb223a49fbb 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/ContinueWithAuthCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/ContinueWithAuthCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class ContinueWithAuthCommand(ContinueWithAuthParameters @params) : Command(@params); +internal class ContinueWithAuthCommand(ContinueWithAuthParameters @params) + : Command(@params, "network.continueWithAuth"); [JsonPolymorphic(TypeDiscriminatorPropertyName = "action")] [JsonDerivedType(typeof(Credentials), "provideCredentials")] diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/FailRequestCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/FailRequestCommand.cs index 10a97607f4d30..75dbbdb8466c9 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/FailRequestCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/FailRequestCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class FailRequestCommand(FailRequestCommandParameters @params) : Command(@params); +internal class FailRequestCommand(FailRequestCommandParameters @params) + : Command(@params, "network.failRequest"); internal record FailRequestCommandParameters(Request Request) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs index 257da7c27daf8..2589f3727df5c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/NetworkModule.cs @@ -38,7 +38,7 @@ internal async Task AddInterceptAsync(IEnumerable pha @params.UrlPatterns = options.UrlPatterns; } - var result = await Broker.ExecuteCommandAsync(new AddInterceptCommand(@params), options).ConfigureAwait(false); + var result = await Broker.ExecuteCommandAsync(new AddInterceptCommand(@params), options).ConfigureAwait(false); return result.Intercept; } diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/ProvideResponseCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/ProvideResponseCommand.cs index dc761b0f4284c..edfcf170358a9 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/ProvideResponseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/ProvideResponseCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class ProvideResponseCommand(ProvideResponseCommandParameters @params) : Command(@params); +internal class ProvideResponseCommand(ProvideResponseCommandParameters @params) + : Command(@params, "network.provideResponse"); internal record ProvideResponseCommandParameters(Request Request) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/RemoveInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/RemoveInterceptCommand.cs index da9b1e31c2965..ff11b0eb9e04a 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/RemoveInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/RemoveInterceptCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class RemoveInterceptCommand(RemoveInterceptCommandParameters @params) : Command(@params); +internal class RemoveInterceptCommand(RemoveInterceptCommandParameters @params) + : Command(@params, "network.removeIntercept"); internal record RemoveInterceptCommandParameters(Intercept Intercept) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs index c6b29b3ba6769..15ca3014c2d6c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/SetCacheBehaviorCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; -internal class SetCacheBehaviorCommand(SetCacheBehaviorCommandParameters @params) : Command(@params); +internal class SetCacheBehaviorCommand(SetCacheBehaviorCommandParameters @params) + : Command(@params, "network.setCacheBehavior"); internal record SetCacheBehaviorCommandParameters(CacheBehavior CacheBehavior) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs index ba79145c6635e..871b327a6c79a 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class AddPreloadScriptCommand(AddPreloadScriptCommandParameters @params) : Command(@params); +internal class AddPreloadScriptCommand(AddPreloadScriptCommandParameters @params) + : Command(@params, "script.addPreloadScript"); internal record AddPreloadScriptCommandParameters(string FunctionDeclaration) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/CallFunctionCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/CallFunctionCommand.cs index ecb97445c3c99..8f7b172fe8072 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/CallFunctionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/CallFunctionCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class CallFunctionCommand(CallFunctionCommandParameters @params) : Command(@params); +internal class CallFunctionCommand(CallFunctionCommandParameters @params) + : Command(@params, "script.callFunction"); internal record CallFunctionCommandParameters(string FunctionDeclaration, bool AwaitPromise, Target Target) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/DisownCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/DisownCommand.cs index 74361770b73cb..b941ddcdedfac 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/DisownCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/DisownCommand.cs @@ -24,6 +24,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class DisownCommand(DisownCommandParameters @params) : Command(@params); +internal class DisownCommand(DisownCommandParameters @params) + : Command(@params, "script.disown"); internal record DisownCommandParameters(IEnumerable Handles, Target Target) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/EvaluateCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/EvaluateCommand.cs index eec45a90bb339..4559077094ad4 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/EvaluateCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/EvaluateCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class EvaluateCommand(EvaluateCommandParameters @params) : Command(@params); +internal class EvaluateCommand(EvaluateCommandParameters @params) + : Command(@params, "script.evaluate"); internal record EvaluateCommandParameters(string Expression, Target Target, bool AwaitPromise) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/GetRealmsCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/GetRealmsCommand.cs index a4fa2ef1c9ac5..d929c18ed1c4c 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/GetRealmsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/GetRealmsCommand.cs @@ -25,7 +25,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class GetRealmsCommand(GetRealmsCommandParameters @params) : Command(@params); +internal class GetRealmsCommand(GetRealmsCommandParameters @params) + : Command(@params, "script.getRealms"); internal record GetRealmsCommandParameters : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/RemovePreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/RemovePreloadScriptCommand.cs index 513c1d6dcf78a..cff5e001816da 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/RemovePreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/RemovePreloadScriptCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Script; -internal class RemovePreloadScriptCommand(RemovePreloadScriptCommandParameters @params) : Command(@params); +internal class RemovePreloadScriptCommand(RemovePreloadScriptCommandParameters @params) + : Command(@params, "script.removePreloadScript"); internal record RemovePreloadScriptCommandParameters(PreloadScript Script) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Modules/Script/ScriptModule.cs index 10e4d9a4db6d9..7aa516480da01 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/ScriptModule.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.BiDi.Communication; using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -40,7 +39,7 @@ public sealed class ScriptModule(Broker broker) : Module(broker) @params.UserActivation = options.UserActivation; } - var result = await Broker.ExecuteCommandAsync(new EvaluateCommand(@params), options).ConfigureAwait(false); + var result = await Broker.ExecuteCommandAsync(new EvaluateCommand(@params), options).ConfigureAwait(false); if (result is EvaluateResult.Exception exp) { @@ -70,7 +69,7 @@ public sealed class ScriptModule(Broker broker) : Module(broker) @params.UserActivation = options.UserActivation; } - var result = await Broker.ExecuteCommandAsync(new CallFunctionCommand(@params), options).ConfigureAwait(false); + var result = await Broker.ExecuteCommandAsync(new CallFunctionCommand(@params), options).ConfigureAwait(false); if (result is EvaluateResult.Exception exp) { @@ -97,7 +96,7 @@ public async Task GetRealmsAsync(GetRealmsOptions? options = nu @params.Type = options.Type; } - return await Broker.ExecuteCommandAsync(new GetRealmsCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new GetRealmsCommand(@params), options).ConfigureAwait(false); } public async Task AddPreloadScriptAsync(string functionDeclaration, AddPreloadScriptOptions? options = null) @@ -111,7 +110,7 @@ public async Task AddPreloadScriptAsync(string functionDeclaratio @params.Sandbox = options.Sandbox; } - var result = await Broker.ExecuteCommandAsync(new AddPreloadScriptCommand(@params), options).ConfigureAwait(false); + var result = await Broker.ExecuteCommandAsync(new AddPreloadScriptCommand(@params), options).ConfigureAwait(false); return result.Script; } diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/EndCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Session/EndCommand.cs index cf748e8396416..71e4cb5277a49 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/EndCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/EndCommand.cs @@ -23,6 +23,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -internal class EndCommand() : Command(CommandParameters.Empty); +internal class EndCommand() + : Command(CommandParameters.Empty, "session.end"); public record EndOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/NewCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Session/NewCommand.cs index 5d8a6779eb531..534f945633ca5 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/NewCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/NewCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -internal class NewCommand(NewCommandParameters @params) : Command(@params); +internal class NewCommand(NewCommandParameters @params) + : Command(@params, "session.new"); internal record NewCommandParameters(CapabilitiesRequest Capabilities) : CommandParameters; diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Modules/Session/SessionModule.cs index ac06f82d88c0c..4921657ef138a 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/SessionModule.cs @@ -29,7 +29,7 @@ internal sealed class SessionModule(Broker broker) : Module(broker) { public async Task StatusAsync(StatusOptions? options = null) { - return await Broker.ExecuteCommandAsync(new StatusCommand(), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new StatusCommand(), options).ConfigureAwait(false); } public async Task SubscribeAsync(IEnumerable events, SubscribeOptions? options = null) @@ -60,7 +60,7 @@ public async Task NewAsync(CapabilitiesRequest capabilitiesRequest, N { var @params = new NewCommandParameters(capabilitiesRequest); - return await Broker.ExecuteCommandAsync(new NewCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new NewCommand(@params), options).ConfigureAwait(false); } public async Task EndAsync(EndOptions? options = null) diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/StatusCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Session/StatusCommand.cs index 1c60512f2ca4c..67277999c131d 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/StatusCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/StatusCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -internal class StatusCommand() : Command(CommandParameters.Empty); +internal class StatusCommand() + : Command(CommandParameters.Empty, "session.status"); public record StatusResult(bool Ready, string Message); diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/SubscribeCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Session/SubscribeCommand.cs index b7b99c0ad0a74..fc85306cf269d 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/SubscribeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/SubscribeCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -internal class SubscribeCommand(SubscribeCommandParameters @params) : Command(@params); +internal class SubscribeCommand(SubscribeCommandParameters @params) + : Command(@params, "session.subscribe"); internal record SubscribeCommandParameters(IEnumerable Events) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Session/UnsubscribeCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Session/UnsubscribeCommand.cs index c71ee4b18f93e..970f6c32dc8a1 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Session/UnsubscribeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Session/UnsubscribeCommand.cs @@ -23,6 +23,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Session; -internal class UnsubscribeCommand(SubscribeCommandParameters @params) : Command(@params); +internal class UnsubscribeCommand(SubscribeCommandParameters @params) + : Command(@params, "session.unsubscribe"); public record UnsubscribeOptions : SubscribeOptions; diff --git a/dotnet/src/webdriver/BiDi/Modules/Storage/DeleteCookiesCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Storage/DeleteCookiesCommand.cs index 010e6c6496590..f031501b83c12 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Storage/DeleteCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Storage/DeleteCookiesCommand.cs @@ -23,7 +23,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Storage; -internal class DeleteCookiesCommand(DeleteCookiesCommandParameters @params) : Command(@params); +internal class DeleteCookiesCommand(DeleteCookiesCommandParameters @params) + : Command(@params, "storage.deleteCookies"); internal record DeleteCookiesCommandParameters : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Storage/GetCookiesCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Storage/GetCookiesCommand.cs index 5a8f9224b53b1..7210210cb04b0 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Storage/GetCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Storage/GetCookiesCommand.cs @@ -27,7 +27,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Storage; -internal class GetCookiesCommand(GetCookiesCommandParameters @params) : Command(@params); +internal class GetCookiesCommand(GetCookiesCommandParameters @params) + : Command(@params, "storage.getCookies"); internal record GetCookiesCommandParameters : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Storage/SetCookieCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Storage/SetCookieCommand.cs index f79fd1854a558..03909a8b5c0ec 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Storage/SetCookieCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Storage/SetCookieCommand.cs @@ -24,7 +24,8 @@ namespace OpenQA.Selenium.BiDi.Modules.Storage; -internal class SetCookieCommand(SetCookieCommandParameters @params) : Command(@params); +internal class SetCookieCommand(SetCookieCommandParameters @params) + : Command(@params, "storage.setCookie"); internal record SetCookieCommandParameters(PartialCookie Cookie) : CommandParameters { diff --git a/dotnet/src/webdriver/BiDi/Modules/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Modules/Storage/StorageModule.cs index faecb3d5a6f2f..9aa51cafd2460 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Storage/StorageModule.cs @@ -36,7 +36,7 @@ public async Task GetCookiesAsync(GetCookiesOptions? options = @params.Partition = options.Partition; } - return await Broker.ExecuteCommandAsync(new GetCookiesCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new GetCookiesCommand(@params), options).ConfigureAwait(false); } public async Task DeleteCookiesAsync(DeleteCookiesOptions? options = null) @@ -49,7 +49,7 @@ public async Task DeleteCookiesAsync(DeleteCookiesOptions? @params.Partition = options.Partition; } - return await Broker.ExecuteCommandAsync(new DeleteCookiesCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new DeleteCookiesCommand(@params), options).ConfigureAwait(false); } public async Task SetCookieAsync(PartialCookie cookie, SetCookieOptions? options = null) @@ -61,6 +61,6 @@ public async Task SetCookieAsync(PartialCookie cookie, SetCooki @params.Partition = options.Partition; } - return await Broker.ExecuteCommandAsync(new SetCookieCommand(@params), options).ConfigureAwait(false); + return await Broker.ExecuteCommandAsync(new SetCookieCommand(@params), options).ConfigureAwait(false); } }