From 15d72e13f4d113f3f375498b10408eddab54624d Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Thu, 9 Apr 2026 22:57:44 +0300 Subject: [PATCH 01/11] [dotnet] [bidi] Statically declare commands --- dotnet/src/webdriver/BiDi/Broker.cs | 23 +++-- .../webdriver/BiDi/Browser/BrowserModule.cs | 44 ++++++--- .../Browser/{CloseCommand.cs => Close.cs} | 3 - ...ContextCommand.cs => CreateUserContext.cs} | 3 - ...tWindowsCommand.cs => GetClientWindows.cs} | 3 - ...rContextsCommand.cs => GetUserContexts.cs} | 3 - ...ContextCommand.cs => RemoveUserContext.cs} | 3 - ...aviorCommand.cs => SetDownloadBehavior.cs} | 3 - .../{ActivateCommand.cs => Activate.cs} | 3 - .../BrowsingContext/BrowsingContextModule.cs | 84 +++++++++++----- ...eenshotCommand.cs => CaptureScreenshot.cs} | 3 - .../{CloseCommand.cs => Close.cs} | 3 - .../{CreateCommand.cs => Create.cs} | 3 - .../{GetTreeCommand.cs => GetTree.cs} | 3 - ...erPromptCommand.cs => HandleUserPrompt.cs} | 3 - .../{LocateNodesCommand.cs => LocateNodes.cs} | 3 - .../{NavigateCommand.cs => Navigate.cs} | 3 - .../{PrintCommand.cs => Print.cs} | 3 - .../{ReloadCommand.cs => Reload.cs} | 3 - .../{SetViewportCommand.cs => SetViewport.cs} | 3 - ...seHistoryCommand.cs => TraverseHistory.cs} | 3 - dotnet/src/webdriver/BiDi/Command.cs | 25 ++--- .../BiDi/Emulation/EmulationModule.cs | 95 +++++++++++-------- ...cs => SetForcedColorsModeThemeOverride.cs} | 3 - ...deCommand.cs => SetGeolocationOverride.cs} | 3 - ...verrideCommand.cs => SetLocaleOverride.cs} | 3 - ...ionsCommand.cs => SetNetworkConditions.cs} | 3 - ...and.cs => SetScreenOrientationOverride.cs} | 3 - ...ommand.cs => SetScreenSettingsOverride.cs} | 3 - ...abledCommand.cs => SetScriptingEnabled.cs} | 3 - ...Command.cs => SetScrollbarTypeOverride.cs} | 3 - ...rrideCommand.cs => SetTimezoneOverride.cs} | 3 - ...OverrideCommand.cs => SetTouchOverride.cs} | 3 - ...rideCommand.cs => SetUserAgentOverride.cs} | 3 - .../src/webdriver/BiDi/Input/InputModule.cs | 21 ++-- ...ormActionsCommand.cs => PerformActions.cs} | 3 - ...aseActionsCommand.cs => ReleaseActions.cs} | 3 - .../Input/{SetFilesCommand.cs => SetFiles.cs} | 3 - dotnet/src/webdriver/BiDi/Module.cs | 6 +- ...ollectorCommand.cs => AddDataCollector.cs} | 3 - ...AddInterceptCommand.cs => AddIntercept.cs} | 3 - ...ueRequestCommand.cs => ContinueRequest.cs} | 3 - ...ResponseCommand.cs => ContinueResponse.cs} | 3 - ...WithAuthCommand.cs => ContinueWithAuth.cs} | 3 - .../{FailRequestCommand.cs => FailRequest.cs} | 3 - .../Network/{GetDataCommand.cs => GetData.cs} | 3 - .../webdriver/BiDi/Network/NetworkModule.cs | 88 ++++++++++++----- ...eResponseCommand.cs => ProvideResponse.cs} | 3 - ...ectorCommand.cs => RemoveDataCollector.cs} | 3 - ...InterceptCommand.cs => RemoveIntercept.cs} | 3 - ...BehaviorCommand.cs => SetCacheBehavior.cs} | 3 - ...raHeadersCommand.cs => SetExtraHeaders.cs} | 3 - .../BiDi/Permissions/PermissionsModule.cs | 7 +- ...tPermissionCommand.cs => SetPermission.cs} | 3 - ...adScriptCommand.cs => AddPreloadScript.cs} | 3 - ...CallFunctionCommand.cs => CallFunction.cs} | 3 - .../Script/{DisownCommand.cs => Disown.cs} | 3 - .../{EvaluateCommand.cs => Evaluate.cs} | 3 - .../{GetRealmsCommand.cs => GetRealms.cs} | 3 - ...criptCommand.cs => RemovePreloadScript.cs} | 3 - .../src/webdriver/BiDi/Script/ScriptModule.cs | 42 +++++--- .../BiDi/Session/{EndCommand.cs => End.cs} | 3 - .../BiDi/Session/{NewCommand.cs => New.cs} | 3 - .../webdriver/BiDi/Session/SessionModule.cs | 34 +++++-- .../Session/{StatusCommand.cs => Status.cs} | 3 - .../{SubscribeCommand.cs => Subscribe.cs} | 3 - .../{UnsubscribeCommand.cs => Unsubscribe.cs} | 3 - ...leteCookiesCommand.cs => DeleteCookies.cs} | 3 - .../{GetCookiesCommand.cs => GetCookies.cs} | 3 - .../{SetCookieCommand.cs => SetCookie.cs} | 3 - .../webdriver/BiDi/Storage/StorageModule.cs | 21 ++-- .../{InstallCommand.cs => Install.cs} | 3 - .../{UninstallCommand.cs => Uninstall.cs} | 3 - .../BiDi/WebExtension/WebExtensionModule.cs | 14 ++- 74 files changed, 340 insertions(+), 347 deletions(-) rename dotnet/src/webdriver/BiDi/Browser/{CloseCommand.cs => Close.cs} (90%) rename dotnet/src/webdriver/BiDi/Browser/{CreateUserContextCommand.cs => CreateUserContext.cs} (88%) rename dotnet/src/webdriver/BiDi/Browser/{GetClientWindowsCommand.cs => GetClientWindows.cs} (88%) rename dotnet/src/webdriver/BiDi/Browser/{GetUserContextsCommand.cs => GetUserContexts.cs} (88%) rename dotnet/src/webdriver/BiDi/Browser/{RemoveUserContextCommand.cs => RemoveUserContext.cs} (85%) rename dotnet/src/webdriver/BiDi/Browser/{SetDownloadBehaviorCommand.cs => SetDownloadBehavior.cs} (89%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{ActivateCommand.cs => Activate.cs} (87%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{CaptureScreenshotCommand.cs => CaptureScreenshot.cs} (92%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{CloseCommand.cs => Close.cs} (89%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{CreateCommand.cs => Create.cs} (91%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{GetTreeCommand.cs => GetTree.cs} (91%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{HandleUserPromptCommand.cs => HandleUserPrompt.cs} (86%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{LocateNodesCommand.cs => LocateNodes.cs} (89%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{NavigateCommand.cs => Navigate.cs} (90%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{PrintCommand.cs => Print.cs} (96%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{ReloadCommand.cs => Reload.cs} (90%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{SetViewportCommand.cs => SetViewport.cs} (93%) rename dotnet/src/webdriver/BiDi/BrowsingContext/{TraverseHistoryCommand.cs => TraverseHistory.cs} (86%) rename dotnet/src/webdriver/BiDi/Emulation/{SetForcedColorsModeThemeOverrideCommand.cs => SetForcedColorsModeThemeOverride.cs} (86%) rename dotnet/src/webdriver/BiDi/Emulation/{SetGeolocationOverrideCommand.cs => SetGeolocationOverride.cs} (93%) rename dotnet/src/webdriver/BiDi/Emulation/{SetLocaleOverrideCommand.cs => SetLocaleOverride.cs} (88%) rename dotnet/src/webdriver/BiDi/Emulation/{SetNetworkConditionsCommand.cs => SetNetworkConditions.cs} (89%) rename dotnet/src/webdriver/BiDi/Emulation/{SetScreenOrientationOverrideCommand.cs => SetScreenOrientationOverride.cs} (89%) rename dotnet/src/webdriver/BiDi/Emulation/{SetScreenSettingsOverrideCommand.cs => SetScreenSettingsOverride.cs} (87%) rename dotnet/src/webdriver/BiDi/Emulation/{SetScriptingEnabledCommand.cs => SetScriptingEnabled.cs} (88%) rename dotnet/src/webdriver/BiDi/Emulation/{SetScrollbarTypeOverrideCommand.cs => SetScrollbarTypeOverride.cs} (88%) rename dotnet/src/webdriver/BiDi/Emulation/{SetTimezoneOverrideCommand.cs => SetTimezoneOverride.cs} (88%) rename dotnet/src/webdriver/BiDi/Emulation/{SetTouchOverrideCommand.cs => SetTouchOverride.cs} (88%) rename dotnet/src/webdriver/BiDi/Emulation/{SetUserAgentOverrideCommand.cs => SetUserAgentOverride.cs} (87%) rename dotnet/src/webdriver/BiDi/Input/{PerformActionsCommand.cs => PerformActions.cs} (87%) rename dotnet/src/webdriver/BiDi/Input/{ReleaseActionsCommand.cs => ReleaseActions.cs} (86%) rename dotnet/src/webdriver/BiDi/Input/{SetFilesCommand.cs => SetFiles.cs} (89%) rename dotnet/src/webdriver/BiDi/Network/{AddDataCollectorCommand.cs => AddDataCollector.cs} (92%) rename dotnet/src/webdriver/BiDi/Network/{AddInterceptCommand.cs => AddIntercept.cs} (92%) rename dotnet/src/webdriver/BiDi/Network/{ContinueRequestCommand.cs => ContinueRequest.cs} (89%) rename dotnet/src/webdriver/BiDi/Network/{ContinueResponseCommand.cs => ContinueResponse.cs} (89%) rename dotnet/src/webdriver/BiDi/Network/{ContinueWithAuthCommand.cs => ContinueWithAuth.cs} (92%) rename dotnet/src/webdriver/BiDi/Network/{FailRequestCommand.cs => FailRequest.cs} (87%) rename dotnet/src/webdriver/BiDi/Network/{GetDataCommand.cs => GetData.cs} (89%) rename dotnet/src/webdriver/BiDi/Network/{ProvideResponseCommand.cs => ProvideResponse.cs} (89%) rename dotnet/src/webdriver/BiDi/Network/{RemoveDataCollectorCommand.cs => RemoveDataCollector.cs} (85%) rename dotnet/src/webdriver/BiDi/Network/{RemoveInterceptCommand.cs => RemoveIntercept.cs} (86%) rename dotnet/src/webdriver/BiDi/Network/{SetCacheBehaviorCommand.cs => SetCacheBehavior.cs} (90%) rename dotnet/src/webdriver/BiDi/Network/{SetExtraHeadersCommand.cs => SetExtraHeaders.cs} (88%) rename dotnet/src/webdriver/BiDi/Permissions/{SetPermissionCommand.cs => SetPermission.cs} (88%) rename dotnet/src/webdriver/BiDi/Script/{AddPreloadScriptCommand.cs => AddPreloadScript.cs} (92%) rename dotnet/src/webdriver/BiDi/Script/{CallFunctionCommand.cs => CallFunction.cs} (91%) rename dotnet/src/webdriver/BiDi/Script/{DisownCommand.cs => Disown.cs} (89%) rename dotnet/src/webdriver/BiDi/Script/{EvaluateCommand.cs => Evaluate.cs} (95%) rename dotnet/src/webdriver/BiDi/Script/{GetRealmsCommand.cs => GetRealms.cs} (91%) rename dotnet/src/webdriver/BiDi/Script/{RemovePreloadScriptCommand.cs => RemovePreloadScript.cs} (85%) rename dotnet/src/webdriver/BiDi/Session/{EndCommand.cs => End.cs} (90%) rename dotnet/src/webdriver/BiDi/Session/{NewCommand.cs => New.cs} (92%) rename dotnet/src/webdriver/BiDi/Session/{StatusCommand.cs => Status.cs} (90%) rename dotnet/src/webdriver/BiDi/Session/{SubscribeCommand.cs => Subscribe.cs} (90%) rename dotnet/src/webdriver/BiDi/Session/{UnsubscribeCommand.cs => Unsubscribe.cs} (86%) rename dotnet/src/webdriver/BiDi/Storage/{DeleteCookiesCommand.cs => DeleteCookies.cs} (90%) rename dotnet/src/webdriver/BiDi/Storage/{GetCookiesCommand.cs => GetCookies.cs} (94%) rename dotnet/src/webdriver/BiDi/Storage/{SetCookieCommand.cs => SetCookie.cs} (92%) rename dotnet/src/webdriver/BiDi/WebExtension/{InstallCommand.cs => Install.cs} (91%) rename dotnet/src/webdriver/BiDi/WebExtension/{UninstallCommand.cs => Uninstall.cs} (87%) diff --git a/dotnet/src/webdriver/BiDi/Broker.cs b/dotnet/src/webdriver/BiDi/Broker.cs index 9611f3cadcec1..e93b7f35fe70f 100644 --- a/dotnet/src/webdriver/BiDi/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Broker.cs @@ -114,8 +114,8 @@ public async ValueTask UnsubscribeAsync(Subscription subscription, CancellationT _eventDispatcher.RemoveHandler(subscription.EventName, subscription.Handler); } - public async Task ExecuteCommandAsync(TCommand command, CommandOptions? options, JsonTypeInfo jsonCommandTypeInfo, JsonTypeInfo jsonResultTypeInfo, CancellationToken cancellationToken) - where TCommand : Command + public async Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + where TParameters : Parameters where TResult : EmptyResult { if (_terminalReceiveException is { } terminalException) @@ -123,7 +123,14 @@ public async Task ExecuteCommandAsync(TCommand comma throw new BiDiException("The broker is no longer processing messages due to a transport error.", terminalException); } - command.Id = Interlocked.Increment(ref _currentCommandId); + var id = Interlocked.Increment(ref _currentCommandId); + + var message = new CommandMessage + { + Id = id, + Method = descriptor.Method, + Params = @params + }; var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -141,7 +148,7 @@ public async Task ExecuteCommandAsync(TCommand comma using (BiDiContext.Use(_bidi)) using (var writer = new Utf8JsonWriter(sendBuffer)) { - JsonSerializer.Serialize(writer, command, jsonCommandTypeInfo); + JsonSerializer.Serialize(writer, message, descriptor.CommandTypeInfo); } } catch @@ -150,13 +157,13 @@ public async Task ExecuteCommandAsync(TCommand comma throw; } - var commandInfo = new CommandInfo(tcs, jsonResultTypeInfo); - _pendingCommands[command.Id] = commandInfo; + var commandInfo = new CommandInfo(tcs, descriptor.ResultTypeInfo); + _pendingCommands[id] = commandInfo; using var ctsRegistration = cts.Token.Register(() => { tcs.TrySetCanceled(cts.Token); - _pendingCommands.TryRemove(command.Id, out _); + _pendingCommands.TryRemove(id, out _); }); try @@ -174,7 +181,7 @@ public async Task ExecuteCommandAsync(TCommand comma } catch { - _pendingCommands.TryRemove(command.Id, out _); + _pendingCommands.TryRemove(id, out _); throw; } finally diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 8db5e1a34d875..4123df610a89c 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -25,68 +25,84 @@ public sealed class BrowserModule : Module, IBrowserModule { private static readonly BrowserJsonSerializerContext JsonContext = BrowserJsonSerializerContext.Default; + private static readonly CommandDescriptor CloseCommand = new( + "browser.close", JsonContext.CommandMessageParameters, JsonContext.CloseResult); + + private static readonly CommandDescriptor CreateUserContextCommand = new( + "browser.createUserContext", JsonContext.CommandMessageCreateUserContextParameters, JsonContext.CreateUserContextResult); + + private static readonly CommandDescriptor GetUserContextsCommand = new( + "browser.getUserContexts", JsonContext.CommandMessageParameters, JsonContext.GetUserContextsResult); + + private static readonly CommandDescriptor RemoveUserContextCommand = new( + "browser.removeUserContext", JsonContext.CommandMessageRemoveUserContextParameters, JsonContext.RemoveUserContextResult); + + private static readonly CommandDescriptor GetClientWindowsCommand = new( + "browser.getClientWindows", JsonContext.CommandMessageParameters, JsonContext.GetClientWindowsResult); + + private static readonly CommandDescriptor SetDownloadBehaviorCommand = new( + "browser.setDownloadBehavior", JsonContext.CommandMessageSetDownloadBehaviorParameters, JsonContext.SetDownloadBehaviorResult); + public async Task CloseAsync(CloseOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new CloseCommand(), options, JsonContext.CloseCommand, JsonContext.CloseResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CloseCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task CreateUserContextAsync(CreateUserContextOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior); - return await ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.CreateUserContextResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CreateUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetUserContextsAsync(GetUserContextsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new GetUserContextsCommand(), options, JsonContext.GetUserContextsCommand, JsonContext.GetUserContextsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(GetUserContextsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveUserContextParameters(userContext); - return await ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, JsonContext.RemoveUserContextCommand, JsonContext.RemoveUserContextResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(RemoveUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetClientWindowsAsync(GetClientWindowsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new(), options, JsonContext.GetClientWindowsCommand, JsonContext.GetClientWindowsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(GetClientWindowsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts); - return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts); - return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts); - return await ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(CloseCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(CloseResult))] -[JsonSerializable(typeof(CreateUserContextCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(CreateUserContextResult))] -[JsonSerializable(typeof(GetUserContextsCommand))] [JsonSerializable(typeof(GetUserContextsResult))] -[JsonSerializable(typeof(RemoveUserContextCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(RemoveUserContextResult))] -[JsonSerializable(typeof(GetClientWindowsCommand))] [JsonSerializable(typeof(GetClientWindowsResult))] -[JsonSerializable(typeof(SetDownloadBehaviorCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetDownloadBehaviorResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Browser/CloseCommand.cs b/dotnet/src/webdriver/BiDi/Browser/Close.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Browser/CloseCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/Close.cs index 6b1e36e682c59..5bd6725cdaae9 100644 --- a/dotnet/src/webdriver/BiDi/Browser/CloseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/Close.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class CloseCommand() - : Command(Parameters.Empty, "browser.close"); - public sealed record CloseOptions : CommandOptions; public sealed record CloseResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/CreateUserContextCommand.cs b/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Browser/CreateUserContextCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs index db0795f62e126..eb9ca1aee3d2b 100644 --- a/dotnet/src/webdriver/BiDi/Browser/CreateUserContextCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class CreateUserContextCommand(CreateUserContextParameters @params) - : Command(@params, "browser.createUserContext"); - internal sealed record CreateUserContextParameters(bool? AcceptInsecureCerts, Session.ProxyConfiguration? Proxy, Session.UserPromptHandler? UnhandledPromptBehavior) : Parameters; public sealed record CreateUserContextOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs index f0967769c58b6..b115ae0617a0f 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class GetClientWindowsCommand() - : Command(Parameters.Empty, "browser.getClientWindows"); - public sealed record GetClientWindowsOptions : CommandOptions; public sealed record GetClientWindowsResult(IReadOnlyList ClientWindows) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs index b7f287fa702ea..a2330b721520d 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContextsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class GetUserContextsCommand() - : Command(Parameters.Empty, "browser.getUserContexts"); - public record GetUserContextsOptions : CommandOptions; public sealed record GetUserContextsResult(IReadOnlyList UserContexts) : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Browser/RemoveUserContextCommand.cs b/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs similarity index 85% rename from dotnet/src/webdriver/BiDi/Browser/RemoveUserContextCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs index 4ae2b1351e73d..e46b48febf317 100644 --- a/dotnet/src/webdriver/BiDi/Browser/RemoveUserContextCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class RemoveUserContextCommand(RemoveUserContextParameters @params) - : Command(@params, "browser.removeUserContext"); - internal sealed record RemoveUserContextParameters(UserContext UserContext) : Parameters; public sealed record RemoveUserContextOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehaviorCommand.cs b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Browser/SetDownloadBehaviorCommand.cs rename to dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs index 2565c2ea9277d..45885d802ffa4 100644 --- a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehaviorCommand.cs +++ b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Browser; -internal sealed class SetDownloadBehaviorCommand(SetDownloadBehaviorParameters @params) - : Command(@params, "browser.setDownloadBehavior"); - internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, IEnumerable? UserContexts) : Parameters; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/ActivateCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/BrowsingContext/ActivateCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs index da3ac83cbee08..d1e1311e02be6 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/ActivateCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class ActivateCommand(ActivateParameters @params) - : Command(@params, "browsingContext.activate"); - internal sealed record ActivateParameters(BrowsingContext Context) : Parameters; public sealed record ActivateOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index f9e8594995000..ba9a5a9d182d1 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -25,88 +25,124 @@ public sealed class BrowsingContextModule : Module, IBrowsingContextModule { private static readonly BrowsingContextJsonSerializerContext JsonContext = BrowsingContextJsonSerializerContext.Default; + private static readonly CommandDescriptor CreateCommand = new( + "browsingContext.create", JsonContext.CommandMessageCreateParameters, JsonContext.CreateResult); + + private static readonly CommandDescriptor NavigateCommand = new( + "browsingContext.navigate", JsonContext.CommandMessageNavigateParameters, JsonContext.NavigateResult); + + private static readonly CommandDescriptor ActivateCommand = new( + "browsingContext.activate", JsonContext.CommandMessageActivateParameters, JsonContext.ActivateResult); + + private static readonly CommandDescriptor LocateNodesCommand = new( + "browsingContext.locateNodes", JsonContext.CommandMessageLocateNodesParameters, JsonContext.LocateNodesResult); + + private static readonly CommandDescriptor CaptureScreenshotCommand = new( + "browsingContext.captureScreenshot", JsonContext.CommandMessageCaptureScreenshotParameters, JsonContext.CaptureScreenshotResult); + + private static readonly CommandDescriptor CloseCommand = new( + "browsingContext.close", JsonContext.CommandMessageCloseParameters, JsonContext.CloseResult); + + private static readonly CommandDescriptor TraverseHistoryCommand = new( + "browsingContext.traverseHistory", JsonContext.CommandMessageTraverseHistoryParameters, JsonContext.TraverseHistoryResult); + + private static readonly CommandDescriptor ReloadCommand = new( + "browsingContext.reload", JsonContext.CommandMessageReloadParameters, JsonContext.ReloadResult); + + private static readonly CommandDescriptor SetViewportCommand = new( + "browsingContext.setViewport", JsonContext.CommandMessageSetViewportParameters, JsonContext.SetViewportResult); + + private static readonly CommandDescriptor GetTreeCommand = new( + "browsingContext.getTree", JsonContext.CommandMessageGetTreeParameters, JsonContext.GetTreeResult); + + private static readonly CommandDescriptor PrintCommand = new( + "browsingContext.print", JsonContext.CommandMessagePrintParameters, JsonContext.PrintResult); + + private static readonly CommandDescriptor HandleUserPromptCommand = new( + "browsingContext.handleUserPrompt", JsonContext.CommandMessageHandleUserPromptParameters, JsonContext.HandleUserPromptResult); + public async Task CreateAsync(ContextType type, CreateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CreateParameters(type, options?.ReferenceContext, options?.Background, options?.UserContext); - return await ExecuteCommandAsync(new CreateCommand(@params), options, JsonContext.CreateCommand, JsonContext.CreateResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CreateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task NavigateAsync(BrowsingContext context, string url, NavigateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new NavigateParameters(context, url, options?.Wait); - return await ExecuteCommandAsync(new NavigateCommand(@params), options, JsonContext.NavigateCommand, JsonContext.NavigateResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(NavigateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ActivateAsync(BrowsingContext context, ActivateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ActivateParameters(context); - return await ExecuteCommandAsync(new ActivateCommand(@params), options, JsonContext.ActivateCommand, JsonContext.ActivateResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ActivateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task LocateNodesAsync(BrowsingContext context, Locator locator, LocateNodesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new LocateNodesParameters(context, locator, options?.MaxNodeCount, options?.SerializationOptions, options?.StartNodes); - return await ExecuteCommandAsync(new LocateNodesCommand(@params), options, JsonContext.LocateNodesCommand, JsonContext.LocateNodesResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(LocateNodesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CaptureScreenshotAsync(BrowsingContext context, CaptureScreenshotOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CaptureScreenshotParameters(context, options?.Origin, options?.Format, options?.Clip); - return await ExecuteCommandAsync(new CaptureScreenshotCommand(@params), options, JsonContext.CaptureScreenshotCommand, JsonContext.CaptureScreenshotResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CaptureScreenshotCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CloseAsync(BrowsingContext context, CloseOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CloseParameters(context, options?.PromptUnload); - return await ExecuteCommandAsync(new CloseCommand(@params), options, JsonContext.CloseCommand, JsonContext.CloseResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CloseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task TraverseHistoryAsync(BrowsingContext context, int delta, TraverseHistoryOptions? options = null, CancellationToken cancellationToken = default) { var @params = new TraverseHistoryParameters(context, delta); - return await ExecuteCommandAsync(new TraverseHistoryCommand(@params), options, JsonContext.TraverseHistoryCommand, JsonContext.TraverseHistoryResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(TraverseHistoryCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ReloadAsync(BrowsingContext context, ReloadOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ReloadParameters(context, options?.IgnoreCache, options?.Wait); - return await ExecuteCommandAsync(new ReloadCommand(@params), options, JsonContext.ReloadCommand, JsonContext.ReloadResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ReloadCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetViewportAsync(SetViewportOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetViewportParameters(options?.Context, options?.Viewport, options?.DevicePixelRatio, options?.UserContexts); - return await ExecuteCommandAsync(new SetViewportCommand(@params), options, JsonContext.SetViewportCommand, JsonContext.SetViewportResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetViewportCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetTreeAsync(GetTreeOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetTreeParameters(options?.MaxDepth, options?.Root); - return await ExecuteCommandAsync(new GetTreeCommand(@params), options, JsonContext.GetTreeCommand, JsonContext.GetTreeResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(GetTreeCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task PrintAsync(BrowsingContext context, PrintOptions? options = null, CancellationToken cancellationToken = default) { var @params = new PrintParameters(context, options?.Background, options?.Margin, options?.Orientation, options?.Page, options?.PageRanges, options?.Scale, options?.ShrinkToFit); - return await ExecuteCommandAsync(new PrintCommand(@params), options, JsonContext.PrintCommand, JsonContext.PrintResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(PrintCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new HandleUserPromptParameters(context, options?.Accept, options?.UserText); - return await ExecuteCommandAsync(new HandleUserPromptCommand(@params), options, JsonContext.HandleUserPromptCommand, JsonContext.HandleUserPromptResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(HandleUserPromptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationStartedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) @@ -283,29 +319,29 @@ public async Task OnUserPromptClosedAsync(Action new(bidi, p.Context, p.Accepted, p.Type, p.UserContext, p.UserText); } -[JsonSerializable(typeof(ActivateCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ActivateResult))] -[JsonSerializable(typeof(CaptureScreenshotCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(CaptureScreenshotResult))] -[JsonSerializable(typeof(CloseCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(CloseResult))] -[JsonSerializable(typeof(CreateCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(CreateResult))] -[JsonSerializable(typeof(GetTreeCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(GetTreeResult))] -[JsonSerializable(typeof(HandleUserPromptCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(HandleUserPromptResult))] -[JsonSerializable(typeof(LocateNodesCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(LocateNodesResult))] -[JsonSerializable(typeof(NavigateCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(NavigateResult))] -[JsonSerializable(typeof(PrintCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(PrintResult))] -[JsonSerializable(typeof(ReloadCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ReloadResult))] -[JsonSerializable(typeof(SetViewportCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetViewportResult))] -[JsonSerializable(typeof(TraverseHistoryCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(TraverseHistoryResult))] [JsonSerializable(typeof(DownloadWillBeginParams))] diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs index 3892d1dabad72..57dec7ead70a0 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshotCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class CaptureScreenshotCommand(CaptureScreenshotParameters @params) - : Command(@params, "browsingContext.captureScreenshot"); - internal sealed record CaptureScreenshotParameters(BrowsingContext Context, ScreenshotOrigin? Origin, ImageFormat? Format, ClipRectangle? Clip) : Parameters; public sealed record CaptureScreenshotOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/CloseCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/BrowsingContext/CloseCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs index 8283ff820594f..4e37eda2a190b 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/CloseCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class CloseCommand(CloseParameters @params) - : Command(@params, "browsingContext.close"); - internal sealed record CloseParameters(BrowsingContext Context, bool? PromptUnload) : Parameters; public sealed record CloseOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs index 762b07f9e2296..0f62971fecf9c 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class CreateCommand(CreateParameters @params) - : Command(@params, "browsingContext.create"); - internal sealed record CreateParameters(ContextType Type, BrowsingContext? ReferenceContext, bool? Background, Browser.UserContext? UserContext) : Parameters; public sealed record CreateOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs index c05cad1c33099..e43ea65359110 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class GetTreeCommand(GetTreeParameters @params) - : Command(@params, "browsingContext.getTree"); - internal sealed record GetTreeParameters(long? MaxDepth, BrowsingContext? Root) : Parameters; public sealed record GetTreeOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPromptCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPromptCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs index 3ed4c7f8ea1c0..667742010ef88 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPromptCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class HandleUserPromptCommand(HandleUserPromptParameters @params) - : Command(@params, "browsingContext.handleUserPrompt"); - internal sealed record HandleUserPromptParameters(BrowsingContext Context, bool? Accept, string? UserText) : Parameters; public sealed record HandleUserPromptOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs index 1d0937863cf74..df84e0be5d2d9 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodesCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class LocateNodesCommand(LocateNodesParameters @params) - : Command(@params, "browsingContext.locateNodes"); - internal sealed record LocateNodesParameters(BrowsingContext Context, Locator Locator, long? MaxNodeCount, Script.SerializationOptions? SerializationOptions, IEnumerable? StartNodes) : Parameters; public sealed record LocateNodesOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs index 6f7d07f584c6c..2a634bf5540df 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class NavigateCommand(NavigateParameters @params) - : Command(@params, "browsingContext.navigate"); - internal sealed record NavigateParameters(BrowsingContext Context, string Url, ReadinessState? Wait) : Parameters; public sealed record NavigateOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs similarity index 96% rename from dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs index c19a44a4d6711..6be3e07d3e583 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class PrintCommand(PrintParameters @params) - : Command(@params, "browsingContext.print"); - internal sealed record PrintParameters(BrowsingContext Context, bool? Background, PrintMargin? Margin, PrintOrientation? Orientation, PrintPage? Page, IEnumerable? PageRanges, double? Scale, bool? ShrinkToFit) : Parameters; public sealed record PrintOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/ReloadCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/BrowsingContext/ReloadCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs index 8eba10f9718fe..6bd17eda0b4a7 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/ReloadCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class ReloadCommand(ReloadParameters @params) - : Command(@params, "browsingContext.reload"); - internal sealed record ReloadParameters(BrowsingContext Context, bool? IgnoreCache, ReadinessState? Wait) : Parameters; public sealed record ReloadOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewportCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs similarity index 93% rename from dotnet/src/webdriver/BiDi/BrowsingContext/SetViewportCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs index bc7d146ea4a4f..ec56d99a3c18d 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewportCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class SetViewportCommand(SetViewportParameters @params) - : Command(@params, "browsingContext.setViewport"); - internal sealed record SetViewportParameters( BrowsingContext? Context, [property: JsonConverter(typeof(OptionalConverter))] Optional? Viewport, diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistoryCommand.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistoryCommand.cs rename to dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs index 2eaaf6bf3c0e2..bfe712436cf11 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistoryCommand.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -internal sealed class TraverseHistoryCommand(TraverseHistoryParameters @params) - : Command(@params, "browsingContext.traverseHistory"); - internal sealed record TraverseHistoryParameters(BrowsingContext Context, long Delta) : Parameters; public sealed record TraverseHistoryOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index edd887fdc6aaa..3d6dec5134377 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -18,29 +18,32 @@ // using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; namespace OpenQA.Selenium.BiDi; -public abstract class Command +internal readonly struct CommandMessage where TParameters : Parameters { - protected Command(string method) - { - Method = method; - } + [JsonPropertyOrder(0)] + public long Id { get; init; } [JsonPropertyOrder(1)] - public string Method { get; } + public string Method { get; init; } - [JsonPropertyOrder(0)] - public long Id { get; internal set; } + [JsonPropertyOrder(2)] + public TParameters Params { get; init; } } -public abstract class Command(TParameters @params, string method) : Command(method) +internal sealed class CommandDescriptor( + string method, + JsonTypeInfo> commandTypeInfo, + JsonTypeInfo resultTypeInfo) where TParameters : Parameters where TResult : EmptyResult { - [JsonPropertyOrder(2)] - public TParameters Params { get; } = @params; + public string Method { get; } = method; + public JsonTypeInfo> CommandTypeInfo { get; } = commandTypeInfo; + public JsonTypeInfo ResultTypeInfo { get; } = resultTypeInfo; } public record Parameters diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 62bf618ad1894..faff4457e0a4c 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -25,121 +25,140 @@ public sealed class EmulationModule : Module, IEmulationModule { private static readonly EmulationJsonSerializerContext JsonContext = EmulationJsonSerializerContext.Default; + private static readonly CommandDescriptor SetTimezoneOverrideCommand = new( + "emulation.setTimezoneOverride", JsonContext.CommandMessageSetTimezoneOverrideParameters, JsonContext.SetTimezoneOverrideResult); + + private static readonly CommandDescriptor SetUserAgentOverrideCommand = new( + "emulation.setUserAgentOverride", JsonContext.CommandMessageSetUserAgentOverrideParameters, JsonContext.SetUserAgentOverrideResult); + + private static readonly CommandDescriptor SetLocaleOverrideCommand = new( + "emulation.setLocaleOverride", JsonContext.CommandMessageSetLocaleOverrideParameters, JsonContext.SetLocaleOverrideResult); + + private static readonly CommandDescriptor SetForcedColorsModeThemeOverrideCommand = new( + "emulation.setForcedColorsModeThemeOverride", JsonContext.CommandMessageSetForcedColorsModeThemeOverrideParameters, JsonContext.SetForcedColorsModeThemeOverrideResult); + + private static readonly CommandDescriptor SetScriptingEnabledCommand = new( + "emulation.setScriptingEnabled", JsonContext.CommandMessageSetScriptingEnabledParameters, JsonContext.SetScriptingEnabledResult); + + private static readonly CommandDescriptor SetScreenOrientationOverrideCommand = new( + "emulation.setScreenOrientationOverride", JsonContext.CommandMessageSetScreenOrientationOverrideParameters, JsonContext.SetScreenOrientationOverrideResult); + + private static readonly CommandDescriptor SetScreenSettingsOverrideCommand = new( + "emulation.setScreenSettingsOverride", JsonContext.CommandMessageSetScreenSettingsOverrideParameters, JsonContext.SetScreenSettingsOverrideResult); + + private static readonly CommandDescriptor SetScrollbarTypeOverrideCommand = new( + "emulation.setScrollbarTypeOverride", JsonContext.CommandMessageSetScrollbarTypeOverrideParameters, JsonContext.SetScrollbarTypeOverrideResult); + + private static readonly CommandDescriptor SetGeolocationOverrideCommand = new( + "emulation.setGeolocationOverride", JsonContext.CommandMessageSetGeolocationOverrideParameters, JsonContext.SetGeolocationOverrideResult); + + private static readonly CommandDescriptor SetTouchOverrideCommand = new( + "emulation.setTouchOverride", JsonContext.CommandMessageSetTouchOverrideParameters, JsonContext.SetTouchOverrideResult); + + private static readonly CommandDescriptor SetNetworkConditionsCommand = new( + "emulation.setNetworkConditions", JsonContext.CommandMessageSetNetworkConditionsParameters, JsonContext.SetNetworkConditionsResult); + public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetTimezoneOverrideParameters(timezone, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetTimezoneOverrideCommand(@params), options, JsonContext.SetTimezoneOverrideCommand, JsonContext.SetTimezoneOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetTimezoneOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetUserAgentOverrideAsync(string? userAgent, SetUserAgentOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetUserAgentOverrideParameters(userAgent, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetUserAgentOverrideCommand(@params), options, JsonContext.SetUserAgentOverrideCommand, JsonContext.SetUserAgentOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetUserAgentOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetLocaleOverrideAsync(string? locale, SetLocaleOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetLocaleOverrideParameters(locale, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetLocaleOverrideCommand(@params), options, JsonContext.SetLocaleOverrideCommand, JsonContext.SetLocaleOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetLocaleOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme? theme, SetForcedColorsModeThemeOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetForcedColorsModeThemeOverrideParameters(theme, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetForcedColorsModeThemeOverrideCommand(@params), options, JsonContext.SetForcedColorsModeThemeOverrideCommand, JsonContext.SetForcedColorsModeThemeOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetForcedColorsModeThemeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScriptingEnabledAsync(bool? enabled, SetScriptingEnabledOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScriptingEnabledParameters(enabled, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetScriptingEnabledCommand(@params), options, JsonContext.SetScriptingEnabledCommand, JsonContext.SetScriptingEnabledResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetScriptingEnabledCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScreenOrientationOverrideAsync(ScreenOrientation? screenOrientation, SetScreenOrientationOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScreenOrientationOverrideParameters(screenOrientation, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetScreenOrientationOverrideCommand(@params), options, JsonContext.SetScreenOrientationOverrideCommand, JsonContext.SetScreenOrientationOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetScreenOrientationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScreenSettingsOverrideAsync(ScreenArea? screenArea, SetScreenSettingsOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScreenSettingsOverrideParameters(screenArea, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetScreenSettingsOverrideCommand(@params), options, JsonContext.SetScreenSettingsOverrideCommand, JsonContext.SetScreenSettingsOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetScreenSettingsOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScrollbarTypeOverrideAsync(ScrollbarType? scrollbarType, SetScrollbarTypeOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScrollbarTypeOverrideParameters(scrollbarType, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetScrollbarTypeOverrideCommand(@params), options, JsonContext.SetScrollbarTypeOverrideCommand, JsonContext.SetScrollbarTypeOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetScrollbarTypeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationCoordinatesOverrideAsync(double latitude, double longitude, SetGeolocationCoordinatesOverrideOptions? options = null, CancellationToken cancellationToken = default) { var coordinates = new GeolocationCoordinates(latitude, longitude, options?.Accuracy, options?.Altitude, options?.AltitudeAccuracy, options?.Heading, options?.Speed); - var @params = new SetGeolocationOverrideCoordinatesParameters(coordinates, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationCoordinatesOverrideAsync(SetGeolocationOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetGeolocationOverrideCoordinatesParameters(null, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationPositionErrorOverrideAsync(SetGeolocationPositionErrorOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetGeolocationOverridePositionErrorParameters(new GeolocationPositionError(), options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetTouchOverrideAsync(long? maxTouchPoints, SetTouchOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetTouchOverrideParameters(maxTouchPoints, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetTouchOverrideCommand(@params), options, JsonContext.SetTouchOverrideCommand, JsonContext.SetTouchOverrideResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetTouchOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetNetworkConditionsAsync(NetworkConditions? networkConditions, SetNetworkConditionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetNetworkConditionsParameters(networkConditions, options?.Contexts, options?.UserContexts); - - return await ExecuteCommandAsync(new SetNetworkConditionsCommand(@params), options, JsonContext.SetNetworkConditionsCommand, JsonContext.SetNetworkConditionsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetNetworkConditionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(SetTimezoneOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetTimezoneOverrideResult))] -[JsonSerializable(typeof(SetUserAgentOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetUserAgentOverrideResult))] -[JsonSerializable(typeof(SetLocaleOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetLocaleOverrideResult))] -[JsonSerializable(typeof(SetForcedColorsModeThemeOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetForcedColorsModeThemeOverrideResult))] -[JsonSerializable(typeof(SetScriptingEnabledCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetScriptingEnabledResult))] -[JsonSerializable(typeof(SetScreenOrientationOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetScreenOrientationOverrideResult))] -[JsonSerializable(typeof(SetScreenSettingsOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetScreenSettingsOverrideResult))] -[JsonSerializable(typeof(SetScrollbarTypeOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetScrollbarTypeOverrideResult))] -[JsonSerializable(typeof(SetGeolocationOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetGeolocationOverrideResult))] -[JsonSerializable(typeof(SetTouchOverrideCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetTouchOverrideResult))] -[JsonSerializable(typeof(SetNetworkConditionsCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetNetworkConditionsResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs index d743fce658ce3..770c2c2143c49 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetForcedColorsModeThemeOverrideCommand(SetForcedColorsModeThemeOverrideParameters @params) - : Command(@params, "emulation.setForcedColorsModeThemeOverride"); - internal sealed record SetForcedColorsModeThemeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ForcedColorsModeTheme? Theme, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetForcedColorsModeThemeOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs similarity index 93% rename from dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs index 153f291c9a5c2..b0f6f77944477 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetGeolocationOverrideCommand(SetGeolocationOverrideParameters @params) - : Command(@params, "emulation.setGeolocationOverride"); - [JsonDerivedType(typeof(SetGeolocationOverrideCoordinatesParameters))] [JsonDerivedType(typeof(SetGeolocationOverridePositionErrorParameters))] internal abstract record SetGeolocationOverrideParameters(IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs index 112fa0be6807c..f241fe6471fae 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetLocaleOverrideCommand(SetLocaleOverrideParameters @params) - : Command(@params, "emulation.setLocaleOverride"); - internal sealed record SetLocaleOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Locale, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetLocaleOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditionsCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditionsCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs index d29d16a670db3..c8fdd98c5ac1a 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditionsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetNetworkConditionsCommand(SetNetworkConditionsParameters @params) - : Command(@params, "emulation.setNetworkConditions"); - internal sealed record SetNetworkConditionsParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] NetworkConditions? NetworkConditions, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs index e839b487d8fcc..d49cb5e35dfd3 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetScreenOrientationOverrideCommand(SetScreenOrientationOverrideParameters @params) - : Command(@params, "emulation.setScreenOrientationOverride"); - internal sealed record SetScreenOrientationOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenOrientation? ScreenOrientation, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetScreenOrientationOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs index 7e181c8f6881d..a5df7bcda9143 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetScreenSettingsOverrideCommand(SetScreenSettingsOverrideParameters @params) - : Command(@params, "emulation.setScreenSettingsOverride"); - internal sealed record SetScreenSettingsOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScreenArea? ScreenArea, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetScreenSettingsOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs index f5255916b0264..723c6ddaf1ba7 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabledCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetScriptingEnabledCommand(SetScriptingEnabledParameters @params) - : Command(@params, "emulation.setScriptingEnabled"); - internal sealed record SetScriptingEnabledParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] bool? Enabled, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetScriptingEnabledOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs index 190d2411edbfc..810816d495897 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetScrollbarTypeOverrideCommand(SetScrollbarTypeOverrideParameters @params) - : Command(@params, "emulation.setScrollbarTypeOverride"); - internal sealed record SetScrollbarTypeOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] ScrollbarType? ScrollbarType, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetScrollbarTypeOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs index 8028b360bf552..a08599b90987b 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetTimezoneOverrideCommand(SetTimezoneOverrideParameters @params) - : Command(@params, "emulation.setTimezoneOverride"); - internal sealed record SetTimezoneOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? Timezone, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetTimezoneOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Emulation/SetTouchOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs index 259579efc4954..93db85bf586ad 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetTouchOverrideCommand(SetTouchOverrideParameters @params) - : Command(@params, "emulation.setTouchOverride"); - internal sealed record SetTouchOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] long? MaxTouchPoints, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetTouchOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs rename to dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs index a3164159843ee..c5e0a878a4dc4 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverrideCommand.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Emulation; -internal sealed class SetUserAgentOverrideCommand(SetUserAgentOverrideParameters @params) - : Command(@params, "emulation.setUserAgentOverride"); - internal sealed record SetUserAgentOverrideParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] string? UserAgent, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetUserAgentOverrideOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index c484d8b2b7830..db024499b467f 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -25,25 +25,34 @@ public sealed class InputModule : Module, IInputModule { private static readonly InputJsonSerializerContext JsonContext = InputJsonSerializerContext.Default; + private static readonly CommandDescriptor PerformActionsCommand = new( + "input.performActions", JsonContext.CommandMessagePerformActionsParameters, JsonContext.PerformActionsResult); + + private static readonly CommandDescriptor ReleaseActionsCommand = new( + "input.releaseActions", JsonContext.CommandMessageReleaseActionsParameters, JsonContext.ReleaseActionsResult); + + private static readonly CommandDescriptor SetFilesCommand = new( + "input.setFiles", JsonContext.CommandMessageSetFilesParameters, JsonContext.SetFilesResult); + public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new PerformActionsParameters(context, actions); - return await ExecuteCommandAsync(new PerformActionsCommand(@params), options, JsonContext.PerformActionsCommand, JsonContext.PerformActionsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(PerformActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ReleaseActionsAsync(BrowsingContext.BrowsingContext context, ReleaseActionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ReleaseActionsParameters(context); - return await ExecuteCommandAsync(new ReleaseActionsCommand(@params), options, JsonContext.ReleaseActionsCommand, JsonContext.ReleaseActionsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ReleaseActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetFilesParameters(context, element, files); - return await ExecuteCommandAsync(new SetFilesCommand(@params), options, JsonContext.SetFilesCommand, JsonContext.SetFilesResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetFilesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnFileDialogOpenedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) @@ -62,11 +71,11 @@ private static FileDialogOpenedEventArgs CreateFileDialogOpenedEventArgs(IBiDi b } } -[JsonSerializable(typeof(PerformActionsCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(PerformActionsResult))] -[JsonSerializable(typeof(ReleaseActionsCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ReleaseActionsResult))] -[JsonSerializable(typeof(SetFilesCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetFilesResult))] [JsonSerializable(typeof(FileDialogInfo))] diff --git a/dotnet/src/webdriver/BiDi/Input/PerformActionsCommand.cs b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/Input/PerformActionsCommand.cs rename to dotnet/src/webdriver/BiDi/Input/PerformActions.cs index 33e6d27076930..86117875cd643 100644 --- a/dotnet/src/webdriver/BiDi/Input/PerformActionsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Input; -internal sealed class PerformActionsCommand(PerformActionsParameters @params) - : Command(@params, "input.performActions"); - internal sealed record PerformActionsParameters(BrowsingContext.BrowsingContext Context, IEnumerable Actions) : Parameters; public sealed record PerformActionsOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Input/ReleaseActionsCommand.cs b/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/Input/ReleaseActionsCommand.cs rename to dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs index b62ea69ccaa12..9bc773dc1aa0d 100644 --- a/dotnet/src/webdriver/BiDi/Input/ReleaseActionsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Input; -internal sealed class ReleaseActionsCommand(ReleaseActionsParameters @params) - : Command(@params, "input.releaseActions"); - internal sealed record ReleaseActionsParameters(BrowsingContext.BrowsingContext Context) : Parameters; public sealed record ReleaseActionsOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Input/SetFilesCommand.cs b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Input/SetFilesCommand.cs rename to dotnet/src/webdriver/BiDi/Input/SetFiles.cs index a20c43556db08..2a4b0b9fa6d9c 100644 --- a/dotnet/src/webdriver/BiDi/Input/SetFilesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Input; -internal sealed class SetFilesCommand(SetFilesParameters @params) - : Command(@params, "input.setFiles"); - internal sealed record SetFilesParameters(BrowsingContext.BrowsingContext Context, Script.ISharedReference Element, IEnumerable Files) : Parameters; public sealed record SetFilesOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index 52da371035eaa..f6c7839199ec1 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -25,11 +25,11 @@ public abstract class Module { private Broker Broker { get; set; } = null!; - protected Task ExecuteCommandAsync(TCommand command, CommandOptions? options, JsonTypeInfo jsonCommandTypeInfo, JsonTypeInfo jsonResultTypeInfo, CancellationToken cancellationToken) - where TCommand : Command + private protected Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + where TParameters : Parameters where TResult : EmptyResult { - return Broker.ExecuteCommandAsync(command, options, jsonCommandTypeInfo, jsonResultTypeInfo, cancellationToken); + return Broker.ExecuteCommandAsync(descriptor, @params, options, cancellationToken); } protected Task SubscribeAsync(string name, Action action, Func factory, SubscriptionOptions? options, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) diff --git a/dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs rename to dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs index 67ab52c1aa405..f1b74035d037e 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class AddDataCollectorCommand(AddDataCollectorParameters @params) - : Command(@params, "network.addDataCollector"); - internal sealed record AddDataCollectorParameters(IEnumerable DataTypes, int MaxEncodedDataSize, CollectorType? CollectorType, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record AddDataCollectorOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/AddInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Network/AddInterceptCommand.cs rename to dotnet/src/webdriver/BiDi/Network/AddIntercept.cs index d5dddb03b07dc..56fba53e233b2 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class AddInterceptCommand(AddInterceptParameters @params) - : Command(@params, "network.addIntercept"); - internal sealed record AddInterceptParameters(IEnumerable Phases, IEnumerable? Contexts, IEnumerable? UrlPatterns) : Parameters; public record AddInterceptOptions() : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueRequestCommand.cs b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Network/ContinueRequestCommand.cs rename to dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs index 1fa5246363236..98873bd0e9dcd 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueRequestCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class ContinueRequestCommand(ContinueRequestParameters @params) - : Command(@params, "network.continueRequest"); - internal sealed record ContinueRequestParameters(Request Request, BytesValue? Body, IEnumerable? Cookies, IEnumerable
? Headers, string? Method, string? Url) : Parameters; public sealed record ContinueRequestOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueResponseCommand.cs b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Network/ContinueResponseCommand.cs rename to dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs index 797cdaeb012f9..9bbee6591ff6d 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueResponseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class ContinueResponseCommand(ContinueResponseParameters @params) - : Command(@params, "network.continueResponse"); - internal sealed record ContinueResponseParameters(Request Request, IEnumerable? Cookies, IEnumerable? Credentials, IEnumerable
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; public sealed record ContinueResponseOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueWithAuthCommand.cs b/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Network/ContinueWithAuthCommand.cs rename to dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs index b83a529ae26aa..e1164eb25da39 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueWithAuthCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal class ContinueWithAuthCommand(ContinueWithAuthParameters @params) - : Command(@params, "network.continueWithAuth"); - [JsonPolymorphic(TypeDiscriminatorPropertyName = "action")] [JsonDerivedType(typeof(ContinueWithAuthCredentials), "provideCredentials")] [JsonDerivedType(typeof(ContinueWithAuthDefaultCredentials), "default")] diff --git a/dotnet/src/webdriver/BiDi/Network/FailRequestCommand.cs b/dotnet/src/webdriver/BiDi/Network/FailRequest.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/Network/FailRequestCommand.cs rename to dotnet/src/webdriver/BiDi/Network/FailRequest.cs index 721c6135af0cd..f603ac955b41a 100644 --- a/dotnet/src/webdriver/BiDi/Network/FailRequestCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/FailRequest.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class FailRequestCommand(FailRequestParameters @params) - : Command(@params, "network.failRequest"); - internal sealed record FailRequestParameters(Request Request) : Parameters; public sealed record FailRequestOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Network/GetDataCommand.cs b/dotnet/src/webdriver/BiDi/Network/GetData.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Network/GetDataCommand.cs rename to dotnet/src/webdriver/BiDi/Network/GetData.cs index 04aee9ef6b7fb..c0d0f3344420f 100644 --- a/dotnet/src/webdriver/BiDi/Network/GetDataCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/GetData.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class GetDataCommand(GetDataParameters @params) - : Command(@params, "network.getData"); - internal sealed record GetDataParameters(DataType DataType, Request Request, Collector? Collector, bool? Disown) : Parameters; public sealed record GetDataOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 72c7a213b0ab3..3326bc959fc39 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -25,74 +25,110 @@ public sealed partial class NetworkModule : Module, INetworkModule { private static readonly NetworkJsonSerializerContext JsonContext = NetworkJsonSerializerContext.Default; + private static readonly CommandDescriptor AddDataCollectorCommand = new( + "network.addDataCollector", JsonContext.CommandMessageAddDataCollectorParameters, JsonContext.AddDataCollectorResult); + + private static readonly CommandDescriptor AddInterceptCommand = new( + "network.addIntercept", JsonContext.CommandMessageAddInterceptParameters, JsonContext.AddInterceptResult); + + private static readonly CommandDescriptor RemoveDataCollectorCommand = new( + "network.removeDataCollector", JsonContext.CommandMessageRemoveDataCollectorParameters, JsonContext.RemoveDataCollectorResult); + + private static readonly CommandDescriptor RemoveInterceptCommand = new( + "network.removeIntercept", JsonContext.CommandMessageRemoveInterceptParameters, JsonContext.RemoveInterceptResult); + + private static readonly CommandDescriptor SetCacheBehaviorCommand = new( + "network.setCacheBehavior", JsonContext.CommandMessageSetCacheBehaviorParameters, JsonContext.SetCacheBehaviorResult); + + private static readonly CommandDescriptor SetExtraHeadersCommand = new( + "network.setExtraHeaders", JsonContext.CommandMessageSetExtraHeadersParameters, JsonContext.SetExtraHeadersResult); + + private static readonly CommandDescriptor ContinueRequestCommand = new( + "network.continueRequest", JsonContext.CommandMessageContinueRequestParameters, JsonContext.ContinueRequestResult); + + private static readonly CommandDescriptor ContinueResponseCommand = new( + "network.continueResponse", JsonContext.CommandMessageContinueResponseParameters, JsonContext.ContinueResponseResult); + + private static readonly CommandDescriptor FailRequestCommand = new( + "network.failRequest", JsonContext.CommandMessageFailRequestParameters, JsonContext.FailRequestResult); + + private static readonly CommandDescriptor GetDataCommand = new( + "network.getData", JsonContext.CommandMessageGetDataParameters, JsonContext.GetDataResult); + + private static readonly CommandDescriptor ProvideResponseCommand = new( + "network.provideResponse", JsonContext.CommandMessageProvideResponseParameters, JsonContext.ProvideResponseResult); + + private static readonly CommandDescriptor ContinueWithAuthCommand = new( + "network.continueWithAuth", JsonContext.CommandMessageContinueWithAuthParameters, JsonContext.ContinueWithAuthResult); + public async Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddDataCollectorParameters(dataTypes, maxEncodedDataSize, options?.CollectorType, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(new AddDataCollectorCommand(@params), options, JsonContext.AddDataCollectorCommand, JsonContext.AddDataCollectorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(AddDataCollectorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task AddInterceptAsync(IEnumerable phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddInterceptParameters(phases, options?.Contexts, options?.UrlPatterns); - return await ExecuteCommandAsync(new AddInterceptCommand(@params), options, JsonContext.AddInterceptCommand, JsonContext.AddInterceptResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(AddInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveDataCollectorAsync(Collector collector, RemoveDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveDataCollectorParameters(collector); - return await ExecuteCommandAsync(new RemoveDataCollectorCommand(@params), options, JsonContext.RemoveDataCollectorCommand, JsonContext.RemoveDataCollectorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(RemoveDataCollectorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveInterceptAsync(Intercept intercept, RemoveInterceptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveInterceptParameters(intercept); - return await ExecuteCommandAsync(new RemoveInterceptCommand(@params), options, JsonContext.RemoveInterceptCommand, JsonContext.RemoveInterceptResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(RemoveInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetCacheBehaviorAsync(CacheBehavior behavior, SetCacheBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetCacheBehaviorParameters(behavior, options?.Contexts); - return await ExecuteCommandAsync(new SetCacheBehaviorCommand(@params), options, JsonContext.SetCacheBehaviorCommand, JsonContext.SetCacheBehaviorResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetCacheBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetExtraHeadersAsync(IEnumerable
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetExtraHeadersParameters(headers, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(new SetExtraHeadersCommand(@params), options, JsonContext.SetExtraHeadersCommand, JsonContext.SetExtraHeadersResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetExtraHeadersCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueRequestAsync(Request request, ContinueRequestOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ContinueRequestParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.Method, options?.Url); - return await ExecuteCommandAsync(new ContinueRequestCommand(@params), options, JsonContext.ContinueRequestCommand, JsonContext.ContinueRequestResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ContinueRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueResponseAsync(Request request, ContinueResponseOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ContinueResponseParameters(request, options?.Cookies, options?.Credentials, options?.Headers, options?.ReasonPhrase, options?.StatusCode); - return await ExecuteCommandAsync(new ContinueResponseCommand(@params), options, JsonContext.ContinueResponseCommand, JsonContext.ContinueResponseResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ContinueResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task FailRequestAsync(Request request, FailRequestOptions? options = null, CancellationToken cancellationToken = default) { var @params = new FailRequestParameters(request); - return await ExecuteCommandAsync(new FailRequestCommand(@params), options, JsonContext.FailRequestCommand, JsonContext.FailRequestResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(FailRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetDataAsync(DataType dataType, Request request, GetDataOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetDataParameters(dataType, request, options?.Collector, options?.Disown); - var result = await ExecuteCommandAsync(new GetDataCommand(@params), options, JsonContext.GetDataCommand, JsonContext.GetDataResult, cancellationToken).ConfigureAwait(false); + var result = await ExecuteCommandAsync(GetDataCommand, @params, options, cancellationToken).ConfigureAwait(false); return result.Bytes; } @@ -101,22 +137,22 @@ public async Task ProvideResponseAsync(Request request, P { var @params = new ProvideResponseParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.ReasonPhrase, options?.StatusCode); - return await ExecuteCommandAsync(new ProvideResponseCommand(@params), options, JsonContext.ProvideResponseCommand, JsonContext.ProvideResponseResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ProvideResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCredentials(request, credentials)), options, JsonContext.ContinueWithAuthCommand, JsonContext.ContinueWithAuthResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthCredentials(request, credentials), options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, ContinueWithAuthDefaultCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthDefaultCredentials(request)), options, JsonContext.ContinueWithAuthCommand, JsonContext.ContinueWithAuthResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthDefaultCredentials(request), options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, ContinueWithAuthCancelCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCancelCredentials(request)), options, JsonContext.ContinueWithAuthCommand, JsonContext.ContinueWithAuthResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthCancelCredentials(request), options, cancellationToken).ConfigureAwait(false); } public async Task OnBeforeRequestSentAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) @@ -185,29 +221,29 @@ private static AuthRequiredEventArgs CreateAuthRequiredEventArgs(IBiDi bidi, Aut => new(bidi, p.Context, p.IsBlocked, p.Navigation, p.RedirectCount, p.Request, p.Timestamp, p.UserContext, p.Intercepts, p.Response); } -[JsonSerializable(typeof(AddDataCollectorCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(AddDataCollectorResult))] -[JsonSerializable(typeof(AddInterceptCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(AddInterceptResult))] -[JsonSerializable(typeof(ContinueRequestCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ContinueRequestResult))] -[JsonSerializable(typeof(ContinueResponseCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ContinueResponseResult))] -[JsonSerializable(typeof(ContinueWithAuthCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ContinueWithAuthResult))] -[JsonSerializable(typeof(FailRequestCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(FailRequestResult))] -[JsonSerializable(typeof(GetDataCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(GetDataResult))] -[JsonSerializable(typeof(ProvideResponseCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(ProvideResponseResult))] -[JsonSerializable(typeof(RemoveDataCollectorCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(RemoveDataCollectorResult))] -[JsonSerializable(typeof(RemoveInterceptCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(RemoveInterceptResult))] -[JsonSerializable(typeof(SetCacheBehaviorCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetCacheBehaviorResult))] -[JsonSerializable(typeof(SetExtraHeadersCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetExtraHeadersResult))] [JsonSerializable(typeof(BeforeRequestSentParameters))] diff --git a/dotnet/src/webdriver/BiDi/Network/ProvideResponseCommand.cs b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Network/ProvideResponseCommand.cs rename to dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs index fabf681145a52..43a89dc6ed69d 100644 --- a/dotnet/src/webdriver/BiDi/Network/ProvideResponseCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class ProvideResponseCommand(ProvideResponseParameters @params) - : Command(@params, "network.provideResponse"); - internal sealed record ProvideResponseParameters(Request Request, BytesValue? Body, IEnumerable? Cookies, IEnumerable
? Headers, string? ReasonPhrase, long? StatusCode) : Parameters; public sealed record ProvideResponseOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/RemoveDataCollectorCommand.cs b/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs similarity index 85% rename from dotnet/src/webdriver/BiDi/Network/RemoveDataCollectorCommand.cs rename to dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs index 13540ad13af22..605539193b7ab 100644 --- a/dotnet/src/webdriver/BiDi/Network/RemoveDataCollectorCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class RemoveDataCollectorCommand(RemoveDataCollectorParameters @params) - : Command(@params, "network.removeDataCollector"); - internal sealed record RemoveDataCollectorParameters(Collector Collector) : Parameters; public record RemoveDataCollectorOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Network/RemoveInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/Network/RemoveInterceptCommand.cs rename to dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs index e2ce91fac6125..03f0df6757536 100644 --- a/dotnet/src/webdriver/BiDi/Network/RemoveInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class RemoveInterceptCommand(RemoveInterceptParameters @params) - : Command(@params, "network.removeIntercept"); - internal sealed record RemoveInterceptParameters(Intercept Intercept) : Parameters; public record RemoveInterceptOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Network/SetCacheBehaviorCommand.cs b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Network/SetCacheBehaviorCommand.cs rename to dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs index d79c1ff40a088..5c67a6e7812f3 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetCacheBehaviorCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class SetCacheBehaviorCommand(SetCacheBehaviorParameters @params) - : Command(@params, "network.setCacheBehavior"); - internal sealed record SetCacheBehaviorParameters(CacheBehavior CacheBehavior, IEnumerable? Contexts) : Parameters; public sealed record SetCacheBehaviorOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Network/SetExtraHeadersCommand.cs b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Network/SetExtraHeadersCommand.cs rename to dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs index 70053a10f5b93..3003d0f1a3d18 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetExtraHeadersCommand.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Network; -internal sealed class SetExtraHeadersCommand(SetExtraHeadersParameters @params) - : Command(@params, "network.setExtraHeaders"); - internal sealed record SetExtraHeadersParameters(IEnumerable
Headers, IEnumerable? Contexts, IEnumerable? UserContexts) : Parameters; public sealed record SetExtraHeadersOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index a26813e13b30f..8d36981dfafc8 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -25,15 +25,18 @@ public sealed class PermissionsModule : Module, IPermissionsModule { private static readonly PermissionsJsonSerializerContext JsonContext = PermissionsJsonSerializerContext.Default; + private static readonly CommandDescriptor SetPermissionCommand = new( + "permissions.setPermission", JsonContext.CommandMessageSetPermissionCommandParameters, JsonContext.SetPermissionResult); + public async Task SetPermissionAsync(PermissionDescriptor descriptor, PermissionState state, string origin, SetPermissionOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetPermissionCommandParameters(descriptor, state, origin, options?.EmbeddedOrigin, options?.UserContext); - return await ExecuteCommandAsync(new SetPermissionCommand(@params), options, JsonContext.SetPermissionCommand, JsonContext.SetPermissionResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetPermissionCommand, @params, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(SetPermissionCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetPermissionResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs b/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs similarity index 88% rename from dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs rename to dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs index 12d327449e639..a95953983456d 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/SetPermissionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Permissions; -internal class SetPermissionCommand(SetPermissionCommandParameters @params) - : Command(@params, "permissions.setPermission"); - internal record SetPermissionCommandParameters(PermissionDescriptor Descriptor, PermissionState State, string Origin, string? EmbeddedOrigin, UserContext? UserContext) : Parameters; public record SetPermissionOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Script/AddPreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Script/AddPreloadScriptCommand.cs rename to dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs index 40c0f7d830a21..fa9acd9bddf23 100644 --- a/dotnet/src/webdriver/BiDi/Script/AddPreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class AddPreloadScriptCommand(AddPreloadScriptParameters @params) - : Command(@params, "script.addPreloadScript"); - internal sealed record AddPreloadScriptParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, IEnumerable? Arguments, IEnumerable? Contexts, IEnumerable? UserContexts, string? Sandbox) : Parameters; public sealed record AddPreloadScriptOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Script/CallFunctionCommand.cs b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/Script/CallFunctionCommand.cs rename to dotnet/src/webdriver/BiDi/Script/CallFunction.cs index 333e5aed00178..30375fab9b1e7 100644 --- a/dotnet/src/webdriver/BiDi/Script/CallFunctionCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class CallFunctionCommand(CallFunctionParameters @params) - : Command(@params, "script.callFunction"); - internal sealed record CallFunctionParameters([StringSyntax(StringSyntaxConstants.JavaScript)] string FunctionDeclaration, bool AwaitPromise, Target Target, IEnumerable? Arguments, ResultOwnership? ResultOwnership, SerializationOptions? SerializationOptions, LocalValue? This, bool? UserActivation) : Parameters; public sealed record CallFunctionOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Script/DisownCommand.cs b/dotnet/src/webdriver/BiDi/Script/Disown.cs similarity index 89% rename from dotnet/src/webdriver/BiDi/Script/DisownCommand.cs rename to dotnet/src/webdriver/BiDi/Script/Disown.cs index 3d3115eaa625a..1d6e9b8cb9992 100644 --- a/dotnet/src/webdriver/BiDi/Script/DisownCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/Disown.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class DisownCommand(DisownParameters @params) - : Command(@params, "script.disown"); - internal sealed record DisownParameters(IEnumerable Handles, Target Target) : Parameters; public sealed record DisownOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs b/dotnet/src/webdriver/BiDi/Script/Evaluate.cs similarity index 95% rename from dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs rename to dotnet/src/webdriver/BiDi/Script/Evaluate.cs index 0f7488eae03df..ccbbbaba28757 100644 --- a/dotnet/src/webdriver/BiDi/Script/EvaluateCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/Evaluate.cs @@ -23,9 +23,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class EvaluateCommand(EvaluateParameters @params) - : Command(@params, "script.evaluate"); - internal sealed record EvaluateParameters( string Expression, Target Target, diff --git a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs rename to dotnet/src/webdriver/BiDi/Script/GetRealms.cs index 859cb67af6257..2a8046b4fa0e0 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealmsCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class GetRealmsCommand(GetRealmsParameters @params) - : Command(@params, "script.getRealms"); - internal sealed record GetRealmsParameters(BrowsingContext.BrowsingContext? Context, RealmType? Type) : Parameters; public sealed record GetRealmsOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Script/RemovePreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs similarity index 85% rename from dotnet/src/webdriver/BiDi/Script/RemovePreloadScriptCommand.cs rename to dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs index 373dba23d22ac..d1d210d08861c 100644 --- a/dotnet/src/webdriver/BiDi/Script/RemovePreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Script; -internal sealed class RemovePreloadScriptCommand(RemovePreloadScriptParameters @params) - : Command(@params, "script.removePreloadScript"); - internal sealed record RemovePreloadScriptParameters(PreloadScript Script) : Parameters; public sealed record RemovePreloadScriptOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index fc41339d25b4c..7f4ae03dbd050 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -26,11 +26,29 @@ public sealed class ScriptModule : Module, IScriptModule { private static readonly ScriptJsonSerializerContext JsonContext = ScriptJsonSerializerContext.Default; + private static readonly CommandDescriptor EvaluateCommand = new( + "script.evaluate", JsonContext.CommandMessageEvaluateParameters, JsonContext.EvaluateResult); + + private static readonly CommandDescriptor CallFunctionCommand = new( + "script.callFunction", JsonContext.CommandMessageCallFunctionParameters, JsonContext.EvaluateResult); + + private static readonly CommandDescriptor DisownCommand = new( + "script.disown", JsonContext.CommandMessageDisownParameters, JsonContext.DisownResult); + + private static readonly CommandDescriptor GetRealmsCommand = new( + "script.getRealms", JsonContext.CommandMessageGetRealmsParameters, JsonContext.GetRealmsResult); + + private static readonly CommandDescriptor AddPreloadScriptCommand = new( + "script.addPreloadScript", JsonContext.CommandMessageAddPreloadScriptParameters, JsonContext.AddPreloadScriptResult); + + private static readonly CommandDescriptor RemovePreloadScriptCommand = new( + "script.removePreloadScript", JsonContext.CommandMessageRemovePreloadScriptParameters, JsonContext.RemovePreloadScriptResult); + public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new EvaluateParameters(expression, target, awaitPromise, options?.ResultOwnership, options?.SerializationOptions, options?.UserActivation); - return await ExecuteCommandAsync(new EvaluateCommand(@params), options, JsonContext.EvaluateCommand, JsonContext.EvaluateResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(EvaluateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) @@ -44,7 +62,7 @@ public async Task CallFunctionAsync([StringSyntax(StringSyntaxCo { var @params = new CallFunctionParameters(functionDeclaration, awaitPromise, target, options?.Arguments, options?.ResultOwnership, options?.SerializationOptions, options?.This, options?.UserActivation); - return await ExecuteCommandAsync(new CallFunctionCommand(@params), options, JsonContext.CallFunctionCommand, JsonContext.EvaluateResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(CallFunctionCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CallFunctionAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string functionDeclaration, bool awaitPromise, Target target, CallFunctionOptions? options = null, CancellationToken cancellationToken = default) @@ -58,28 +76,28 @@ public async Task DisownAsync(IEnumerable handles, Target { var @params = new DisownParameters(handles, target); - return await ExecuteCommandAsync(new DisownCommand(@params), options, JsonContext.DisownCommand, JsonContext.DisownResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(DisownCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetRealmsAsync(GetRealmsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetRealmsParameters(options?.Context, options?.Type); - return await ExecuteCommandAsync(new GetRealmsCommand(@params), options, JsonContext.GetRealmsCommand, JsonContext.GetRealmsResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(GetRealmsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task AddPreloadScriptAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string functionDeclaration, AddPreloadScriptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddPreloadScriptParameters(functionDeclaration, options?.Arguments, options?.Contexts, options?.UserContexts, options?.Sandbox); - return await ExecuteCommandAsync(new AddPreloadScriptCommand(@params), options, JsonContext.AddPreloadScriptCommand, JsonContext.AddPreloadScriptResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(AddPreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemovePreloadScriptAsync(PreloadScript script, RemovePreloadScriptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemovePreloadScriptParameters(script); - return await ExecuteCommandAsync(new RemovePreloadScriptCommand(@params), options, JsonContext.RemovePreloadScriptCommand, JsonContext.RemovePreloadScriptResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(RemovePreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnMessageAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) @@ -173,17 +191,17 @@ private static RealmDestroyedEventArgs CreateRealmDestroyedEventArgs(IBiDi bidi, [JsonSerializable(typeof(WorkletRealmInfo))] #endregion -[JsonSerializable(typeof(AddPreloadScriptCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(AddPreloadScriptResult))] -[JsonSerializable(typeof(DisownCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(DisownResult))] -[JsonSerializable(typeof(CallFunctionCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(EvaluateResult))] -[JsonSerializable(typeof(EvaluateCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(EvaluateResult))] -[JsonSerializable(typeof(GetRealmsCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(GetRealmsResult))] -[JsonSerializable(typeof(RemovePreloadScriptCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(RemovePreloadScriptResult))] [JsonSerializable(typeof(MessageParameters))] diff --git a/dotnet/src/webdriver/BiDi/Session/EndCommand.cs b/dotnet/src/webdriver/BiDi/Session/End.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Session/EndCommand.cs rename to dotnet/src/webdriver/BiDi/Session/End.cs index a93434214db2c..398e01937317e 100644 --- a/dotnet/src/webdriver/BiDi/Session/EndCommand.cs +++ b/dotnet/src/webdriver/BiDi/Session/End.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class EndCommand() - : Command(Parameters.Empty, "session.end"); - public sealed record EndOptions : CommandOptions; public sealed record EndResult : EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/Session/NewCommand.cs b/dotnet/src/webdriver/BiDi/Session/New.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Session/NewCommand.cs rename to dotnet/src/webdriver/BiDi/Session/New.cs index 68e445a475ee0..38fb54ee90b43 100644 --- a/dotnet/src/webdriver/BiDi/Session/NewCommand.cs +++ b/dotnet/src/webdriver/BiDi/Session/New.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class NewCommand(NewParameters @params) - : Command(@params, "session.new"); - internal sealed record NewParameters(CapabilitiesRequest Capabilities) : Parameters; public sealed record NewOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 9697ccbe91f07..830844c394a2c 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -25,47 +25,61 @@ internal sealed class SessionModule : Module, ISessionModule { private static readonly SessionJsonSerializerContext JsonContext = SessionJsonSerializerContext.Default; + private static readonly CommandDescriptor StatusCommand = new( + "session.status", JsonContext.CommandMessageParameters, JsonContext.StatusResult); + + private static readonly CommandDescriptor NewCommand = new( + "session.new", JsonContext.CommandMessageNewParameters, JsonContext.NewResult); + + private static readonly CommandDescriptor EndCommand = new( + "session.end", JsonContext.CommandMessageParameters, JsonContext.EndResult); + + private static readonly CommandDescriptor SubscribeCommand = new( + "session.subscribe", JsonContext.CommandMessageSubscribeParameters, JsonContext.SubscribeResult); + + private static readonly CommandDescriptor UnsubscribeByIdCommand = new( + "session.unsubscribe", JsonContext.CommandMessageUnsubscribeByIdParameters, JsonContext.UnsubscribeResult); + public async Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new StatusCommand(), options, JsonContext.StatusCommand, JsonContext.StatusResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(StatusCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task SubscribeAsync(IEnumerable events, SubscribeOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SubscribeParameters(events, options?.Contexts); - return await ExecuteCommandAsync(new(@params), options, JsonContext.SubscribeCommand, JsonContext.SubscribeResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SubscribeCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task UnsubscribeAsync(IEnumerable subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default) { var @params = new UnsubscribeByIdParameters(subscriptions); - return await ExecuteCommandAsync(new UnsubscribeByIdCommand(@params), options, JsonContext.UnsubscribeByIdCommand, JsonContext.UnsubscribeResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(UnsubscribeByIdCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task NewAsync(CapabilitiesRequest capabilities, NewOptions? options = null, CancellationToken cancellationToken = default) { var @params = new NewParameters(capabilities); - return await ExecuteCommandAsync(new NewCommand(@params), options, JsonContext.NewCommand, JsonContext.NewResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(NewCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task EndAsync(EndOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(new EndCommand(), options, JsonContext.EndCommand, JsonContext.EndResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(EndCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(StatusCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(StatusResult))] -[JsonSerializable(typeof(NewCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(NewResult))] -[JsonSerializable(typeof(EndCommand))] [JsonSerializable(typeof(EndResult))] -[JsonSerializable(typeof(SubscribeCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SubscribeResult))] -[JsonSerializable(typeof(UnsubscribeByIdCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(UnsubscribeResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Session/StatusCommand.cs b/dotnet/src/webdriver/BiDi/Session/Status.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Session/StatusCommand.cs rename to dotnet/src/webdriver/BiDi/Session/Status.cs index dfe95878ca124..88523fa45b623 100644 --- a/dotnet/src/webdriver/BiDi/Session/StatusCommand.cs +++ b/dotnet/src/webdriver/BiDi/Session/Status.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class StatusCommand() - : Command(Parameters.Empty, "session.status"); - public sealed record StatusResult(bool Ready, string Message) : EmptyResult; public sealed record StatusOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Session/SubscribeCommand.cs b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Session/SubscribeCommand.cs rename to dotnet/src/webdriver/BiDi/Session/Subscribe.cs index f22e64227fab5..6e68f60c23e53 100644 --- a/dotnet/src/webdriver/BiDi/Session/SubscribeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class SubscribeCommand(SubscribeParameters @params) - : Command(@params, "session.subscribe"); - internal sealed record SubscribeParameters(IEnumerable Events, IEnumerable? Contexts) : Parameters; public sealed record SubscribeOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Session/UnsubscribeCommand.cs b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs similarity index 86% rename from dotnet/src/webdriver/BiDi/Session/UnsubscribeCommand.cs rename to dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs index 821c7e0b49183..2d3954f6874cb 100644 --- a/dotnet/src/webdriver/BiDi/Session/UnsubscribeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Session; -internal sealed class UnsubscribeByIdCommand(UnsubscribeByIdParameters @params) - : Command(@params, "session.unsubscribe"); - internal sealed record UnsubscribeByIdParameters(IEnumerable Subscriptions) : Parameters; public sealed record UnsubscribeByIdOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/Storage/DeleteCookiesCommand.cs b/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs similarity index 90% rename from dotnet/src/webdriver/BiDi/Storage/DeleteCookiesCommand.cs rename to dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs index 9e170974149ee..71890e8d427a5 100644 --- a/dotnet/src/webdriver/BiDi/Storage/DeleteCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.Storage; -internal sealed class DeleteCookiesCommand(DeleteCookiesParameters @params) - : Command(@params, "storage.deleteCookies"); - internal sealed record DeleteCookiesParameters(CookieFilter? Filter, PartitionDescriptor? Partition) : Parameters; public sealed record DeleteCookiesOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs similarity index 94% rename from dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs rename to dotnet/src/webdriver/BiDi/Storage/GetCookies.cs index 83b3613ddc6bd..181044397e995 100644 --- a/dotnet/src/webdriver/BiDi/Storage/GetCookiesCommand.cs +++ b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Storage; -internal sealed class GetCookiesCommand(GetCookiesParameters @params) - : Command(@params, "storage.getCookies"); - internal sealed record GetCookiesParameters(CookieFilter? Filter, PartitionDescriptor? Partition) : Parameters; public sealed record GetCookiesOptions : CommandOptions diff --git a/dotnet/src/webdriver/BiDi/Storage/SetCookieCommand.cs b/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs similarity index 92% rename from dotnet/src/webdriver/BiDi/Storage/SetCookieCommand.cs rename to dotnet/src/webdriver/BiDi/Storage/SetCookie.cs index b02932e5da575..672df580c320d 100644 --- a/dotnet/src/webdriver/BiDi/Storage/SetCookieCommand.cs +++ b/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs @@ -22,9 +22,6 @@ namespace OpenQA.Selenium.BiDi.Storage; -internal sealed class SetCookieCommand(SetCookieParameters @params) - : Command(@params, "storage.setCookie"); - internal sealed record SetCookieParameters(PartialCookie Cookie, PartitionDescriptor? Partition) : Parameters; public sealed record PartialCookie(string Name, Network.BytesValue Value, string Domain) diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 5cd921b3f0165..cdc9b3782a781 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -25,33 +25,42 @@ public sealed class StorageModule : Module, IStorageModule { private static readonly StorageJsonSerializerContext JsonContext = StorageJsonSerializerContext.Default; + private static readonly CommandDescriptor GetCookiesCommand = new( + "storage.getCookies", JsonContext.CommandMessageGetCookiesParameters, JsonContext.GetCookiesResult); + + private static readonly CommandDescriptor DeleteCookiesCommand = new( + "storage.deleteCookies", JsonContext.CommandMessageDeleteCookiesParameters, JsonContext.DeleteCookiesResult); + + private static readonly CommandDescriptor SetCookieCommand = new( + "storage.setCookie", JsonContext.CommandMessageSetCookieParameters, JsonContext.SetCookieResult); + public async Task GetCookiesAsync(GetCookiesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetCookiesParameters(options?.Filter, options?.Partition); - return await ExecuteCommandAsync(new GetCookiesCommand(@params), options, JsonContext.GetCookiesCommand, JsonContext.GetCookiesResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(GetCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task DeleteCookiesAsync(DeleteCookiesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new DeleteCookiesParameters(options?.Filter, options?.Partition); - return await ExecuteCommandAsync(new DeleteCookiesCommand(@params), options, JsonContext.DeleteCookiesCommand, JsonContext.DeleteCookiesResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(DeleteCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetCookieAsync(PartialCookie cookie, SetCookieOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetCookieParameters(cookie, options?.Partition); - return await ExecuteCommandAsync(new SetCookieCommand(@params), options, JsonContext.SetCookieCommand, JsonContext.SetCookieResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(SetCookieCommand, @params, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(GetCookiesCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(GetCookiesResult))] -[JsonSerializable(typeof(SetCookieCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(SetCookieResult))] -[JsonSerializable(typeof(DeleteCookiesCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(DeleteCookiesResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs b/dotnet/src/webdriver/BiDi/WebExtension/Install.cs similarity index 91% rename from dotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs rename to dotnet/src/webdriver/BiDi/WebExtension/Install.cs index 983293ceaccd9..fc51995e7b476 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/InstallCommand.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/Install.cs @@ -21,9 +21,6 @@ namespace OpenQA.Selenium.BiDi.WebExtension; -internal sealed class InstallCommand(InstallParameters @params) - : Command(@params, "webExtension.install"); - internal sealed record InstallParameters(ExtensionData ExtensionData) : Parameters; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] diff --git a/dotnet/src/webdriver/BiDi/WebExtension/UninstallCommand.cs b/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs similarity index 87% rename from dotnet/src/webdriver/BiDi/WebExtension/UninstallCommand.cs rename to dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs index 1b117a8fa39bc..263efbf5926a7 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/UninstallCommand.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs @@ -19,9 +19,6 @@ namespace OpenQA.Selenium.BiDi.WebExtension; -internal sealed class UninstallCommand(UninstallParameters @params) - : Command(@params, "webExtension.uninstall"); - internal sealed record UninstallParameters(Extension Extension) : Parameters; public sealed record UninstallOptions : CommandOptions; diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index e048dd7154317..854a3b3949683 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -25,24 +25,30 @@ public sealed class WebExtensionModule : Module, IWebExtensionModule { private static readonly WebExtensionJsonSerializerContext JsonContext = WebExtensionJsonSerializerContext.Default; + private static readonly CommandDescriptor InstallCommand = new( + "webExtension.install", JsonContext.CommandMessageInstallParameters, JsonContext.InstallResult); + + private static readonly CommandDescriptor UninstallCommand = new( + "webExtension.uninstall", JsonContext.CommandMessageUninstallParameters, JsonContext.UninstallResult); + public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null, CancellationToken cancellationToken = default) { var @params = new InstallParameters(extensionData); - return await ExecuteCommandAsync(new InstallCommand(@params), options, JsonContext.InstallCommand, JsonContext.InstallResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(InstallCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task UninstallAsync(Extension extension, UninstallOptions? options = null, CancellationToken cancellationToken = default) { var @params = new UninstallParameters(extension); - return await ExecuteCommandAsync(new UninstallCommand(@params), options, JsonContext.UninstallCommand, JsonContext.UninstallResult, cancellationToken).ConfigureAwait(false); + return await ExecuteCommandAsync(UninstallCommand, @params, options, cancellationToken).ConfigureAwait(false); } } -[JsonSerializable(typeof(InstallCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(InstallResult))] -[JsonSerializable(typeof(UninstallCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(UninstallResult))] [JsonSourceGenerationOptions( From 804fe84f06b8095f7395ad4c3e1b8f51b20ee9f6 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:04:55 +0300 Subject: [PATCH 02/11] Adjust tests --- dotnet/src/webdriver/BiDi/Command.cs | 4 ++-- dotnet/src/webdriver/BiDi/Module.cs | 2 +- dotnet/test/webdriver/BiDi/Session/SessionTests.cs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index 3d6dec5134377..b76606bf48e5b 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi; -internal readonly struct CommandMessage where TParameters : Parameters +public readonly struct CommandMessage where TParameters : Parameters { [JsonPropertyOrder(0)] public long Id { get; init; } @@ -34,7 +34,7 @@ namespace OpenQA.Selenium.BiDi; public TParameters Params { get; init; } } -internal sealed class CommandDescriptor( +public sealed class CommandDescriptor( string method, JsonTypeInfo> commandTypeInfo, JsonTypeInfo resultTypeInfo) diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index f6c7839199ec1..cf7705f0a69cb 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -25,7 +25,7 @@ public abstract class Module { private Broker Broker { get; set; } = null!; - private protected Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + protected Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) where TParameters : Parameters where TResult : EmptyResult { diff --git a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs index bd3d9f023788a..a12b2d34c1ba2 100644 --- a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs +++ b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs @@ -79,22 +79,22 @@ class CustomModule : Module { private static readonly CustomModuleJsonSerializerContext JsonContext = CustomModuleJsonSerializerContext.Default; + private static readonly CommandDescriptor DoSomethingCommand = + new("session.status", JsonContext.CommandMessageParameters, JsonContext.DoSomethingResult); + public async Task DoSomethingAsync(DoSomethingOptions options = null) { - return await ExecuteCommandAsync(new DoSomethingCommand(), options, JsonContext.DoSomethingCommand, JsonContext.DoSomethingResult, CancellationToken.None); + return await ExecuteCommandAsync(DoSomethingCommand, Parameters.Empty, options, CancellationToken.None); } } [JsonSourceGenerationOptions( PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] -[JsonSerializable(typeof(DoSomethingCommand))] +[JsonSerializable(typeof(CommandMessage))] [JsonSerializable(typeof(DoSomethingResult))] partial class CustomModuleJsonSerializerContext : JsonSerializerContext; -class DoSomethingCommand() - : Command(Parameters.Empty, "session.status"); - record DoSomethingResult : EmptyResult; record DoSomethingOptions : CommandOptions; From a6b914ac2133f32c898d54e671add2393700262a Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Thu, 9 Apr 2026 23:49:45 +0300 Subject: [PATCH 03/11] Internal modules implementation --- dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs | 2 +- .../BiDi/BrowsingContext/BrowsingContextInputModule.cs | 2 +- .../webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs | 2 +- .../src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs | 2 +- .../BiDi/BrowsingContext/BrowsingContextNetworkModule.cs | 2 +- .../BiDi/BrowsingContext/BrowsingContextScriptModule.cs | 2 +- .../BiDi/BrowsingContext/BrowsingContextStorageModule.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs | 2 +- dotnet/src/webdriver/BiDi/Input/InputModule.cs | 2 +- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 2 +- dotnet/src/webdriver/BiDi/Network/NetworkModule.cs | 2 +- dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs | 2 +- dotnet/src/webdriver/BiDi/Script/ScriptModule.cs | 2 +- dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/StorageModule.cs | 2 +- dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 4123df610a89c..e016c6ff74b71 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Browser; -public sealed class BrowserModule : Module, IBrowserModule +internal sealed class BrowserModule : Module, IBrowserModule { private static readonly BrowserJsonSerializerContext JsonContext = BrowserJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs index d57553a02d284..93ab39a381714 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextInputModule(BrowsingContext context, IInputModule inputModule) : IBrowsingContextInputModule +internal sealed class BrowsingContextInputModule(BrowsingContext context, IInputModule inputModule) : IBrowsingContextInputModule { public Task PerformActionsAsync(IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs index 9e29d351125e8..02314c3d5c7a1 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextLogModule(BrowsingContext context, ILogModule logModule) : IBrowsingContextLogModule +internal sealed class BrowsingContextLogModule(BrowsingContext context, ILogModule logModule) : IBrowsingContextLogModule { public Task OnEntryAddedAsync(Func handler, ContextSubscriptionOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index ba9a5a9d182d1..5f17810827f3f 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextModule : Module, IBrowsingContextModule +internal sealed class BrowsingContextModule : Module, IBrowsingContextModule { private static readonly BrowsingContextJsonSerializerContext JsonContext = BrowsingContextJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs index 420cc6e6892b8..3e9c824a8488a 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextNetworkModule(BrowsingContext context, INetworkModule networkModule) : IBrowsingContextNetworkModule +internal sealed class BrowsingContextNetworkModule(BrowsingContext context, INetworkModule networkModule) : IBrowsingContextNetworkModule { public Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs index 233e60bd09d33..41138004d71ab 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextScriptModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextScriptModule(BrowsingContext context, IScriptModule scriptModule) : IBrowsingContextScriptModule +internal sealed class BrowsingContextScriptModule(BrowsingContext context, IScriptModule scriptModule) : IBrowsingContextScriptModule { public Task AddPreloadScriptAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string functionDeclaration, ContextAddPreloadScriptOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextStorageModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextStorageModule.cs index c88cd03ee9d09..989b864ed08d9 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextStorageModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextStorageModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; -public sealed class BrowsingContextStorageModule(BrowsingContext context, IStorageModule storageModule) : IBrowsingContextStorageModule +internal sealed class BrowsingContextStorageModule(BrowsingContext context, IStorageModule storageModule) : IBrowsingContextStorageModule { public Task GetCookiesAsync(ContextGetCookiesOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index faff4457e0a4c..4ce021aa7548f 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Emulation; -public sealed class EmulationModule : Module, IEmulationModule +internal sealed class EmulationModule : Module, IEmulationModule { private static readonly EmulationJsonSerializerContext JsonContext = EmulationJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index db024499b467f..2bd5243154bd5 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Input; -public sealed class InputModule : Module, IInputModule +internal sealed class InputModule : Module, IInputModule { private static readonly InputJsonSerializerContext JsonContext = InputJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index 1e0274317b6c4..ef144088d0a04 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Log; -public sealed class LogModule : Module, ILogModule +internal sealed class LogModule : Module, ILogModule { private static readonly LogJsonSerializerContext JsonContext = LogJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 3326bc959fc39..8bf78819cf91d 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Network; -public sealed partial class NetworkModule : Module, INetworkModule +internal sealed partial class NetworkModule : Module, INetworkModule { private static readonly NetworkJsonSerializerContext JsonContext = NetworkJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 8d36981dfafc8..7a5741ea1d9eb 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Permissions; -public sealed class PermissionsModule : Module, IPermissionsModule +internal sealed class PermissionsModule : Module, IPermissionsModule { private static readonly PermissionsJsonSerializerContext JsonContext = PermissionsJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 7f4ae03dbd050..26e24042eb34b 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -22,7 +22,7 @@ namespace OpenQA.Selenium.BiDi.Script; -public sealed class ScriptModule : Module, IScriptModule +internal sealed class ScriptModule : Module, IScriptModule { private static readonly ScriptJsonSerializerContext JsonContext = ScriptJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs b/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs index c1c2a46f46494..278ab0e7a46cb 100644 --- a/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs +++ b/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Speculation; -public sealed class SpeculationModule : Module, ISpeculationModule +internal sealed class SpeculationModule : Module, ISpeculationModule { private static readonly SpeculationJsonSerializerContext JsonContext = SpeculationJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index cdc9b3782a781..a24efac7b91e1 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.Storage; -public sealed class StorageModule : Module, IStorageModule +internal sealed class StorageModule : Module, IStorageModule { private static readonly StorageJsonSerializerContext JsonContext = StorageJsonSerializerContext.Default; diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 854a3b3949683..c6fab9b2101f9 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi.WebExtension; -public sealed class WebExtensionModule : Module, IWebExtensionModule +internal sealed class WebExtensionModule : Module, IWebExtensionModule { private static readonly WebExtensionJsonSerializerContext JsonContext = WebExtensionJsonSerializerContext.Default; From 642e8ea9044955661bd99f37b518a39c8ff76a15 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 00:15:11 +0300 Subject: [PATCH 04/11] Alias for json context --- .../webdriver/BiDi/Browser/BrowserModule.cs | 15 ++-- .../BrowsingContext/BrowsingContextModule.cs | 83 +++++++++---------- .../BiDi/Emulation/EmulationModule.cs | 25 +++--- .../src/webdriver/BiDi/Input/InputModule.cs | 13 ++- dotnet/src/webdriver/BiDi/Log/LogModule.cs | 7 +- .../webdriver/BiDi/Network/NetworkModule.cs | 46 +++++----- .../BiDi/Permissions/PermissionsModule.cs | 5 +- .../src/webdriver/BiDi/Script/ScriptModule.cs | 27 +++--- .../webdriver/BiDi/Session/SessionModule.cs | 13 ++- .../BiDi/Speculation/SpeculationModule.cs | 7 +- .../webdriver/BiDi/Storage/StorageModule.cs | 9 +- .../BiDi/WebExtension/WebExtensionModule.cs | 7 +- 12 files changed, 123 insertions(+), 134 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index e016c6ff74b71..112d237bf79b8 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -18,30 +18,29 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Browser.BrowserJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Browser; internal sealed class BrowserModule : Module, IBrowserModule { - private static readonly BrowserJsonSerializerContext JsonContext = BrowserJsonSerializerContext.Default; - private static readonly CommandDescriptor CloseCommand = new( - "browser.close", JsonContext.CommandMessageParameters, JsonContext.CloseResult); + "browser.close", Default.CommandMessageParameters, Default.CloseResult); private static readonly CommandDescriptor CreateUserContextCommand = new( - "browser.createUserContext", JsonContext.CommandMessageCreateUserContextParameters, JsonContext.CreateUserContextResult); + "browser.createUserContext", Default.CommandMessageCreateUserContextParameters, Default.CreateUserContextResult); private static readonly CommandDescriptor GetUserContextsCommand = new( - "browser.getUserContexts", JsonContext.CommandMessageParameters, JsonContext.GetUserContextsResult); + "browser.getUserContexts", Default.CommandMessageParameters, Default.GetUserContextsResult); private static readonly CommandDescriptor RemoveUserContextCommand = new( - "browser.removeUserContext", JsonContext.CommandMessageRemoveUserContextParameters, JsonContext.RemoveUserContextResult); + "browser.removeUserContext", Default.CommandMessageRemoveUserContextParameters, Default.RemoveUserContextResult); private static readonly CommandDescriptor GetClientWindowsCommand = new( - "browser.getClientWindows", JsonContext.CommandMessageParameters, JsonContext.GetClientWindowsResult); + "browser.getClientWindows", Default.CommandMessageParameters, Default.GetClientWindowsResult); private static readonly CommandDescriptor SetDownloadBehaviorCommand = new( - "browser.setDownloadBehavior", JsonContext.CommandMessageSetDownloadBehaviorParameters, JsonContext.SetDownloadBehaviorResult); + "browser.setDownloadBehavior", Default.CommandMessageSetDownloadBehaviorParameters, Default.SetDownloadBehaviorResult); public async Task CloseAsync(CloseOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index 5f17810827f3f..e2b7388a227ca 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -18,48 +18,47 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.BrowsingContext.BrowsingContextJsonSerializerContext; namespace OpenQA.Selenium.BiDi.BrowsingContext; internal sealed class BrowsingContextModule : Module, IBrowsingContextModule { - private static readonly BrowsingContextJsonSerializerContext JsonContext = BrowsingContextJsonSerializerContext.Default; - private static readonly CommandDescriptor CreateCommand = new( - "browsingContext.create", JsonContext.CommandMessageCreateParameters, JsonContext.CreateResult); + "browsingContext.create", Default.CommandMessageCreateParameters, Default.CreateResult); private static readonly CommandDescriptor NavigateCommand = new( - "browsingContext.navigate", JsonContext.CommandMessageNavigateParameters, JsonContext.NavigateResult); + "browsingContext.navigate", Default.CommandMessageNavigateParameters, Default.NavigateResult); private static readonly CommandDescriptor ActivateCommand = new( - "browsingContext.activate", JsonContext.CommandMessageActivateParameters, JsonContext.ActivateResult); + "browsingContext.activate", Default.CommandMessageActivateParameters, Default.ActivateResult); private static readonly CommandDescriptor LocateNodesCommand = new( - "browsingContext.locateNodes", JsonContext.CommandMessageLocateNodesParameters, JsonContext.LocateNodesResult); + "browsingContext.locateNodes", Default.CommandMessageLocateNodesParameters, Default.LocateNodesResult); private static readonly CommandDescriptor CaptureScreenshotCommand = new( - "browsingContext.captureScreenshot", JsonContext.CommandMessageCaptureScreenshotParameters, JsonContext.CaptureScreenshotResult); + "browsingContext.captureScreenshot", Default.CommandMessageCaptureScreenshotParameters, Default.CaptureScreenshotResult); private static readonly CommandDescriptor CloseCommand = new( - "browsingContext.close", JsonContext.CommandMessageCloseParameters, JsonContext.CloseResult); + "browsingContext.close", Default.CommandMessageCloseParameters, Default.CloseResult); private static readonly CommandDescriptor TraverseHistoryCommand = new( - "browsingContext.traverseHistory", JsonContext.CommandMessageTraverseHistoryParameters, JsonContext.TraverseHistoryResult); + "browsingContext.traverseHistory", Default.CommandMessageTraverseHistoryParameters, Default.TraverseHistoryResult); private static readonly CommandDescriptor ReloadCommand = new( - "browsingContext.reload", JsonContext.CommandMessageReloadParameters, JsonContext.ReloadResult); + "browsingContext.reload", Default.CommandMessageReloadParameters, Default.ReloadResult); private static readonly CommandDescriptor SetViewportCommand = new( - "browsingContext.setViewport", JsonContext.CommandMessageSetViewportParameters, JsonContext.SetViewportResult); + "browsingContext.setViewport", Default.CommandMessageSetViewportParameters, Default.SetViewportResult); private static readonly CommandDescriptor GetTreeCommand = new( - "browsingContext.getTree", JsonContext.CommandMessageGetTreeParameters, JsonContext.GetTreeResult); + "browsingContext.getTree", Default.CommandMessageGetTreeParameters, Default.GetTreeResult); private static readonly CommandDescriptor PrintCommand = new( - "browsingContext.print", JsonContext.CommandMessagePrintParameters, JsonContext.PrintResult); + "browsingContext.print", Default.CommandMessagePrintParameters, Default.PrintResult); private static readonly CommandDescriptor HandleUserPromptCommand = new( - "browsingContext.handleUserPrompt", JsonContext.CommandMessageHandleUserPromptParameters, JsonContext.HandleUserPromptResult); + "browsingContext.handleUserPrompt", Default.CommandMessageHandleUserPromptParameters, Default.HandleUserPromptResult); public async Task CreateAsync(ContextType type, CreateOptions? options = null, CancellationToken cancellationToken = default) { @@ -147,142 +146,142 @@ public async Task HandleUserPromptAsync(BrowsingContext public async Task OnNavigationStartedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationStarted", handler, CreateNavigationStartedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationStarted", handler, CreateNavigationStartedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationStartedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationStarted", handler, CreateNavigationStartedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationStarted", handler, CreateNavigationStartedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnFragmentNavigatedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.fragmentNavigated", handler, CreateFragmentNavigatedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.fragmentNavigated", handler, CreateFragmentNavigatedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnFragmentNavigatedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.fragmentNavigated", handler, CreateFragmentNavigatedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.fragmentNavigated", handler, CreateFragmentNavigatedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnHistoryUpdatedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.historyUpdated", handler, CreateHistoryUpdatedEventArgs, options, JsonContext.HistoryUpdatedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.historyUpdated", handler, CreateHistoryUpdatedEventArgs, options, Default.HistoryUpdatedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnHistoryUpdatedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.historyUpdated", handler, CreateHistoryUpdatedEventArgs, options, JsonContext.HistoryUpdatedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.historyUpdated", handler, CreateHistoryUpdatedEventArgs, options, Default.HistoryUpdatedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnDomContentLoadedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.domContentLoaded", handler, CreateDomContentLoadedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.domContentLoaded", handler, CreateDomContentLoadedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnDomContentLoadedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.domContentLoaded", handler, CreateDomContentLoadedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.domContentLoaded", handler, CreateDomContentLoadedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnLoadAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.load", handler, CreateLoadEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.load", handler, CreateLoadEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnLoadAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.load", handler, CreateLoadEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.load", handler, CreateLoadEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnDownloadWillBeginAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.downloadWillBegin", handler, CreateDownloadWillBeginEventArgs, options, JsonContext.DownloadWillBeginParams, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.downloadWillBegin", handler, CreateDownloadWillBeginEventArgs, options, Default.DownloadWillBeginParams, cancellationToken).ConfigureAwait(false); } public async Task OnDownloadWillBeginAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.downloadWillBegin", handler, CreateDownloadWillBeginEventArgs, options, JsonContext.DownloadWillBeginParams, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.downloadWillBegin", handler, CreateDownloadWillBeginEventArgs, options, Default.DownloadWillBeginParams, cancellationToken).ConfigureAwait(false); } public async Task OnDownloadEndAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.downloadEnd", handler, CreateDownloadEndEventArgs, options, JsonContext.DownloadEndParams, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.downloadEnd", handler, CreateDownloadEndEventArgs, options, Default.DownloadEndParams, cancellationToken).ConfigureAwait(false); } public async Task OnDownloadEndAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.downloadEnd", handler, CreateDownloadEndEventArgs, options, JsonContext.DownloadEndParams, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.downloadEnd", handler, CreateDownloadEndEventArgs, options, Default.DownloadEndParams, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationAbortedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationAborted", handler, CreateNavigationAbortedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationAborted", handler, CreateNavigationAbortedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationAbortedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationAborted", handler, CreateNavigationAbortedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationAborted", handler, CreateNavigationAbortedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationFailedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationFailed", handler, CreateNavigationFailedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationFailed", handler, CreateNavigationFailedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationFailedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationFailed", handler, CreateNavigationFailedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationFailed", handler, CreateNavigationFailedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationCommittedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationCommitted", handler, CreateNavigationCommittedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationCommitted", handler, CreateNavigationCommittedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationCommittedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.navigationCommitted", handler, CreateNavigationCommittedEventArgs, options, JsonContext.NavigationInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.navigationCommitted", handler, CreateNavigationCommittedEventArgs, options, Default.NavigationInfo, cancellationToken).ConfigureAwait(false); } public async Task OnContextCreatedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.contextCreated", handler, CreateContextCreatedEventArgs, options, JsonContext.Info, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.contextCreated", handler, CreateContextCreatedEventArgs, options, Default.Info, cancellationToken).ConfigureAwait(false); } public async Task OnContextCreatedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.contextCreated", handler, CreateContextCreatedEventArgs, options, JsonContext.Info, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.contextCreated", handler, CreateContextCreatedEventArgs, options, Default.Info, cancellationToken).ConfigureAwait(false); } public async Task OnContextDestroyedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.contextDestroyed", handler, CreateContextDestroyedEventArgs, options, JsonContext.Info, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.contextDestroyed", handler, CreateContextDestroyedEventArgs, options, Default.Info, cancellationToken).ConfigureAwait(false); } public async Task OnContextDestroyedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.contextDestroyed", handler, CreateContextDestroyedEventArgs, options, JsonContext.Info, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.contextDestroyed", handler, CreateContextDestroyedEventArgs, options, Default.Info, cancellationToken).ConfigureAwait(false); } public async Task OnUserPromptOpenedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.userPromptOpened", handler, CreateUserPromptOpenedEventArgs, options, JsonContext.UserPromptOpenedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.userPromptOpened", handler, CreateUserPromptOpenedEventArgs, options, Default.UserPromptOpenedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnUserPromptOpenedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.userPromptOpened", handler, CreateUserPromptOpenedEventArgs, options, JsonContext.UserPromptOpenedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.userPromptOpened", handler, CreateUserPromptOpenedEventArgs, options, Default.UserPromptOpenedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnUserPromptClosedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.userPromptClosed", handler, CreateUserPromptClosedEventArgs, options, JsonContext.UserPromptClosedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.userPromptClosed", handler, CreateUserPromptClosedEventArgs, options, Default.UserPromptClosedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnUserPromptClosedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("browsingContext.userPromptClosed", handler, CreateUserPromptClosedEventArgs, options, JsonContext.UserPromptClosedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("browsingContext.userPromptClosed", handler, CreateUserPromptClosedEventArgs, options, Default.UserPromptClosedParameters, cancellationToken).ConfigureAwait(false); } private static NavigationStartedEventArgs CreateNavigationStartedEventArgs(IBiDi bidi, NavigationInfo p) => new(bidi, p.Context, p.Navigation, p.Timestamp, p.Url, p.UserContext); diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 4ce021aa7548f..3149fbca81432 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -18,45 +18,44 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Emulation.EmulationJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Emulation; internal sealed class EmulationModule : Module, IEmulationModule { - private static readonly EmulationJsonSerializerContext JsonContext = EmulationJsonSerializerContext.Default; - private static readonly CommandDescriptor SetTimezoneOverrideCommand = new( - "emulation.setTimezoneOverride", JsonContext.CommandMessageSetTimezoneOverrideParameters, JsonContext.SetTimezoneOverrideResult); + "emulation.setTimezoneOverride", Default.CommandMessageSetTimezoneOverrideParameters, Default.SetTimezoneOverrideResult); private static readonly CommandDescriptor SetUserAgentOverrideCommand = new( - "emulation.setUserAgentOverride", JsonContext.CommandMessageSetUserAgentOverrideParameters, JsonContext.SetUserAgentOverrideResult); + "emulation.setUserAgentOverride", Default.CommandMessageSetUserAgentOverrideParameters, Default.SetUserAgentOverrideResult); private static readonly CommandDescriptor SetLocaleOverrideCommand = new( - "emulation.setLocaleOverride", JsonContext.CommandMessageSetLocaleOverrideParameters, JsonContext.SetLocaleOverrideResult); + "emulation.setLocaleOverride", Default.CommandMessageSetLocaleOverrideParameters, Default.SetLocaleOverrideResult); private static readonly CommandDescriptor SetForcedColorsModeThemeOverrideCommand = new( - "emulation.setForcedColorsModeThemeOverride", JsonContext.CommandMessageSetForcedColorsModeThemeOverrideParameters, JsonContext.SetForcedColorsModeThemeOverrideResult); + "emulation.setForcedColorsModeThemeOverride", Default.CommandMessageSetForcedColorsModeThemeOverrideParameters, Default.SetForcedColorsModeThemeOverrideResult); private static readonly CommandDescriptor SetScriptingEnabledCommand = new( - "emulation.setScriptingEnabled", JsonContext.CommandMessageSetScriptingEnabledParameters, JsonContext.SetScriptingEnabledResult); + "emulation.setScriptingEnabled", Default.CommandMessageSetScriptingEnabledParameters, Default.SetScriptingEnabledResult); private static readonly CommandDescriptor SetScreenOrientationOverrideCommand = new( - "emulation.setScreenOrientationOverride", JsonContext.CommandMessageSetScreenOrientationOverrideParameters, JsonContext.SetScreenOrientationOverrideResult); + "emulation.setScreenOrientationOverride", Default.CommandMessageSetScreenOrientationOverrideParameters, Default.SetScreenOrientationOverrideResult); private static readonly CommandDescriptor SetScreenSettingsOverrideCommand = new( - "emulation.setScreenSettingsOverride", JsonContext.CommandMessageSetScreenSettingsOverrideParameters, JsonContext.SetScreenSettingsOverrideResult); + "emulation.setScreenSettingsOverride", Default.CommandMessageSetScreenSettingsOverrideParameters, Default.SetScreenSettingsOverrideResult); private static readonly CommandDescriptor SetScrollbarTypeOverrideCommand = new( - "emulation.setScrollbarTypeOverride", JsonContext.CommandMessageSetScrollbarTypeOverrideParameters, JsonContext.SetScrollbarTypeOverrideResult); + "emulation.setScrollbarTypeOverride", Default.CommandMessageSetScrollbarTypeOverrideParameters, Default.SetScrollbarTypeOverrideResult); private static readonly CommandDescriptor SetGeolocationOverrideCommand = new( - "emulation.setGeolocationOverride", JsonContext.CommandMessageSetGeolocationOverrideParameters, JsonContext.SetGeolocationOverrideResult); + "emulation.setGeolocationOverride", Default.CommandMessageSetGeolocationOverrideParameters, Default.SetGeolocationOverrideResult); private static readonly CommandDescriptor SetTouchOverrideCommand = new( - "emulation.setTouchOverride", JsonContext.CommandMessageSetTouchOverrideParameters, JsonContext.SetTouchOverrideResult); + "emulation.setTouchOverride", Default.CommandMessageSetTouchOverrideParameters, Default.SetTouchOverrideResult); private static readonly CommandDescriptor SetNetworkConditionsCommand = new( - "emulation.setNetworkConditions", JsonContext.CommandMessageSetNetworkConditionsParameters, JsonContext.SetNetworkConditionsResult); + "emulation.setNetworkConditions", Default.CommandMessageSetNetworkConditionsParameters, Default.SetNetworkConditionsResult); public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 2bd5243154bd5..5bbfa48797276 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -18,21 +18,20 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Input.InputJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Input; internal sealed class InputModule : Module, IInputModule { - private static readonly InputJsonSerializerContext JsonContext = InputJsonSerializerContext.Default; - private static readonly CommandDescriptor PerformActionsCommand = new( - "input.performActions", JsonContext.CommandMessagePerformActionsParameters, JsonContext.PerformActionsResult); + "input.performActions", Default.CommandMessagePerformActionsParameters, Default.PerformActionsResult); private static readonly CommandDescriptor ReleaseActionsCommand = new( - "input.releaseActions", JsonContext.CommandMessageReleaseActionsParameters, JsonContext.ReleaseActionsResult); + "input.releaseActions", Default.CommandMessageReleaseActionsParameters, Default.ReleaseActionsResult); private static readonly CommandDescriptor SetFilesCommand = new( - "input.setFiles", JsonContext.CommandMessageSetFilesParameters, JsonContext.SetFilesResult); + "input.setFiles", Default.CommandMessageSetFilesParameters, Default.SetFilesResult); public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { @@ -57,12 +56,12 @@ public async Task SetFilesAsync(BrowsingContext.BrowsingContext public async Task OnFileDialogOpenedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("input.fileDialogOpened", handler, CreateFileDialogOpenedEventArgs, options, JsonContext.FileDialogInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("input.fileDialogOpened", handler, CreateFileDialogOpenedEventArgs, options, Default.FileDialogInfo, cancellationToken).ConfigureAwait(false); } public async Task OnFileDialogOpenedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("input.fileDialogOpened", handler, CreateFileDialogOpenedEventArgs, options, JsonContext.FileDialogInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("input.fileDialogOpened", handler, CreateFileDialogOpenedEventArgs, options, Default.FileDialogInfo, cancellationToken).ConfigureAwait(false); } private static FileDialogOpenedEventArgs CreateFileDialogOpenedEventArgs(IBiDi bidi, FileDialogInfo p) diff --git a/dotnet/src/webdriver/BiDi/Log/LogModule.cs b/dotnet/src/webdriver/BiDi/Log/LogModule.cs index ef144088d0a04..342441fb2cdd9 100644 --- a/dotnet/src/webdriver/BiDi/Log/LogModule.cs +++ b/dotnet/src/webdriver/BiDi/Log/LogModule.cs @@ -18,21 +18,20 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Log.LogJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Log; internal sealed class LogModule : Module, ILogModule { - private static readonly LogJsonSerializerContext JsonContext = LogJsonSerializerContext.Default; - public async Task OnEntryAddedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("log.entryAdded", handler, CreateEntryAddedEventArgs, options, JsonContext.LogEntry, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("log.entryAdded", handler, CreateEntryAddedEventArgs, options, Default.LogEntry, cancellationToken).ConfigureAwait(false); } public async Task OnEntryAddedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("log.entryAdded", handler, CreateEntryAddedEventArgs, options, JsonContext.LogEntry, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("log.entryAdded", handler, CreateEntryAddedEventArgs, options, Default.LogEntry, cancellationToken).ConfigureAwait(false); } private static EntryAddedEventArgs CreateEntryAddedEventArgs(IBiDi bidi, LogEntry p) => p switch diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 8bf78819cf91d..20191a0b6fc29 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -18,48 +18,48 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Network.NetworkJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Network; internal sealed partial class NetworkModule : Module, INetworkModule { - private static readonly NetworkJsonSerializerContext JsonContext = NetworkJsonSerializerContext.Default; private static readonly CommandDescriptor AddDataCollectorCommand = new( - "network.addDataCollector", JsonContext.CommandMessageAddDataCollectorParameters, JsonContext.AddDataCollectorResult); + "network.addDataCollector", Default.CommandMessageAddDataCollectorParameters, Default.AddDataCollectorResult); private static readonly CommandDescriptor AddInterceptCommand = new( - "network.addIntercept", JsonContext.CommandMessageAddInterceptParameters, JsonContext.AddInterceptResult); + "network.addIntercept", Default.CommandMessageAddInterceptParameters, Default.AddInterceptResult); private static readonly CommandDescriptor RemoveDataCollectorCommand = new( - "network.removeDataCollector", JsonContext.CommandMessageRemoveDataCollectorParameters, JsonContext.RemoveDataCollectorResult); + "network.removeDataCollector", Default.CommandMessageRemoveDataCollectorParameters, Default.RemoveDataCollectorResult); private static readonly CommandDescriptor RemoveInterceptCommand = new( - "network.removeIntercept", JsonContext.CommandMessageRemoveInterceptParameters, JsonContext.RemoveInterceptResult); + "network.removeIntercept", Default.CommandMessageRemoveInterceptParameters, Default.RemoveInterceptResult); private static readonly CommandDescriptor SetCacheBehaviorCommand = new( - "network.setCacheBehavior", JsonContext.CommandMessageSetCacheBehaviorParameters, JsonContext.SetCacheBehaviorResult); + "network.setCacheBehavior", Default.CommandMessageSetCacheBehaviorParameters, Default.SetCacheBehaviorResult); private static readonly CommandDescriptor SetExtraHeadersCommand = new( - "network.setExtraHeaders", JsonContext.CommandMessageSetExtraHeadersParameters, JsonContext.SetExtraHeadersResult); + "network.setExtraHeaders", Default.CommandMessageSetExtraHeadersParameters, Default.SetExtraHeadersResult); private static readonly CommandDescriptor ContinueRequestCommand = new( - "network.continueRequest", JsonContext.CommandMessageContinueRequestParameters, JsonContext.ContinueRequestResult); + "network.continueRequest", Default.CommandMessageContinueRequestParameters, Default.ContinueRequestResult); private static readonly CommandDescriptor ContinueResponseCommand = new( - "network.continueResponse", JsonContext.CommandMessageContinueResponseParameters, JsonContext.ContinueResponseResult); + "network.continueResponse", Default.CommandMessageContinueResponseParameters, Default.ContinueResponseResult); private static readonly CommandDescriptor FailRequestCommand = new( - "network.failRequest", JsonContext.CommandMessageFailRequestParameters, JsonContext.FailRequestResult); + "network.failRequest", Default.CommandMessageFailRequestParameters, Default.FailRequestResult); private static readonly CommandDescriptor GetDataCommand = new( - "network.getData", JsonContext.CommandMessageGetDataParameters, JsonContext.GetDataResult); + "network.getData", Default.CommandMessageGetDataParameters, Default.GetDataResult); private static readonly CommandDescriptor ProvideResponseCommand = new( - "network.provideResponse", JsonContext.CommandMessageProvideResponseParameters, JsonContext.ProvideResponseResult); + "network.provideResponse", Default.CommandMessageProvideResponseParameters, Default.ProvideResponseResult); private static readonly CommandDescriptor ContinueWithAuthCommand = new( - "network.continueWithAuth", JsonContext.CommandMessageContinueWithAuthParameters, JsonContext.ContinueWithAuthResult); + "network.continueWithAuth", Default.CommandMessageContinueWithAuthParameters, Default.ContinueWithAuthResult); public async Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { @@ -157,52 +157,52 @@ public async Task ContinueWithAuthAsync(Request request, public async Task OnBeforeRequestSentAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.beforeRequestSent", handler, CreateBeforeRequestSentEventArgs, options, JsonContext.BeforeRequestSentParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.beforeRequestSent", handler, CreateBeforeRequestSentEventArgs, options, Default.BeforeRequestSentParameters, cancellationToken).ConfigureAwait(false); } public async Task OnBeforeRequestSentAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.beforeRequestSent", handler, CreateBeforeRequestSentEventArgs, options, JsonContext.BeforeRequestSentParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.beforeRequestSent", handler, CreateBeforeRequestSentEventArgs, options, Default.BeforeRequestSentParameters, cancellationToken).ConfigureAwait(false); } public async Task OnResponseStartedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.responseStarted", handler, CreateResponseStartedEventArgs, options, JsonContext.ResponseStartedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.responseStarted", handler, CreateResponseStartedEventArgs, options, Default.ResponseStartedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnResponseStartedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.responseStarted", handler, CreateResponseStartedEventArgs, options, JsonContext.ResponseStartedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.responseStarted", handler, CreateResponseStartedEventArgs, options, Default.ResponseStartedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnResponseCompletedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.responseCompleted", handler, CreateResponseCompletedEventArgs, options, JsonContext.ResponseCompletedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.responseCompleted", handler, CreateResponseCompletedEventArgs, options, Default.ResponseCompletedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnResponseCompletedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.responseCompleted", handler, CreateResponseCompletedEventArgs, options, JsonContext.ResponseCompletedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.responseCompleted", handler, CreateResponseCompletedEventArgs, options, Default.ResponseCompletedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnFetchErrorAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.fetchError", handler, CreateFetchErrorEventArgs, options, JsonContext.FetchErrorParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.fetchError", handler, CreateFetchErrorEventArgs, options, Default.FetchErrorParameters, cancellationToken).ConfigureAwait(false); } public async Task OnFetchErrorAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.fetchError", handler, CreateFetchErrorEventArgs, options, JsonContext.FetchErrorParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.fetchError", handler, CreateFetchErrorEventArgs, options, Default.FetchErrorParameters, cancellationToken).ConfigureAwait(false); } public async Task OnAuthRequiredAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.authRequired", handler, CreateAuthRequiredEventArgs, options, JsonContext.AuthRequiredParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.authRequired", handler, CreateAuthRequiredEventArgs, options, Default.AuthRequiredParameters, cancellationToken).ConfigureAwait(false); } public async Task OnAuthRequiredAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("network.authRequired", handler, CreateAuthRequiredEventArgs, options, JsonContext.AuthRequiredParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("network.authRequired", handler, CreateAuthRequiredEventArgs, options, Default.AuthRequiredParameters, cancellationToken).ConfigureAwait(false); } private static BeforeRequestSentEventArgs CreateBeforeRequestSentEventArgs(IBiDi bidi, BeforeRequestSentParameters p) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 7a5741ea1d9eb..5cbead6b50a96 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -18,15 +18,14 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Permissions.PermissionsJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Permissions; internal sealed class PermissionsModule : Module, IPermissionsModule { - private static readonly PermissionsJsonSerializerContext JsonContext = PermissionsJsonSerializerContext.Default; - private static readonly CommandDescriptor SetPermissionCommand = new( - "permissions.setPermission", JsonContext.CommandMessageSetPermissionCommandParameters, JsonContext.SetPermissionResult); + "permissions.setPermission", Default.CommandMessageSetPermissionCommandParameters, Default.SetPermissionResult); public async Task SetPermissionAsync(PermissionDescriptor descriptor, PermissionState state, string origin, SetPermissionOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 26e24042eb34b..90c62c8d9646b 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -19,30 +19,29 @@ using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Script.ScriptJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Script; internal sealed class ScriptModule : Module, IScriptModule { - private static readonly ScriptJsonSerializerContext JsonContext = ScriptJsonSerializerContext.Default; - private static readonly CommandDescriptor EvaluateCommand = new( - "script.evaluate", JsonContext.CommandMessageEvaluateParameters, JsonContext.EvaluateResult); + "script.evaluate", Default.CommandMessageEvaluateParameters, Default.EvaluateResult); private static readonly CommandDescriptor CallFunctionCommand = new( - "script.callFunction", JsonContext.CommandMessageCallFunctionParameters, JsonContext.EvaluateResult); + "script.callFunction", Default.CommandMessageCallFunctionParameters, Default.EvaluateResult); private static readonly CommandDescriptor DisownCommand = new( - "script.disown", JsonContext.CommandMessageDisownParameters, JsonContext.DisownResult); + "script.disown", Default.CommandMessageDisownParameters, Default.DisownResult); private static readonly CommandDescriptor GetRealmsCommand = new( - "script.getRealms", JsonContext.CommandMessageGetRealmsParameters, JsonContext.GetRealmsResult); + "script.getRealms", Default.CommandMessageGetRealmsParameters, Default.GetRealmsResult); private static readonly CommandDescriptor AddPreloadScriptCommand = new( - "script.addPreloadScript", JsonContext.CommandMessageAddPreloadScriptParameters, JsonContext.AddPreloadScriptResult); + "script.addPreloadScript", Default.CommandMessageAddPreloadScriptParameters, Default.AddPreloadScriptResult); private static readonly CommandDescriptor RemovePreloadScriptCommand = new( - "script.removePreloadScript", JsonContext.CommandMessageRemovePreloadScriptParameters, JsonContext.RemovePreloadScriptResult); + "script.removePreloadScript", Default.CommandMessageRemovePreloadScriptParameters, Default.RemovePreloadScriptResult); public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) { @@ -102,32 +101,32 @@ public async Task RemovePreloadScriptAsync(PreloadScr public async Task OnMessageAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.message", handler, CreateMessageEventArgs, options, JsonContext.MessageParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.message", handler, CreateMessageEventArgs, options, Default.MessageParameters, cancellationToken).ConfigureAwait(false); } public async Task OnMessageAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.message", handler, CreateMessageEventArgs, options, JsonContext.MessageParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.message", handler, CreateMessageEventArgs, options, Default.MessageParameters, cancellationToken).ConfigureAwait(false); } public async Task OnRealmCreatedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.realmCreated", handler, CreateRealmCreatedEventArgs, options, JsonContext.RealmInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.realmCreated", handler, CreateRealmCreatedEventArgs, options, Default.RealmInfo, cancellationToken).ConfigureAwait(false); } public async Task OnRealmCreatedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.realmCreated", handler, CreateRealmCreatedEventArgs, options, JsonContext.RealmInfo, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.realmCreated", handler, CreateRealmCreatedEventArgs, options, Default.RealmInfo, cancellationToken).ConfigureAwait(false); } public async Task OnRealmDestroyedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.realmDestroyed", handler, CreateRealmDestroyedEventArgs, options, JsonContext.RealmDestroyedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.realmDestroyed", handler, CreateRealmDestroyedEventArgs, options, Default.RealmDestroyedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnRealmDestroyedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("script.realmDestroyed", handler, CreateRealmDestroyedEventArgs, options, JsonContext.RealmDestroyedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("script.realmDestroyed", handler, CreateRealmDestroyedEventArgs, options, Default.RealmDestroyedParameters, cancellationToken).ConfigureAwait(false); } private static MessageEventArgs CreateMessageEventArgs(IBiDi bidi, MessageParameters p) diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 830844c394a2c..73aa3ba9d538c 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -18,27 +18,26 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Session.SessionJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Session; internal sealed class SessionModule : Module, ISessionModule { - private static readonly SessionJsonSerializerContext JsonContext = SessionJsonSerializerContext.Default; - private static readonly CommandDescriptor StatusCommand = new( - "session.status", JsonContext.CommandMessageParameters, JsonContext.StatusResult); + "session.status", Default.CommandMessageParameters, Default.StatusResult); private static readonly CommandDescriptor NewCommand = new( - "session.new", JsonContext.CommandMessageNewParameters, JsonContext.NewResult); + "session.new", Default.CommandMessageNewParameters, Default.NewResult); private static readonly CommandDescriptor EndCommand = new( - "session.end", JsonContext.CommandMessageParameters, JsonContext.EndResult); + "session.end", Default.CommandMessageParameters, Default.EndResult); private static readonly CommandDescriptor SubscribeCommand = new( - "session.subscribe", JsonContext.CommandMessageSubscribeParameters, JsonContext.SubscribeResult); + "session.subscribe", Default.CommandMessageSubscribeParameters, Default.SubscribeResult); private static readonly CommandDescriptor UnsubscribeByIdCommand = new( - "session.unsubscribe", JsonContext.CommandMessageUnsubscribeByIdParameters, JsonContext.UnsubscribeResult); + "session.unsubscribe", Default.CommandMessageUnsubscribeByIdParameters, Default.UnsubscribeResult); public async Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs b/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs index 278ab0e7a46cb..6243014142982 100644 --- a/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs +++ b/dotnet/src/webdriver/BiDi/Speculation/SpeculationModule.cs @@ -18,21 +18,20 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Speculation.SpeculationJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Speculation; internal sealed class SpeculationModule : Module, ISpeculationModule { - private static readonly SpeculationJsonSerializerContext JsonContext = SpeculationJsonSerializerContext.Default; - public async Task OnPrefetchStatusUpdatedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("speculation.prefetchStatusUpdated", handler, CreatePrefetchStatusUpdatedEventArgs, options, JsonContext.PrefetchStatusUpdatedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("speculation.prefetchStatusUpdated", handler, CreatePrefetchStatusUpdatedEventArgs, options, Default.PrefetchStatusUpdatedParameters, cancellationToken).ConfigureAwait(false); } public async Task OnPrefetchStatusUpdatedAsync(Action handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) { - return await SubscribeAsync("speculation.prefetchStatusUpdated", handler, CreatePrefetchStatusUpdatedEventArgs, options, JsonContext.PrefetchStatusUpdatedParameters, cancellationToken).ConfigureAwait(false); + return await SubscribeAsync("speculation.prefetchStatusUpdated", handler, CreatePrefetchStatusUpdatedEventArgs, options, Default.PrefetchStatusUpdatedParameters, cancellationToken).ConfigureAwait(false); } private static PrefetchStatusUpdatedEventArgs CreatePrefetchStatusUpdatedEventArgs(IBiDi bidi, PrefetchStatusUpdatedParameters p) diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index a24efac7b91e1..6e3533037d5e1 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -18,21 +18,20 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.Storage.StorageJsonSerializerContext; namespace OpenQA.Selenium.BiDi.Storage; internal sealed class StorageModule : Module, IStorageModule { - private static readonly StorageJsonSerializerContext JsonContext = StorageJsonSerializerContext.Default; - private static readonly CommandDescriptor GetCookiesCommand = new( - "storage.getCookies", JsonContext.CommandMessageGetCookiesParameters, JsonContext.GetCookiesResult); + "storage.getCookies", Default.CommandMessageGetCookiesParameters, Default.GetCookiesResult); private static readonly CommandDescriptor DeleteCookiesCommand = new( - "storage.deleteCookies", JsonContext.CommandMessageDeleteCookiesParameters, JsonContext.DeleteCookiesResult); + "storage.deleteCookies", Default.CommandMessageDeleteCookiesParameters, Default.DeleteCookiesResult); private static readonly CommandDescriptor SetCookieCommand = new( - "storage.setCookie", JsonContext.CommandMessageSetCookieParameters, JsonContext.SetCookieResult); + "storage.setCookie", Default.CommandMessageSetCookieParameters, Default.SetCookieResult); public async Task GetCookiesAsync(GetCookiesOptions? options = null, CancellationToken cancellationToken = default) { diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index c6fab9b2101f9..081019ff47b69 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -18,18 +18,17 @@ // using System.Text.Json.Serialization; +using static OpenQA.Selenium.BiDi.WebExtension.WebExtensionJsonSerializerContext; namespace OpenQA.Selenium.BiDi.WebExtension; internal sealed class WebExtensionModule : Module, IWebExtensionModule { - private static readonly WebExtensionJsonSerializerContext JsonContext = WebExtensionJsonSerializerContext.Default; - private static readonly CommandDescriptor InstallCommand = new( - "webExtension.install", JsonContext.CommandMessageInstallParameters, JsonContext.InstallResult); + "webExtension.install", Default.CommandMessageInstallParameters, Default.InstallResult); private static readonly CommandDescriptor UninstallCommand = new( - "webExtension.uninstall", JsonContext.CommandMessageUninstallParameters, JsonContext.UninstallResult); + "webExtension.uninstall", Default.CommandMessageUninstallParameters, Default.UninstallResult); public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null, CancellationToken cancellationToken = default) { From 170d18fb77084ae4feeb8b822d5dddd4dc17f46f Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 00:31:06 +0300 Subject: [PATCH 05/11] Broker knows how to compose command --- dotnet/src/webdriver/BiDi/Broker.cs | 14 +++--- .../webdriver/BiDi/Browser/BrowserModule.cs | 20 ++++---- .../BrowsingContext/BrowsingContextModule.cs | 48 +++++++++---------- dotnet/src/webdriver/BiDi/Command.cs | 17 +------ .../BiDi/Emulation/EmulationModule.cs | 44 ++++++++--------- .../src/webdriver/BiDi/Input/InputModule.cs | 12 ++--- .../webdriver/BiDi/Network/NetworkModule.cs | 48 +++++++++---------- .../BiDi/Permissions/PermissionsModule.cs | 4 +- .../src/webdriver/BiDi/Script/ScriptModule.cs | 24 +++++----- .../webdriver/BiDi/Session/SessionModule.cs | 18 +++---- .../webdriver/BiDi/Storage/StorageModule.cs | 12 ++--- .../BiDi/WebExtension/WebExtensionModule.cs | 8 ++-- .../webdriver/BiDi/Session/SessionTests.cs | 4 +- 13 files changed, 129 insertions(+), 144 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Broker.cs b/dotnet/src/webdriver/BiDi/Broker.cs index e93b7f35fe70f..5dca483c9718a 100644 --- a/dotnet/src/webdriver/BiDi/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Broker.cs @@ -125,13 +125,6 @@ public async Task ExecuteCommandAsync(CommandDesc var id = Interlocked.Increment(ref _currentCommandId); - var message = new CommandMessage - { - Id = id, - Method = descriptor.Method, - Params = @params - }; - var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); using var cts = cancellationToken.CanBeCanceled @@ -148,7 +141,12 @@ public async Task ExecuteCommandAsync(CommandDesc using (BiDiContext.Use(_bidi)) using (var writer = new Utf8JsonWriter(sendBuffer)) { - JsonSerializer.Serialize(writer, message, descriptor.CommandTypeInfo); + writer.WriteStartObject(); + writer.WriteNumber("id"u8, id); + writer.WriteString("method"u8, descriptor.Method); + writer.WritePropertyName("params"u8); + JsonSerializer.Serialize(writer, @params, descriptor.ParamsTypeInfo); + writer.WriteEndObject(); } } catch diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 112d237bf79b8..75baa08beab51 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -25,22 +25,22 @@ namespace OpenQA.Selenium.BiDi.Browser; internal sealed class BrowserModule : Module, IBrowserModule { private static readonly CommandDescriptor CloseCommand = new( - "browser.close", Default.CommandMessageParameters, Default.CloseResult); + "browser.close", Default.Parameters, Default.CloseResult); private static readonly CommandDescriptor CreateUserContextCommand = new( - "browser.createUserContext", Default.CommandMessageCreateUserContextParameters, Default.CreateUserContextResult); + "browser.createUserContext", Default.CreateUserContextParameters, Default.CreateUserContextResult); private static readonly CommandDescriptor GetUserContextsCommand = new( - "browser.getUserContexts", Default.CommandMessageParameters, Default.GetUserContextsResult); + "browser.getUserContexts", Default.Parameters, Default.GetUserContextsResult); private static readonly CommandDescriptor RemoveUserContextCommand = new( - "browser.removeUserContext", Default.CommandMessageRemoveUserContextParameters, Default.RemoveUserContextResult); + "browser.removeUserContext", Default.RemoveUserContextParameters, Default.RemoveUserContextResult); private static readonly CommandDescriptor GetClientWindowsCommand = new( - "browser.getClientWindows", Default.CommandMessageParameters, Default.GetClientWindowsResult); + "browser.getClientWindows", Default.Parameters, Default.GetClientWindowsResult); private static readonly CommandDescriptor SetDownloadBehaviorCommand = new( - "browser.setDownloadBehavior", Default.CommandMessageSetDownloadBehaviorParameters, Default.SetDownloadBehaviorResult); + "browser.setDownloadBehavior", Default.SetDownloadBehaviorParameters, Default.SetDownloadBehaviorResult); public async Task CloseAsync(CloseOptions? options = null, CancellationToken cancellationToken = default) { @@ -93,15 +93,15 @@ public async Task SetDownloadBehaviorDeniedAsync(SetD } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(Parameters))] [JsonSerializable(typeof(CloseResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(CreateUserContextParameters))] [JsonSerializable(typeof(CreateUserContextResult))] [JsonSerializable(typeof(GetUserContextsResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(RemoveUserContextParameters))] [JsonSerializable(typeof(RemoveUserContextResult))] [JsonSerializable(typeof(GetClientWindowsResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetDownloadBehaviorParameters))] [JsonSerializable(typeof(SetDownloadBehaviorResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index e2b7388a227ca..f641a6f389296 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -25,40 +25,40 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; internal sealed class BrowsingContextModule : Module, IBrowsingContextModule { private static readonly CommandDescriptor CreateCommand = new( - "browsingContext.create", Default.CommandMessageCreateParameters, Default.CreateResult); + "browsingContext.create", Default.CreateParameters, Default.CreateResult); private static readonly CommandDescriptor NavigateCommand = new( - "browsingContext.navigate", Default.CommandMessageNavigateParameters, Default.NavigateResult); + "browsingContext.navigate", Default.NavigateParameters, Default.NavigateResult); private static readonly CommandDescriptor ActivateCommand = new( - "browsingContext.activate", Default.CommandMessageActivateParameters, Default.ActivateResult); + "browsingContext.activate", Default.ActivateParameters, Default.ActivateResult); private static readonly CommandDescriptor LocateNodesCommand = new( - "browsingContext.locateNodes", Default.CommandMessageLocateNodesParameters, Default.LocateNodesResult); + "browsingContext.locateNodes", Default.LocateNodesParameters, Default.LocateNodesResult); private static readonly CommandDescriptor CaptureScreenshotCommand = new( - "browsingContext.captureScreenshot", Default.CommandMessageCaptureScreenshotParameters, Default.CaptureScreenshotResult); + "browsingContext.captureScreenshot", Default.CaptureScreenshotParameters, Default.CaptureScreenshotResult); private static readonly CommandDescriptor CloseCommand = new( - "browsingContext.close", Default.CommandMessageCloseParameters, Default.CloseResult); + "browsingContext.close", Default.CloseParameters, Default.CloseResult); private static readonly CommandDescriptor TraverseHistoryCommand = new( - "browsingContext.traverseHistory", Default.CommandMessageTraverseHistoryParameters, Default.TraverseHistoryResult); + "browsingContext.traverseHistory", Default.TraverseHistoryParameters, Default.TraverseHistoryResult); private static readonly CommandDescriptor ReloadCommand = new( - "browsingContext.reload", Default.CommandMessageReloadParameters, Default.ReloadResult); + "browsingContext.reload", Default.ReloadParameters, Default.ReloadResult); private static readonly CommandDescriptor SetViewportCommand = new( - "browsingContext.setViewport", Default.CommandMessageSetViewportParameters, Default.SetViewportResult); + "browsingContext.setViewport", Default.SetViewportParameters, Default.SetViewportResult); private static readonly CommandDescriptor GetTreeCommand = new( - "browsingContext.getTree", Default.CommandMessageGetTreeParameters, Default.GetTreeResult); + "browsingContext.getTree", Default.GetTreeParameters, Default.GetTreeResult); private static readonly CommandDescriptor PrintCommand = new( - "browsingContext.print", Default.CommandMessagePrintParameters, Default.PrintResult); + "browsingContext.print", Default.PrintParameters, Default.PrintResult); private static readonly CommandDescriptor HandleUserPromptCommand = new( - "browsingContext.handleUserPrompt", Default.CommandMessageHandleUserPromptParameters, Default.HandleUserPromptResult); + "browsingContext.handleUserPrompt", Default.HandleUserPromptParameters, Default.HandleUserPromptResult); public async Task CreateAsync(ContextType type, CreateOptions? options = null, CancellationToken cancellationToken = default) { @@ -318,29 +318,29 @@ public async Task OnUserPromptClosedAsync(Action new(bidi, p.Context, p.Accepted, p.Type, p.UserContext, p.UserText); } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ActivateParameters))] [JsonSerializable(typeof(ActivateResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(CaptureScreenshotParameters))] [JsonSerializable(typeof(CaptureScreenshotResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(CloseParameters))] [JsonSerializable(typeof(CloseResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(CreateParameters))] [JsonSerializable(typeof(CreateResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(GetTreeParameters))] [JsonSerializable(typeof(GetTreeResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(HandleUserPromptParameters))] [JsonSerializable(typeof(HandleUserPromptResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(LocateNodesParameters))] [JsonSerializable(typeof(LocateNodesResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(NavigateParameters))] [JsonSerializable(typeof(NavigateResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(PrintParameters))] [JsonSerializable(typeof(PrintResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ReloadParameters))] [JsonSerializable(typeof(ReloadResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetViewportParameters))] [JsonSerializable(typeof(SetViewportResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(TraverseHistoryParameters))] [JsonSerializable(typeof(TraverseHistoryResult))] [JsonSerializable(typeof(DownloadWillBeginParams))] diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index b76606bf48e5b..8d0bb59da7266 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -17,32 +17,19 @@ // under the License. // -using System.Text.Json.Serialization; using System.Text.Json.Serialization.Metadata; namespace OpenQA.Selenium.BiDi; -public readonly struct CommandMessage where TParameters : Parameters -{ - [JsonPropertyOrder(0)] - public long Id { get; init; } - - [JsonPropertyOrder(1)] - public string Method { get; init; } - - [JsonPropertyOrder(2)] - public TParameters Params { get; init; } -} - public sealed class CommandDescriptor( string method, - JsonTypeInfo> commandTypeInfo, + JsonTypeInfo paramsTypeInfo, JsonTypeInfo resultTypeInfo) where TParameters : Parameters where TResult : EmptyResult { public string Method { get; } = method; - public JsonTypeInfo> CommandTypeInfo { get; } = commandTypeInfo; + public JsonTypeInfo ParamsTypeInfo { get; } = paramsTypeInfo; public JsonTypeInfo ResultTypeInfo { get; } = resultTypeInfo; } diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 3149fbca81432..8065d0eb40a98 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -25,37 +25,37 @@ namespace OpenQA.Selenium.BiDi.Emulation; internal sealed class EmulationModule : Module, IEmulationModule { private static readonly CommandDescriptor SetTimezoneOverrideCommand = new( - "emulation.setTimezoneOverride", Default.CommandMessageSetTimezoneOverrideParameters, Default.SetTimezoneOverrideResult); + "emulation.setTimezoneOverride", Default.SetTimezoneOverrideParameters, Default.SetTimezoneOverrideResult); private static readonly CommandDescriptor SetUserAgentOverrideCommand = new( - "emulation.setUserAgentOverride", Default.CommandMessageSetUserAgentOverrideParameters, Default.SetUserAgentOverrideResult); + "emulation.setUserAgentOverride", Default.SetUserAgentOverrideParameters, Default.SetUserAgentOverrideResult); private static readonly CommandDescriptor SetLocaleOverrideCommand = new( - "emulation.setLocaleOverride", Default.CommandMessageSetLocaleOverrideParameters, Default.SetLocaleOverrideResult); + "emulation.setLocaleOverride", Default.SetLocaleOverrideParameters, Default.SetLocaleOverrideResult); private static readonly CommandDescriptor SetForcedColorsModeThemeOverrideCommand = new( - "emulation.setForcedColorsModeThemeOverride", Default.CommandMessageSetForcedColorsModeThemeOverrideParameters, Default.SetForcedColorsModeThemeOverrideResult); + "emulation.setForcedColorsModeThemeOverride", Default.SetForcedColorsModeThemeOverrideParameters, Default.SetForcedColorsModeThemeOverrideResult); private static readonly CommandDescriptor SetScriptingEnabledCommand = new( - "emulation.setScriptingEnabled", Default.CommandMessageSetScriptingEnabledParameters, Default.SetScriptingEnabledResult); + "emulation.setScriptingEnabled", Default.SetScriptingEnabledParameters, Default.SetScriptingEnabledResult); private static readonly CommandDescriptor SetScreenOrientationOverrideCommand = new( - "emulation.setScreenOrientationOverride", Default.CommandMessageSetScreenOrientationOverrideParameters, Default.SetScreenOrientationOverrideResult); + "emulation.setScreenOrientationOverride", Default.SetScreenOrientationOverrideParameters, Default.SetScreenOrientationOverrideResult); private static readonly CommandDescriptor SetScreenSettingsOverrideCommand = new( - "emulation.setScreenSettingsOverride", Default.CommandMessageSetScreenSettingsOverrideParameters, Default.SetScreenSettingsOverrideResult); + "emulation.setScreenSettingsOverride", Default.SetScreenSettingsOverrideParameters, Default.SetScreenSettingsOverrideResult); private static readonly CommandDescriptor SetScrollbarTypeOverrideCommand = new( - "emulation.setScrollbarTypeOverride", Default.CommandMessageSetScrollbarTypeOverrideParameters, Default.SetScrollbarTypeOverrideResult); + "emulation.setScrollbarTypeOverride", Default.SetScrollbarTypeOverrideParameters, Default.SetScrollbarTypeOverrideResult); private static readonly CommandDescriptor SetGeolocationOverrideCommand = new( - "emulation.setGeolocationOverride", Default.CommandMessageSetGeolocationOverrideParameters, Default.SetGeolocationOverrideResult); + "emulation.setGeolocationOverride", Default.SetGeolocationOverrideParameters, Default.SetGeolocationOverrideResult); private static readonly CommandDescriptor SetTouchOverrideCommand = new( - "emulation.setTouchOverride", Default.CommandMessageSetTouchOverrideParameters, Default.SetTouchOverrideResult); + "emulation.setTouchOverride", Default.SetTouchOverrideParameters, Default.SetTouchOverrideResult); private static readonly CommandDescriptor SetNetworkConditionsCommand = new( - "emulation.setNetworkConditions", Default.CommandMessageSetNetworkConditionsParameters, Default.SetNetworkConditionsResult); + "emulation.setNetworkConditions", Default.SetNetworkConditionsParameters, Default.SetNetworkConditionsResult); public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default) { @@ -137,27 +137,27 @@ public async Task SetNetworkConditionsAsync(NetworkC } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetTimezoneOverrideParameters))] [JsonSerializable(typeof(SetTimezoneOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetUserAgentOverrideParameters))] [JsonSerializable(typeof(SetUserAgentOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetLocaleOverrideParameters))] [JsonSerializable(typeof(SetLocaleOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetForcedColorsModeThemeOverrideParameters))] [JsonSerializable(typeof(SetForcedColorsModeThemeOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetScriptingEnabledParameters))] [JsonSerializable(typeof(SetScriptingEnabledResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetScreenOrientationOverrideParameters))] [JsonSerializable(typeof(SetScreenOrientationOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetScreenSettingsOverrideParameters))] [JsonSerializable(typeof(SetScreenSettingsOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetScrollbarTypeOverrideParameters))] [JsonSerializable(typeof(SetScrollbarTypeOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetGeolocationOverrideParameters))] [JsonSerializable(typeof(SetGeolocationOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetTouchOverrideParameters))] [JsonSerializable(typeof(SetTouchOverrideResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetNetworkConditionsParameters))] [JsonSerializable(typeof(SetNetworkConditionsResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 5bbfa48797276..0c5e59b1e6c11 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -25,13 +25,13 @@ namespace OpenQA.Selenium.BiDi.Input; internal sealed class InputModule : Module, IInputModule { private static readonly CommandDescriptor PerformActionsCommand = new( - "input.performActions", Default.CommandMessagePerformActionsParameters, Default.PerformActionsResult); + "input.performActions", Default.PerformActionsParameters, Default.PerformActionsResult); private static readonly CommandDescriptor ReleaseActionsCommand = new( - "input.releaseActions", Default.CommandMessageReleaseActionsParameters, Default.ReleaseActionsResult); + "input.releaseActions", Default.ReleaseActionsParameters, Default.ReleaseActionsResult); private static readonly CommandDescriptor SetFilesCommand = new( - "input.setFiles", Default.CommandMessageSetFilesParameters, Default.SetFilesResult); + "input.setFiles", Default.SetFilesParameters, Default.SetFilesResult); public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) { @@ -70,11 +70,11 @@ private static FileDialogOpenedEventArgs CreateFileDialogOpenedEventArgs(IBiDi b } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(PerformActionsParameters))] [JsonSerializable(typeof(PerformActionsResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ReleaseActionsParameters))] [JsonSerializable(typeof(ReleaseActionsResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetFilesParameters))] [JsonSerializable(typeof(SetFilesResult))] [JsonSerializable(typeof(FileDialogInfo))] diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 20191a0b6fc29..21e50b6e1cd56 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -26,40 +26,40 @@ internal sealed partial class NetworkModule : Module, INetworkModule { private static readonly CommandDescriptor AddDataCollectorCommand = new( - "network.addDataCollector", Default.CommandMessageAddDataCollectorParameters, Default.AddDataCollectorResult); + "network.addDataCollector", Default.AddDataCollectorParameters, Default.AddDataCollectorResult); private static readonly CommandDescriptor AddInterceptCommand = new( - "network.addIntercept", Default.CommandMessageAddInterceptParameters, Default.AddInterceptResult); + "network.addIntercept", Default.AddInterceptParameters, Default.AddInterceptResult); private static readonly CommandDescriptor RemoveDataCollectorCommand = new( - "network.removeDataCollector", Default.CommandMessageRemoveDataCollectorParameters, Default.RemoveDataCollectorResult); + "network.removeDataCollector", Default.RemoveDataCollectorParameters, Default.RemoveDataCollectorResult); private static readonly CommandDescriptor RemoveInterceptCommand = new( - "network.removeIntercept", Default.CommandMessageRemoveInterceptParameters, Default.RemoveInterceptResult); + "network.removeIntercept", Default.RemoveInterceptParameters, Default.RemoveInterceptResult); private static readonly CommandDescriptor SetCacheBehaviorCommand = new( - "network.setCacheBehavior", Default.CommandMessageSetCacheBehaviorParameters, Default.SetCacheBehaviorResult); + "network.setCacheBehavior", Default.SetCacheBehaviorParameters, Default.SetCacheBehaviorResult); private static readonly CommandDescriptor SetExtraHeadersCommand = new( - "network.setExtraHeaders", Default.CommandMessageSetExtraHeadersParameters, Default.SetExtraHeadersResult); + "network.setExtraHeaders", Default.SetExtraHeadersParameters, Default.SetExtraHeadersResult); private static readonly CommandDescriptor ContinueRequestCommand = new( - "network.continueRequest", Default.CommandMessageContinueRequestParameters, Default.ContinueRequestResult); + "network.continueRequest", Default.ContinueRequestParameters, Default.ContinueRequestResult); private static readonly CommandDescriptor ContinueResponseCommand = new( - "network.continueResponse", Default.CommandMessageContinueResponseParameters, Default.ContinueResponseResult); + "network.continueResponse", Default.ContinueResponseParameters, Default.ContinueResponseResult); private static readonly CommandDescriptor FailRequestCommand = new( - "network.failRequest", Default.CommandMessageFailRequestParameters, Default.FailRequestResult); + "network.failRequest", Default.FailRequestParameters, Default.FailRequestResult); private static readonly CommandDescriptor GetDataCommand = new( - "network.getData", Default.CommandMessageGetDataParameters, Default.GetDataResult); + "network.getData", Default.GetDataParameters, Default.GetDataResult); private static readonly CommandDescriptor ProvideResponseCommand = new( - "network.provideResponse", Default.CommandMessageProvideResponseParameters, Default.ProvideResponseResult); + "network.provideResponse", Default.ProvideResponseParameters, Default.ProvideResponseResult); private static readonly CommandDescriptor ContinueWithAuthCommand = new( - "network.continueWithAuth", Default.CommandMessageContinueWithAuthParameters, Default.ContinueWithAuthResult); + "network.continueWithAuth", Default.ContinueWithAuthParameters, Default.ContinueWithAuthResult); public async Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { @@ -221,29 +221,29 @@ private static AuthRequiredEventArgs CreateAuthRequiredEventArgs(IBiDi bidi, Aut => new(bidi, p.Context, p.IsBlocked, p.Navigation, p.RedirectCount, p.Request, p.Timestamp, p.UserContext, p.Intercepts, p.Response); } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(AddDataCollectorParameters))] [JsonSerializable(typeof(AddDataCollectorResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(AddInterceptParameters))] [JsonSerializable(typeof(AddInterceptResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ContinueRequestParameters))] [JsonSerializable(typeof(ContinueRequestResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ContinueResponseParameters))] [JsonSerializable(typeof(ContinueResponseResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ContinueWithAuthParameters))] [JsonSerializable(typeof(ContinueWithAuthResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(FailRequestParameters))] [JsonSerializable(typeof(FailRequestResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(GetDataParameters))] [JsonSerializable(typeof(GetDataResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(ProvideResponseParameters))] [JsonSerializable(typeof(ProvideResponseResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(RemoveDataCollectorParameters))] [JsonSerializable(typeof(RemoveDataCollectorResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(RemoveInterceptParameters))] [JsonSerializable(typeof(RemoveInterceptResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetCacheBehaviorParameters))] [JsonSerializable(typeof(SetCacheBehaviorResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetExtraHeadersParameters))] [JsonSerializable(typeof(SetExtraHeadersResult))] [JsonSerializable(typeof(BeforeRequestSentParameters))] diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 5cbead6b50a96..3503fecd08116 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -25,7 +25,7 @@ namespace OpenQA.Selenium.BiDi.Permissions; internal sealed class PermissionsModule : Module, IPermissionsModule { private static readonly CommandDescriptor SetPermissionCommand = new( - "permissions.setPermission", Default.CommandMessageSetPermissionCommandParameters, Default.SetPermissionResult); + "permissions.setPermission", Default.SetPermissionCommandParameters, Default.SetPermissionResult); public async Task SetPermissionAsync(PermissionDescriptor descriptor, PermissionState state, string origin, SetPermissionOptions? options = null, CancellationToken cancellationToken = default) { @@ -35,7 +35,7 @@ public async Task SetPermissionAsync(PermissionDescriptor d } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetPermissionCommandParameters))] [JsonSerializable(typeof(SetPermissionResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index 90c62c8d9646b..c52058eb948bf 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -26,22 +26,22 @@ namespace OpenQA.Selenium.BiDi.Script; internal sealed class ScriptModule : Module, IScriptModule { private static readonly CommandDescriptor EvaluateCommand = new( - "script.evaluate", Default.CommandMessageEvaluateParameters, Default.EvaluateResult); + "script.evaluate", Default.EvaluateParameters, Default.EvaluateResult); private static readonly CommandDescriptor CallFunctionCommand = new( - "script.callFunction", Default.CommandMessageCallFunctionParameters, Default.EvaluateResult); + "script.callFunction", Default.CallFunctionParameters, Default.EvaluateResult); private static readonly CommandDescriptor DisownCommand = new( - "script.disown", Default.CommandMessageDisownParameters, Default.DisownResult); + "script.disown", Default.DisownParameters, Default.DisownResult); private static readonly CommandDescriptor GetRealmsCommand = new( - "script.getRealms", Default.CommandMessageGetRealmsParameters, Default.GetRealmsResult); + "script.getRealms", Default.GetRealmsParameters, Default.GetRealmsResult); private static readonly CommandDescriptor AddPreloadScriptCommand = new( - "script.addPreloadScript", Default.CommandMessageAddPreloadScriptParameters, Default.AddPreloadScriptResult); + "script.addPreloadScript", Default.AddPreloadScriptParameters, Default.AddPreloadScriptResult); private static readonly CommandDescriptor RemovePreloadScriptCommand = new( - "script.removePreloadScript", Default.CommandMessageRemovePreloadScriptParameters, Default.RemovePreloadScriptResult); + "script.removePreloadScript", Default.RemovePreloadScriptParameters, Default.RemovePreloadScriptResult); public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) { @@ -190,17 +190,17 @@ private static RealmDestroyedEventArgs CreateRealmDestroyedEventArgs(IBiDi bidi, [JsonSerializable(typeof(WorkletRealmInfo))] #endregion -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(AddPreloadScriptParameters))] [JsonSerializable(typeof(AddPreloadScriptResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(DisownParameters))] [JsonSerializable(typeof(DisownResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(CallFunctionParameters))] [JsonSerializable(typeof(EvaluateResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(EvaluateParameters))] [JsonSerializable(typeof(EvaluateResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(GetRealmsParameters))] [JsonSerializable(typeof(GetRealmsResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(RemovePreloadScriptParameters))] [JsonSerializable(typeof(RemovePreloadScriptResult))] [JsonSerializable(typeof(MessageParameters))] diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 73aa3ba9d538c..9dfaa44e311dd 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -25,19 +25,19 @@ namespace OpenQA.Selenium.BiDi.Session; internal sealed class SessionModule : Module, ISessionModule { private static readonly CommandDescriptor StatusCommand = new( - "session.status", Default.CommandMessageParameters, Default.StatusResult); + "session.status", Default.Parameters, Default.StatusResult); private static readonly CommandDescriptor NewCommand = new( - "session.new", Default.CommandMessageNewParameters, Default.NewResult); + "session.new", Default.NewParameters, Default.NewResult); private static readonly CommandDescriptor EndCommand = new( - "session.end", Default.CommandMessageParameters, Default.EndResult); + "session.end", Default.Parameters, Default.EndResult); private static readonly CommandDescriptor SubscribeCommand = new( - "session.subscribe", Default.CommandMessageSubscribeParameters, Default.SubscribeResult); + "session.subscribe", Default.SubscribeParameters, Default.SubscribeResult); private static readonly CommandDescriptor UnsubscribeByIdCommand = new( - "session.unsubscribe", Default.CommandMessageUnsubscribeByIdParameters, Default.UnsubscribeResult); + "session.unsubscribe", Default.UnsubscribeByIdParameters, Default.UnsubscribeResult); public async Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default) { @@ -71,14 +71,14 @@ public async Task EndAsync(EndOptions? options = null, CancellationTo } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(Parameters))] [JsonSerializable(typeof(StatusResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(NewParameters))] [JsonSerializable(typeof(NewResult))] [JsonSerializable(typeof(EndResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SubscribeParameters))] [JsonSerializable(typeof(SubscribeResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(UnsubscribeByIdParameters))] [JsonSerializable(typeof(UnsubscribeResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 6e3533037d5e1..3c824a7b5f1f8 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -25,13 +25,13 @@ namespace OpenQA.Selenium.BiDi.Storage; internal sealed class StorageModule : Module, IStorageModule { private static readonly CommandDescriptor GetCookiesCommand = new( - "storage.getCookies", Default.CommandMessageGetCookiesParameters, Default.GetCookiesResult); + "storage.getCookies", Default.GetCookiesParameters, Default.GetCookiesResult); private static readonly CommandDescriptor DeleteCookiesCommand = new( - "storage.deleteCookies", Default.CommandMessageDeleteCookiesParameters, Default.DeleteCookiesResult); + "storage.deleteCookies", Default.DeleteCookiesParameters, Default.DeleteCookiesResult); private static readonly CommandDescriptor SetCookieCommand = new( - "storage.setCookie", Default.CommandMessageSetCookieParameters, Default.SetCookieResult); + "storage.setCookie", Default.SetCookieParameters, Default.SetCookieResult); public async Task GetCookiesAsync(GetCookiesOptions? options = null, CancellationToken cancellationToken = default) { @@ -55,11 +55,11 @@ public async Task SetCookieAsync(PartialCookie cookie, SetCooki } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(GetCookiesParameters))] [JsonSerializable(typeof(GetCookiesResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(SetCookieParameters))] [JsonSerializable(typeof(SetCookieResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(DeleteCookiesParameters))] [JsonSerializable(typeof(DeleteCookiesResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 081019ff47b69..8aeb6df54df2a 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -25,10 +25,10 @@ namespace OpenQA.Selenium.BiDi.WebExtension; internal sealed class WebExtensionModule : Module, IWebExtensionModule { private static readonly CommandDescriptor InstallCommand = new( - "webExtension.install", Default.CommandMessageInstallParameters, Default.InstallResult); + "webExtension.install", Default.InstallParameters, Default.InstallResult); private static readonly CommandDescriptor UninstallCommand = new( - "webExtension.uninstall", Default.CommandMessageUninstallParameters, Default.UninstallResult); + "webExtension.uninstall", Default.UninstallParameters, Default.UninstallResult); public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null, CancellationToken cancellationToken = default) { @@ -45,9 +45,9 @@ public async Task UninstallAsync(Extension extension, Uninstall } } -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(InstallParameters))] [JsonSerializable(typeof(InstallResult))] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(UninstallParameters))] [JsonSerializable(typeof(UninstallResult))] [JsonSourceGenerationOptions( diff --git a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs index a12b2d34c1ba2..01b46c6675aad 100644 --- a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs +++ b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs @@ -80,7 +80,7 @@ class CustomModule : Module private static readonly CustomModuleJsonSerializerContext JsonContext = CustomModuleJsonSerializerContext.Default; private static readonly CommandDescriptor DoSomethingCommand = - new("session.status", JsonContext.CommandMessageParameters, JsonContext.DoSomethingResult); + new("session.status", JsonContext.Parameters, JsonContext.DoSomethingResult); public async Task DoSomethingAsync(DoSomethingOptions options = null) { @@ -91,7 +91,7 @@ public async Task DoSomethingAsync(DoSomethingOptions options [JsonSourceGenerationOptions( PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] -[JsonSerializable(typeof(CommandMessage))] +[JsonSerializable(typeof(Parameters))] [JsonSerializable(typeof(DoSomethingResult))] partial class CustomModuleJsonSerializerContext : JsonSerializerContext; From d2483a106110d31d7895683ba6065d1273e25d04 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 00:41:58 +0300 Subject: [PATCH 06/11] ExecuteAsync shortcut --- dotnet/src/webdriver/BiDi/Broker.cs | 2 +- .../webdriver/BiDi/Browser/BrowserModule.cs | 16 +++++------ .../BrowsingContext/BrowsingContextModule.cs | 24 ++++++++-------- .../BiDi/Emulation/EmulationModule.cs | 26 ++++++++--------- .../src/webdriver/BiDi/Input/InputModule.cs | 6 ++-- dotnet/src/webdriver/BiDi/Module.cs | 4 +-- .../webdriver/BiDi/Network/NetworkModule.cs | 28 +++++++++---------- .../BiDi/Permissions/PermissionsModule.cs | 2 +- .../src/webdriver/BiDi/Script/ScriptModule.cs | 12 ++++---- .../webdriver/BiDi/Session/SessionModule.cs | 10 +++---- .../webdriver/BiDi/Storage/StorageModule.cs | 6 ++-- .../BiDi/WebExtension/WebExtensionModule.cs | 4 +-- .../webdriver/BiDi/Session/SessionTests.cs | 2 +- 13 files changed, 71 insertions(+), 71 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Broker.cs b/dotnet/src/webdriver/BiDi/Broker.cs index 5dca483c9718a..f277f01f13190 100644 --- a/dotnet/src/webdriver/BiDi/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Broker.cs @@ -114,7 +114,7 @@ public async ValueTask UnsubscribeAsync(Subscription subscription, CancellationT _eventDispatcher.RemoveHandler(subscription.EventName, subscription.Handler); } - public async Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + public async Task ExecuteAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) where TParameters : Parameters where TResult : EmptyResult { diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 75baa08beab51..964797bc4d2ff 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -44,52 +44,52 @@ internal sealed class BrowserModule : Module, IBrowserModule public async Task CloseAsync(CloseOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(CloseCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CloseCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task CreateUserContextAsync(CreateUserContextOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior); - return await ExecuteCommandAsync(CreateUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CreateUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetUserContextsAsync(GetUserContextsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(GetUserContextsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(GetUserContextsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveUserContextParameters(userContext); - return await ExecuteCommandAsync(RemoveUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(RemoveUserContextCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetClientWindowsAsync(GetClientWindowsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(GetClientWindowsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(GetClientWindowsCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts); - return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts); - return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts); - return await ExecuteCommandAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetDownloadBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index f641a6f389296..4d7ec074feb5f 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -64,84 +64,84 @@ public async Task CreateAsync(ContextType type, CreateOptions? opt { var @params = new CreateParameters(type, options?.ReferenceContext, options?.Background, options?.UserContext); - return await ExecuteCommandAsync(CreateCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CreateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task NavigateAsync(BrowsingContext context, string url, NavigateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new NavigateParameters(context, url, options?.Wait); - return await ExecuteCommandAsync(NavigateCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(NavigateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ActivateAsync(BrowsingContext context, ActivateOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ActivateParameters(context); - return await ExecuteCommandAsync(ActivateCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ActivateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task LocateNodesAsync(BrowsingContext context, Locator locator, LocateNodesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new LocateNodesParameters(context, locator, options?.MaxNodeCount, options?.SerializationOptions, options?.StartNodes); - return await ExecuteCommandAsync(LocateNodesCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(LocateNodesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CaptureScreenshotAsync(BrowsingContext context, CaptureScreenshotOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CaptureScreenshotParameters(context, options?.Origin, options?.Format, options?.Clip); - return await ExecuteCommandAsync(CaptureScreenshotCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CaptureScreenshotCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CloseAsync(BrowsingContext context, CloseOptions? options = null, CancellationToken cancellationToken = default) { var @params = new CloseParameters(context, options?.PromptUnload); - return await ExecuteCommandAsync(CloseCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CloseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task TraverseHistoryAsync(BrowsingContext context, int delta, TraverseHistoryOptions? options = null, CancellationToken cancellationToken = default) { var @params = new TraverseHistoryParameters(context, delta); - return await ExecuteCommandAsync(TraverseHistoryCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(TraverseHistoryCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ReloadAsync(BrowsingContext context, ReloadOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ReloadParameters(context, options?.IgnoreCache, options?.Wait); - return await ExecuteCommandAsync(ReloadCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ReloadCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetViewportAsync(SetViewportOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetViewportParameters(options?.Context, options?.Viewport, options?.DevicePixelRatio, options?.UserContexts); - return await ExecuteCommandAsync(SetViewportCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetViewportCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetTreeAsync(GetTreeOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetTreeParameters(options?.MaxDepth, options?.Root); - return await ExecuteCommandAsync(GetTreeCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(GetTreeCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task PrintAsync(BrowsingContext context, PrintOptions? options = null, CancellationToken cancellationToken = default) { var @params = new PrintParameters(context, options?.Background, options?.Margin, options?.Orientation, options?.Page, options?.PageRanges, options?.Scale, options?.ShrinkToFit); - return await ExecuteCommandAsync(PrintCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(PrintCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new HandleUserPromptParameters(context, options?.Accept, options?.UserText); - return await ExecuteCommandAsync(HandleUserPromptCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(HandleUserPromptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnNavigationStartedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index 8065d0eb40a98..ce291ad3a0fb7 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -60,80 +60,80 @@ internal sealed class EmulationModule : Module, IEmulationModule public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetTimezoneOverrideParameters(timezone, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetTimezoneOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetTimezoneOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetUserAgentOverrideAsync(string? userAgent, SetUserAgentOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetUserAgentOverrideParameters(userAgent, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetUserAgentOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetUserAgentOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetLocaleOverrideAsync(string? locale, SetLocaleOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetLocaleOverrideParameters(locale, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetLocaleOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetLocaleOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetForcedColorsModeThemeOverrideAsync(ForcedColorsModeTheme? theme, SetForcedColorsModeThemeOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetForcedColorsModeThemeOverrideParameters(theme, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetForcedColorsModeThemeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetForcedColorsModeThemeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScriptingEnabledAsync(bool? enabled, SetScriptingEnabledOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScriptingEnabledParameters(enabled, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetScriptingEnabledCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetScriptingEnabledCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScreenOrientationOverrideAsync(ScreenOrientation? screenOrientation, SetScreenOrientationOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScreenOrientationOverrideParameters(screenOrientation, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetScreenOrientationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetScreenOrientationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScreenSettingsOverrideAsync(ScreenArea? screenArea, SetScreenSettingsOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScreenSettingsOverrideParameters(screenArea, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetScreenSettingsOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetScreenSettingsOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetScrollbarTypeOverrideAsync(ScrollbarType? scrollbarType, SetScrollbarTypeOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetScrollbarTypeOverrideParameters(scrollbarType, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetScrollbarTypeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetScrollbarTypeOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationCoordinatesOverrideAsync(double latitude, double longitude, SetGeolocationCoordinatesOverrideOptions? options = null, CancellationToken cancellationToken = default) { var coordinates = new GeolocationCoordinates(latitude, longitude, options?.Accuracy, options?.Altitude, options?.AltitudeAccuracy, options?.Heading, options?.Speed); var @params = new SetGeolocationOverrideCoordinatesParameters(coordinates, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationCoordinatesOverrideAsync(SetGeolocationOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetGeolocationOverrideCoordinatesParameters(null, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetGeolocationPositionErrorOverrideAsync(SetGeolocationPositionErrorOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetGeolocationOverridePositionErrorParameters(new GeolocationPositionError(), options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetGeolocationOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetTouchOverrideAsync(long? maxTouchPoints, SetTouchOverrideOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetTouchOverrideParameters(maxTouchPoints, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetTouchOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetTouchOverrideCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetNetworkConditionsAsync(NetworkConditions? networkConditions, SetNetworkConditionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetNetworkConditionsParameters(networkConditions, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetNetworkConditionsCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetNetworkConditionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 0c5e59b1e6c11..6eab864a3749a 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -37,21 +37,21 @@ public async Task PerformActionsAsync(BrowsingContext.Brow { var @params = new PerformActionsParameters(context, actions); - return await ExecuteCommandAsync(PerformActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(PerformActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ReleaseActionsAsync(BrowsingContext.BrowsingContext context, ReleaseActionsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ReleaseActionsParameters(context); - return await ExecuteCommandAsync(ReleaseActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ReleaseActionsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable files, SetFilesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetFilesParameters(context, element, files); - return await ExecuteCommandAsync(SetFilesCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetFilesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnFileDialogOpenedAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index cf7705f0a69cb..f9df822aa1c96 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -25,11 +25,11 @@ public abstract class Module { private Broker Broker { get; set; } = null!; - protected Task ExecuteCommandAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + protected Task ExecuteAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) where TParameters : Parameters where TResult : EmptyResult { - return Broker.ExecuteCommandAsync(descriptor, @params, options, cancellationToken); + return Broker.ExecuteAsync(descriptor, @params, options, cancellationToken); } protected Task SubscribeAsync(string name, Action action, Func factory, SubscriptionOptions? options, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index 21e50b6e1cd56..cd822796f950f 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -65,70 +65,70 @@ public async Task AddDataCollectorAsync(IEnumerable AddInterceptAsync(IEnumerable phases, AddInterceptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddInterceptParameters(phases, options?.Contexts, options?.UrlPatterns); - return await ExecuteCommandAsync(AddInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(AddInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveDataCollectorAsync(Collector collector, RemoveDataCollectorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveDataCollectorParameters(collector); - return await ExecuteCommandAsync(RemoveDataCollectorCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(RemoveDataCollectorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemoveInterceptAsync(Intercept intercept, RemoveInterceptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemoveInterceptParameters(intercept); - return await ExecuteCommandAsync(RemoveInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(RemoveInterceptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetCacheBehaviorAsync(CacheBehavior behavior, SetCacheBehaviorOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetCacheBehaviorParameters(behavior, options?.Contexts); - return await ExecuteCommandAsync(SetCacheBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetCacheBehaviorCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetExtraHeadersAsync(IEnumerable
headers, SetExtraHeadersOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetExtraHeadersParameters(headers, options?.Contexts, options?.UserContexts); - return await ExecuteCommandAsync(SetExtraHeadersCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetExtraHeadersCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueRequestAsync(Request request, ContinueRequestOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ContinueRequestParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.Method, options?.Url); - return await ExecuteCommandAsync(ContinueRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ContinueRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueResponseAsync(Request request, ContinueResponseOptions? options = null, CancellationToken cancellationToken = default) { var @params = new ContinueResponseParameters(request, options?.Cookies, options?.Credentials, options?.Headers, options?.ReasonPhrase, options?.StatusCode); - return await ExecuteCommandAsync(ContinueResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ContinueResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task FailRequestAsync(Request request, FailRequestOptions? options = null, CancellationToken cancellationToken = default) { var @params = new FailRequestParameters(request); - return await ExecuteCommandAsync(FailRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(FailRequestCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetDataAsync(DataType dataType, Request request, GetDataOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetDataParameters(dataType, request, options?.Collector, options?.Disown); - var result = await ExecuteCommandAsync(GetDataCommand, @params, options, cancellationToken).ConfigureAwait(false); + var result = await ExecuteAsync(GetDataCommand, @params, options, cancellationToken).ConfigureAwait(false); return result.Bytes; } @@ -137,22 +137,22 @@ public async Task ProvideResponseAsync(Request request, P { var @params = new ProvideResponseParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.ReasonPhrase, options?.StatusCode); - return await ExecuteCommandAsync(ProvideResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ProvideResponseCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthCredentials(request, credentials), options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ContinueWithAuthCommand, new ContinueWithAuthCredentials(request, credentials), options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, ContinueWithAuthDefaultCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthDefaultCredentials(request), options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ContinueWithAuthCommand, new ContinueWithAuthDefaultCredentials(request), options, cancellationToken).ConfigureAwait(false); } public async Task ContinueWithAuthAsync(Request request, ContinueWithAuthCancelCredentialsOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(ContinueWithAuthCommand, new ContinueWithAuthCancelCredentials(request), options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(ContinueWithAuthCommand, new ContinueWithAuthCancelCredentials(request), options, cancellationToken).ConfigureAwait(false); } public async Task OnBeforeRequestSentAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 3503fecd08116..6c040c90c9e6b 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -31,7 +31,7 @@ public async Task SetPermissionAsync(PermissionDescriptor d { var @params = new SetPermissionCommandParameters(descriptor, state, origin, options?.EmbeddedOrigin, options?.UserContext); - return await ExecuteCommandAsync(SetPermissionCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetPermissionCommand, @params, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index c52058eb948bf..fd716a8952bdf 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -47,7 +47,7 @@ public async Task EvaluateAsync([StringSyntax(StringSyntaxConsta { var @params = new EvaluateParameters(expression, target, awaitPromise, options?.ResultOwnership, options?.SerializationOptions, options?.UserActivation); - return await ExecuteCommandAsync(EvaluateCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(EvaluateCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) @@ -61,7 +61,7 @@ public async Task CallFunctionAsync([StringSyntax(StringSyntaxCo { var @params = new CallFunctionParameters(functionDeclaration, awaitPromise, target, options?.Arguments, options?.ResultOwnership, options?.SerializationOptions, options?.This, options?.UserActivation); - return await ExecuteCommandAsync(CallFunctionCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(CallFunctionCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task CallFunctionAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string functionDeclaration, bool awaitPromise, Target target, CallFunctionOptions? options = null, CancellationToken cancellationToken = default) @@ -75,28 +75,28 @@ public async Task DisownAsync(IEnumerable handles, Target { var @params = new DisownParameters(handles, target); - return await ExecuteCommandAsync(DisownCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(DisownCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task GetRealmsAsync(GetRealmsOptions? options = null, CancellationToken cancellationToken = default) { var @params = new GetRealmsParameters(options?.Context, options?.Type); - return await ExecuteCommandAsync(GetRealmsCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(GetRealmsCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task AddPreloadScriptAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string functionDeclaration, AddPreloadScriptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new AddPreloadScriptParameters(functionDeclaration, options?.Arguments, options?.Contexts, options?.UserContexts, options?.Sandbox); - return await ExecuteCommandAsync(AddPreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(AddPreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task RemovePreloadScriptAsync(PreloadScript script, RemovePreloadScriptOptions? options = null, CancellationToken cancellationToken = default) { var @params = new RemovePreloadScriptParameters(script); - return await ExecuteCommandAsync(RemovePreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(RemovePreloadScriptCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task OnMessageAsync(Func handler, SubscriptionOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 9dfaa44e311dd..30d81070e7bbe 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -41,33 +41,33 @@ internal sealed class SessionModule : Module, ISessionModule public async Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(StatusCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(StatusCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } public async Task SubscribeAsync(IEnumerable events, SubscribeOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SubscribeParameters(events, options?.Contexts); - return await ExecuteCommandAsync(SubscribeCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SubscribeCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task UnsubscribeAsync(IEnumerable subscriptions, UnsubscribeByIdOptions? options = null, CancellationToken cancellationToken = default) { var @params = new UnsubscribeByIdParameters(subscriptions); - return await ExecuteCommandAsync(UnsubscribeByIdCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(UnsubscribeByIdCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task NewAsync(CapabilitiesRequest capabilities, NewOptions? options = null, CancellationToken cancellationToken = default) { var @params = new NewParameters(capabilities); - return await ExecuteCommandAsync(NewCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(NewCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task EndAsync(EndOptions? options = null, CancellationToken cancellationToken = default) { - return await ExecuteCommandAsync(EndCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(EndCommand, Parameters.Empty, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index 3c824a7b5f1f8..f13721ab56884 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -37,21 +37,21 @@ public async Task GetCookiesAsync(GetCookiesOptions? options = { var @params = new GetCookiesParameters(options?.Filter, options?.Partition); - return await ExecuteCommandAsync(GetCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(GetCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task DeleteCookiesAsync(DeleteCookiesOptions? options = null, CancellationToken cancellationToken = default) { var @params = new DeleteCookiesParameters(options?.Filter, options?.Partition); - return await ExecuteCommandAsync(DeleteCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(DeleteCookiesCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task SetCookieAsync(PartialCookie cookie, SetCookieOptions? options = null, CancellationToken cancellationToken = default) { var @params = new SetCookieParameters(cookie, options?.Partition); - return await ExecuteCommandAsync(SetCookieCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(SetCookieCommand, @params, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 8aeb6df54df2a..3a03167b8fdbd 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -34,14 +34,14 @@ public async Task InstallAsync(ExtensionData extensionData, Insta { var @params = new InstallParameters(extensionData); - return await ExecuteCommandAsync(InstallCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(InstallCommand, @params, options, cancellationToken).ConfigureAwait(false); } public async Task UninstallAsync(Extension extension, UninstallOptions? options = null, CancellationToken cancellationToken = default) { var @params = new UninstallParameters(extension); - return await ExecuteCommandAsync(UninstallCommand, @params, options, cancellationToken).ConfigureAwait(false); + return await ExecuteAsync(UninstallCommand, @params, options, cancellationToken).ConfigureAwait(false); } } diff --git a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs index 01b46c6675aad..39ac19b2479a1 100644 --- a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs +++ b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs @@ -84,7 +84,7 @@ class CustomModule : Module public async Task DoSomethingAsync(DoSomethingOptions options = null) { - return await ExecuteCommandAsync(DoSomethingCommand, Parameters.Empty, options, CancellationToken.None); + return await ExecuteAsync(DoSomethingCommand, Parameters.Empty, options, CancellationToken.None); } } From 6add3d127f4ddf65842226458d25ff8f424ebafe Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:26:54 +0300 Subject: [PATCH 07/11] Simplify to Command<,> --- dotnet/src/webdriver/BiDi/Broker.cs | 2 +- .../webdriver/BiDi/Browser/BrowserModule.cs | 12 +++++----- .../BrowsingContext/BrowsingContextModule.cs | 24 +++++++++---------- dotnet/src/webdriver/BiDi/Command.cs | 2 +- .../BiDi/Emulation/EmulationModule.cs | 22 ++++++++--------- .../src/webdriver/BiDi/Input/InputModule.cs | 6 ++--- dotnet/src/webdriver/BiDi/Module.cs | 2 +- .../webdriver/BiDi/Network/NetworkModule.cs | 24 +++++++++---------- .../BiDi/Permissions/PermissionsModule.cs | 2 +- .../src/webdriver/BiDi/Script/ScriptModule.cs | 12 +++++----- .../webdriver/BiDi/Session/SessionModule.cs | 10 ++++---- .../webdriver/BiDi/Storage/StorageModule.cs | 6 ++--- .../BiDi/WebExtension/WebExtensionModule.cs | 4 ++-- .../webdriver/BiDi/Session/SessionTests.cs | 2 +- 14 files changed, 65 insertions(+), 65 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Broker.cs b/dotnet/src/webdriver/BiDi/Broker.cs index f277f01f13190..d039d85edbb22 100644 --- a/dotnet/src/webdriver/BiDi/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Broker.cs @@ -114,7 +114,7 @@ public async ValueTask UnsubscribeAsync(Subscription subscription, CancellationT _eventDispatcher.RemoveHandler(subscription.EventName, subscription.Handler); } - public async Task ExecuteAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + public async Task ExecuteAsync(Command descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) where TParameters : Parameters where TResult : EmptyResult { diff --git a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs index 964797bc4d2ff..d0e847adaf826 100644 --- a/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs +++ b/dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs @@ -24,22 +24,22 @@ namespace OpenQA.Selenium.BiDi.Browser; internal sealed class BrowserModule : Module, IBrowserModule { - private static readonly CommandDescriptor CloseCommand = new( + private static readonly Command CloseCommand = new( "browser.close", Default.Parameters, Default.CloseResult); - private static readonly CommandDescriptor CreateUserContextCommand = new( + private static readonly Command CreateUserContextCommand = new( "browser.createUserContext", Default.CreateUserContextParameters, Default.CreateUserContextResult); - private static readonly CommandDescriptor GetUserContextsCommand = new( + private static readonly Command GetUserContextsCommand = new( "browser.getUserContexts", Default.Parameters, Default.GetUserContextsResult); - private static readonly CommandDescriptor RemoveUserContextCommand = new( + private static readonly Command RemoveUserContextCommand = new( "browser.removeUserContext", Default.RemoveUserContextParameters, Default.RemoveUserContextResult); - private static readonly CommandDescriptor GetClientWindowsCommand = new( + private static readonly Command GetClientWindowsCommand = new( "browser.getClientWindows", Default.Parameters, Default.GetClientWindowsResult); - private static readonly CommandDescriptor SetDownloadBehaviorCommand = new( + private static readonly Command SetDownloadBehaviorCommand = new( "browser.setDownloadBehavior", Default.SetDownloadBehaviorParameters, Default.SetDownloadBehaviorResult); public async Task CloseAsync(CloseOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs index 4d7ec074feb5f..da8ddf663238a 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs @@ -24,40 +24,40 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext; internal sealed class BrowsingContextModule : Module, IBrowsingContextModule { - private static readonly CommandDescriptor CreateCommand = new( + private static readonly Command CreateCommand = new( "browsingContext.create", Default.CreateParameters, Default.CreateResult); - private static readonly CommandDescriptor NavigateCommand = new( + private static readonly Command NavigateCommand = new( "browsingContext.navigate", Default.NavigateParameters, Default.NavigateResult); - private static readonly CommandDescriptor ActivateCommand = new( + private static readonly Command ActivateCommand = new( "browsingContext.activate", Default.ActivateParameters, Default.ActivateResult); - private static readonly CommandDescriptor LocateNodesCommand = new( + private static readonly Command LocateNodesCommand = new( "browsingContext.locateNodes", Default.LocateNodesParameters, Default.LocateNodesResult); - private static readonly CommandDescriptor CaptureScreenshotCommand = new( + private static readonly Command CaptureScreenshotCommand = new( "browsingContext.captureScreenshot", Default.CaptureScreenshotParameters, Default.CaptureScreenshotResult); - private static readonly CommandDescriptor CloseCommand = new( + private static readonly Command CloseCommand = new( "browsingContext.close", Default.CloseParameters, Default.CloseResult); - private static readonly CommandDescriptor TraverseHistoryCommand = new( + private static readonly Command TraverseHistoryCommand = new( "browsingContext.traverseHistory", Default.TraverseHistoryParameters, Default.TraverseHistoryResult); - private static readonly CommandDescriptor ReloadCommand = new( + private static readonly Command ReloadCommand = new( "browsingContext.reload", Default.ReloadParameters, Default.ReloadResult); - private static readonly CommandDescriptor SetViewportCommand = new( + private static readonly Command SetViewportCommand = new( "browsingContext.setViewport", Default.SetViewportParameters, Default.SetViewportResult); - private static readonly CommandDescriptor GetTreeCommand = new( + private static readonly Command GetTreeCommand = new( "browsingContext.getTree", Default.GetTreeParameters, Default.GetTreeResult); - private static readonly CommandDescriptor PrintCommand = new( + private static readonly Command PrintCommand = new( "browsingContext.print", Default.PrintParameters, Default.PrintResult); - private static readonly CommandDescriptor HandleUserPromptCommand = new( + private static readonly Command HandleUserPromptCommand = new( "browsingContext.handleUserPrompt", Default.HandleUserPromptParameters, Default.HandleUserPromptResult); public async Task CreateAsync(ContextType type, CreateOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index 8d0bb59da7266..b10af0e2f817e 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -21,7 +21,7 @@ namespace OpenQA.Selenium.BiDi; -public sealed class CommandDescriptor( +public sealed class Command( string method, JsonTypeInfo paramsTypeInfo, JsonTypeInfo resultTypeInfo) diff --git a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs index ce291ad3a0fb7..82fd31828e8a0 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs @@ -24,37 +24,37 @@ namespace OpenQA.Selenium.BiDi.Emulation; internal sealed class EmulationModule : Module, IEmulationModule { - private static readonly CommandDescriptor SetTimezoneOverrideCommand = new( + private static readonly Command SetTimezoneOverrideCommand = new( "emulation.setTimezoneOverride", Default.SetTimezoneOverrideParameters, Default.SetTimezoneOverrideResult); - private static readonly CommandDescriptor SetUserAgentOverrideCommand = new( + private static readonly Command SetUserAgentOverrideCommand = new( "emulation.setUserAgentOverride", Default.SetUserAgentOverrideParameters, Default.SetUserAgentOverrideResult); - private static readonly CommandDescriptor SetLocaleOverrideCommand = new( + private static readonly Command SetLocaleOverrideCommand = new( "emulation.setLocaleOverride", Default.SetLocaleOverrideParameters, Default.SetLocaleOverrideResult); - private static readonly CommandDescriptor SetForcedColorsModeThemeOverrideCommand = new( + private static readonly Command SetForcedColorsModeThemeOverrideCommand = new( "emulation.setForcedColorsModeThemeOverride", Default.SetForcedColorsModeThemeOverrideParameters, Default.SetForcedColorsModeThemeOverrideResult); - private static readonly CommandDescriptor SetScriptingEnabledCommand = new( + private static readonly Command SetScriptingEnabledCommand = new( "emulation.setScriptingEnabled", Default.SetScriptingEnabledParameters, Default.SetScriptingEnabledResult); - private static readonly CommandDescriptor SetScreenOrientationOverrideCommand = new( + private static readonly Command SetScreenOrientationOverrideCommand = new( "emulation.setScreenOrientationOverride", Default.SetScreenOrientationOverrideParameters, Default.SetScreenOrientationOverrideResult); - private static readonly CommandDescriptor SetScreenSettingsOverrideCommand = new( + private static readonly Command SetScreenSettingsOverrideCommand = new( "emulation.setScreenSettingsOverride", Default.SetScreenSettingsOverrideParameters, Default.SetScreenSettingsOverrideResult); - private static readonly CommandDescriptor SetScrollbarTypeOverrideCommand = new( + private static readonly Command SetScrollbarTypeOverrideCommand = new( "emulation.setScrollbarTypeOverride", Default.SetScrollbarTypeOverrideParameters, Default.SetScrollbarTypeOverrideResult); - private static readonly CommandDescriptor SetGeolocationOverrideCommand = new( + private static readonly Command SetGeolocationOverrideCommand = new( "emulation.setGeolocationOverride", Default.SetGeolocationOverrideParameters, Default.SetGeolocationOverrideResult); - private static readonly CommandDescriptor SetTouchOverrideCommand = new( + private static readonly Command SetTouchOverrideCommand = new( "emulation.setTouchOverride", Default.SetTouchOverrideParameters, Default.SetTouchOverrideResult); - private static readonly CommandDescriptor SetNetworkConditionsCommand = new( + private static readonly Command SetNetworkConditionsCommand = new( "emulation.setNetworkConditions", Default.SetNetworkConditionsParameters, Default.SetNetworkConditionsResult); public async Task SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Input/InputModule.cs b/dotnet/src/webdriver/BiDi/Input/InputModule.cs index 6eab864a3749a..1673fa74ce5a1 100644 --- a/dotnet/src/webdriver/BiDi/Input/InputModule.cs +++ b/dotnet/src/webdriver/BiDi/Input/InputModule.cs @@ -24,13 +24,13 @@ namespace OpenQA.Selenium.BiDi.Input; internal sealed class InputModule : Module, IInputModule { - private static readonly CommandDescriptor PerformActionsCommand = new( + private static readonly Command PerformActionsCommand = new( "input.performActions", Default.PerformActionsParameters, Default.PerformActionsResult); - private static readonly CommandDescriptor ReleaseActionsCommand = new( + private static readonly Command ReleaseActionsCommand = new( "input.releaseActions", Default.ReleaseActionsParameters, Default.ReleaseActionsResult); - private static readonly CommandDescriptor SetFilesCommand = new( + private static readonly Command SetFilesCommand = new( "input.setFiles", Default.SetFilesParameters, Default.SetFilesResult); public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable actions, PerformActionsOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Module.cs b/dotnet/src/webdriver/BiDi/Module.cs index f9df822aa1c96..934406b253f0a 100644 --- a/dotnet/src/webdriver/BiDi/Module.cs +++ b/dotnet/src/webdriver/BiDi/Module.cs @@ -25,7 +25,7 @@ public abstract class Module { private Broker Broker { get; set; } = null!; - protected Task ExecuteAsync(CommandDescriptor descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) + protected Task ExecuteAsync(Command descriptor, TParameters @params, CommandOptions? options, CancellationToken cancellationToken) where TParameters : Parameters where TResult : EmptyResult { diff --git a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs index cd822796f950f..6b2613ce25234 100644 --- a/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Network/NetworkModule.cs @@ -25,40 +25,40 @@ namespace OpenQA.Selenium.BiDi.Network; internal sealed partial class NetworkModule : Module, INetworkModule { - private static readonly CommandDescriptor AddDataCollectorCommand = new( + private static readonly Command AddDataCollectorCommand = new( "network.addDataCollector", Default.AddDataCollectorParameters, Default.AddDataCollectorResult); - private static readonly CommandDescriptor AddInterceptCommand = new( + private static readonly Command AddInterceptCommand = new( "network.addIntercept", Default.AddInterceptParameters, Default.AddInterceptResult); - private static readonly CommandDescriptor RemoveDataCollectorCommand = new( + private static readonly Command RemoveDataCollectorCommand = new( "network.removeDataCollector", Default.RemoveDataCollectorParameters, Default.RemoveDataCollectorResult); - private static readonly CommandDescriptor RemoveInterceptCommand = new( + private static readonly Command RemoveInterceptCommand = new( "network.removeIntercept", Default.RemoveInterceptParameters, Default.RemoveInterceptResult); - private static readonly CommandDescriptor SetCacheBehaviorCommand = new( + private static readonly Command SetCacheBehaviorCommand = new( "network.setCacheBehavior", Default.SetCacheBehaviorParameters, Default.SetCacheBehaviorResult); - private static readonly CommandDescriptor SetExtraHeadersCommand = new( + private static readonly Command SetExtraHeadersCommand = new( "network.setExtraHeaders", Default.SetExtraHeadersParameters, Default.SetExtraHeadersResult); - private static readonly CommandDescriptor ContinueRequestCommand = new( + private static readonly Command ContinueRequestCommand = new( "network.continueRequest", Default.ContinueRequestParameters, Default.ContinueRequestResult); - private static readonly CommandDescriptor ContinueResponseCommand = new( + private static readonly Command ContinueResponseCommand = new( "network.continueResponse", Default.ContinueResponseParameters, Default.ContinueResponseResult); - private static readonly CommandDescriptor FailRequestCommand = new( + private static readonly Command FailRequestCommand = new( "network.failRequest", Default.FailRequestParameters, Default.FailRequestResult); - private static readonly CommandDescriptor GetDataCommand = new( + private static readonly Command GetDataCommand = new( "network.getData", Default.GetDataParameters, Default.GetDataResult); - private static readonly CommandDescriptor ProvideResponseCommand = new( + private static readonly Command ProvideResponseCommand = new( "network.provideResponse", Default.ProvideResponseParameters, Default.ProvideResponseResult); - private static readonly CommandDescriptor ContinueWithAuthCommand = new( + private static readonly Command ContinueWithAuthCommand = new( "network.continueWithAuth", Default.ContinueWithAuthParameters, Default.ContinueWithAuthResult); public async Task AddDataCollectorAsync(IEnumerable dataTypes, int maxEncodedDataSize, AddDataCollectorOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs index 6c040c90c9e6b..61031431f9457 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/PermissionsModule.cs @@ -24,7 +24,7 @@ namespace OpenQA.Selenium.BiDi.Permissions; internal sealed class PermissionsModule : Module, IPermissionsModule { - private static readonly CommandDescriptor SetPermissionCommand = new( + private static readonly Command SetPermissionCommand = new( "permissions.setPermission", Default.SetPermissionCommandParameters, Default.SetPermissionResult); public async Task SetPermissionAsync(PermissionDescriptor descriptor, PermissionState state, string origin, SetPermissionOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs index fd716a8952bdf..3f6353dd68c2b 100644 --- a/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Script/ScriptModule.cs @@ -25,22 +25,22 @@ namespace OpenQA.Selenium.BiDi.Script; internal sealed class ScriptModule : Module, IScriptModule { - private static readonly CommandDescriptor EvaluateCommand = new( + private static readonly Command EvaluateCommand = new( "script.evaluate", Default.EvaluateParameters, Default.EvaluateResult); - private static readonly CommandDescriptor CallFunctionCommand = new( + private static readonly Command CallFunctionCommand = new( "script.callFunction", Default.CallFunctionParameters, Default.EvaluateResult); - private static readonly CommandDescriptor DisownCommand = new( + private static readonly Command DisownCommand = new( "script.disown", Default.DisownParameters, Default.DisownResult); - private static readonly CommandDescriptor GetRealmsCommand = new( + private static readonly Command GetRealmsCommand = new( "script.getRealms", Default.GetRealmsParameters, Default.GetRealmsResult); - private static readonly CommandDescriptor AddPreloadScriptCommand = new( + private static readonly Command AddPreloadScriptCommand = new( "script.addPreloadScript", Default.AddPreloadScriptParameters, Default.AddPreloadScriptResult); - private static readonly CommandDescriptor RemovePreloadScriptCommand = new( + private static readonly Command RemovePreloadScriptCommand = new( "script.removePreloadScript", Default.RemovePreloadScriptParameters, Default.RemovePreloadScriptResult); public async Task EvaluateAsync([StringSyntax(StringSyntaxConstants.JavaScript)] string expression, bool awaitPromise, Target target, EvaluateOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs index 30d81070e7bbe..f9234efae1ff9 100644 --- a/dotnet/src/webdriver/BiDi/Session/SessionModule.cs +++ b/dotnet/src/webdriver/BiDi/Session/SessionModule.cs @@ -24,19 +24,19 @@ namespace OpenQA.Selenium.BiDi.Session; internal sealed class SessionModule : Module, ISessionModule { - private static readonly CommandDescriptor StatusCommand = new( + private static readonly Command StatusCommand = new( "session.status", Default.Parameters, Default.StatusResult); - private static readonly CommandDescriptor NewCommand = new( + private static readonly Command NewCommand = new( "session.new", Default.NewParameters, Default.NewResult); - private static readonly CommandDescriptor EndCommand = new( + private static readonly Command EndCommand = new( "session.end", Default.Parameters, Default.EndResult); - private static readonly CommandDescriptor SubscribeCommand = new( + private static readonly Command SubscribeCommand = new( "session.subscribe", Default.SubscribeParameters, Default.SubscribeResult); - private static readonly CommandDescriptor UnsubscribeByIdCommand = new( + private static readonly Command UnsubscribeByIdCommand = new( "session.unsubscribe", Default.UnsubscribeByIdParameters, Default.UnsubscribeResult); public async Task StatusAsync(StatusOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs index f13721ab56884..a9339e890842d 100644 --- a/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs +++ b/dotnet/src/webdriver/BiDi/Storage/StorageModule.cs @@ -24,13 +24,13 @@ namespace OpenQA.Selenium.BiDi.Storage; internal sealed class StorageModule : Module, IStorageModule { - private static readonly CommandDescriptor GetCookiesCommand = new( + private static readonly Command GetCookiesCommand = new( "storage.getCookies", Default.GetCookiesParameters, Default.GetCookiesResult); - private static readonly CommandDescriptor DeleteCookiesCommand = new( + private static readonly Command DeleteCookiesCommand = new( "storage.deleteCookies", Default.DeleteCookiesParameters, Default.DeleteCookiesResult); - private static readonly CommandDescriptor SetCookieCommand = new( + private static readonly Command SetCookieCommand = new( "storage.setCookie", Default.SetCookieParameters, Default.SetCookieResult); public async Task GetCookiesAsync(GetCookiesOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs index 3a03167b8fdbd..baf108a201b99 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/WebExtensionModule.cs @@ -24,10 +24,10 @@ namespace OpenQA.Selenium.BiDi.WebExtension; internal sealed class WebExtensionModule : Module, IWebExtensionModule { - private static readonly CommandDescriptor InstallCommand = new( + private static readonly Command InstallCommand = new( "webExtension.install", Default.InstallParameters, Default.InstallResult); - private static readonly CommandDescriptor UninstallCommand = new( + private static readonly Command UninstallCommand = new( "webExtension.uninstall", Default.UninstallParameters, Default.UninstallResult); public async Task InstallAsync(ExtensionData extensionData, InstallOptions? options = null, CancellationToken cancellationToken = default) diff --git a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs index 39ac19b2479a1..8a3aa7f62ede2 100644 --- a/dotnet/test/webdriver/BiDi/Session/SessionTests.cs +++ b/dotnet/test/webdriver/BiDi/Session/SessionTests.cs @@ -79,7 +79,7 @@ class CustomModule : Module { private static readonly CustomModuleJsonSerializerContext JsonContext = CustomModuleJsonSerializerContext.Default; - private static readonly CommandDescriptor DoSomethingCommand = + private static readonly Command DoSomethingCommand = new("session.status", JsonContext.Parameters, JsonContext.DoSomethingResult); public async Task DoSomethingAsync(DoSomethingOptions options = null) From c19a91ab3298d3c3b4400cc3d12d4518bb6f3215 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:49:19 +0300 Subject: [PATCH 08/11] TryRemove pending command --- dotnet/src/webdriver/BiDi/Broker.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Broker.cs b/dotnet/src/webdriver/BiDi/Broker.cs index d039d85edbb22..3e1b49783f16b 100644 --- a/dotnet/src/webdriver/BiDi/Broker.cs +++ b/dotnet/src/webdriver/BiDi/Broker.cs @@ -295,7 +295,7 @@ private void ProcessReceivedMessage(ReadOnlySpan data) case TypeSuccess: if (id is null) throw new BiDiException("The remote end responded with 'success' message type, but missed required 'id' property."); - if (_pendingCommands.TryGetValue(id.Value, out var command)) + if (_pendingCommands.TryRemove(id.Value, out var command)) { try { @@ -308,10 +308,6 @@ private void ProcessReceivedMessage(ReadOnlySpan data) { command.TaskCompletionSource.TrySetException(ex); } - finally - { - _pendingCommands.TryRemove(id.Value, out _); - } } else { @@ -347,10 +343,9 @@ private void ProcessReceivedMessage(ReadOnlySpan data) case TypeError: if (id is null) throw new BiDiException($"The remote end responded with 'error' message type, but missed required 'id' property. Message content: {System.Text.Encoding.UTF8.GetString(data.ToArray())}"); - if (_pendingCommands.TryGetValue(id.Value, out var errorCommand)) + if (_pendingCommands.TryRemove(id.Value, out var errorCommand)) { errorCommand.TaskCompletionSource.TrySetException(new BiDiException($"{error}: {message}")); - _pendingCommands.TryRemove(id.Value, out _); } else { From 4a689f31a135d7247fd29bb5366f65753c688565 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:52:06 +0300 Subject: [PATCH 09/11] Command struct --- dotnet/src/webdriver/BiDi/Command.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index b10af0e2f817e..42a0ee1935efe 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -21,17 +21,12 @@ namespace OpenQA.Selenium.BiDi; -public sealed class Command( - string method, - JsonTypeInfo paramsTypeInfo, - JsonTypeInfo resultTypeInfo) +public readonly record struct Command( + string Method, + JsonTypeInfo ParamsTypeInfo, + JsonTypeInfo ResultTypeInfo) where TParameters : Parameters - where TResult : EmptyResult -{ - public string Method { get; } = method; - public JsonTypeInfo ParamsTypeInfo { get; } = paramsTypeInfo; - public JsonTypeInfo ResultTypeInfo { get; } = resultTypeInfo; -} + where TResult : EmptyResult; public record Parameters { From e1314cd9233f7be6019a8cdeb0df1205d6518837 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 02:50:46 +0300 Subject: [PATCH 10/11] copyright --- dotnet/src/webdriver/BiDi/Browser/Close.cs | 2 +- dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs | 2 +- dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs | 2 +- dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs | 2 +- dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs | 2 +- dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs | 2 +- dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs | 2 +- .../BiDi/Emulation/SetForcedColorsModeThemeOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs | 2 +- .../webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs | 2 +- .../src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs | 2 +- dotnet/src/webdriver/BiDi/Input/PerformActions.cs | 2 +- dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs | 2 +- dotnet/src/webdriver/BiDi/Input/SetFiles.cs | 2 +- dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs | 2 +- dotnet/src/webdriver/BiDi/Network/AddIntercept.cs | 2 +- dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs | 2 +- dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs | 2 +- dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs | 2 +- dotnet/src/webdriver/BiDi/Network/FailRequest.cs | 2 +- dotnet/src/webdriver/BiDi/Network/GetData.cs | 2 +- dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs | 2 +- dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs | 2 +- dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs | 2 +- dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs | 2 +- dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs | 2 +- dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs | 2 +- dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs | 2 +- dotnet/src/webdriver/BiDi/Script/CallFunction.cs | 2 +- dotnet/src/webdriver/BiDi/Script/Disown.cs | 2 +- dotnet/src/webdriver/BiDi/Script/Evaluate.cs | 2 +- dotnet/src/webdriver/BiDi/Script/GetRealms.cs | 2 +- dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs | 2 +- dotnet/src/webdriver/BiDi/Session/End.cs | 2 +- dotnet/src/webdriver/BiDi/Session/New.cs | 2 +- dotnet/src/webdriver/BiDi/Session/Status.cs | 2 +- dotnet/src/webdriver/BiDi/Session/Subscribe.cs | 2 +- dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/GetCookies.cs | 2 +- dotnet/src/webdriver/BiDi/Storage/SetCookie.cs | 2 +- dotnet/src/webdriver/BiDi/WebExtension/Install.cs | 2 +- dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs | 2 +- 61 files changed, 61 insertions(+), 61 deletions(-) diff --git a/dotnet/src/webdriver/BiDi/Browser/Close.cs b/dotnet/src/webdriver/BiDi/Browser/Close.cs index 5bd6725cdaae9..5efc9a1d676b8 100644 --- a/dotnet/src/webdriver/BiDi/Browser/Close.cs +++ b/dotnet/src/webdriver/BiDi/Browser/Close.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs b/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs index eb9ca1aee3d2b..b73759a0ac1f5 100644 --- a/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs +++ b/dotnet/src/webdriver/BiDi/Browser/CreateUserContext.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs index b115ae0617a0f..c64f92b2f7e4e 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetClientWindows.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs index a2330b721520d..f8e9ca7dffcd7 100644 --- a/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs +++ b/dotnet/src/webdriver/BiDi/Browser/GetUserContexts.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs b/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs index e46b48febf317..fad7cf28f3358 100644 --- a/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs +++ b/dotnet/src/webdriver/BiDi/Browser/RemoveUserContext.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs index 45885d802ffa4..aef71f681dc28 100644 --- a/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs +++ b/dotnet/src/webdriver/BiDi/Browser/SetDownloadBehavior.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs index d1e1311e02be6..4e241347f41d2 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Activate.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs index 57dec7ead70a0..cadf54f01a793 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/CaptureScreenshot.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs index 4e37eda2a190b..68217933227ca 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Close.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs index 0f62971fecf9c..bf3bbe6c9cfb8 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Create.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs index e43ea65359110..8c862bb368185 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/GetTree.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs index 667742010ef88..0c0139cd8c450 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/HandleUserPrompt.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs index df84e0be5d2d9..ba26c934d91cb 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/LocateNodes.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs index 2a634bf5540df..5b84004a73941 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Navigate.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs index 6be3e07d3e583..886645743fb82 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Print.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs index 6bd17eda0b4a7..a0d038ddaba36 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/Reload.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs index ec56d99a3c18d..9df7438701872 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/SetViewport.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs b/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs index bfe712436cf11..f9c2196114ca9 100644 --- a/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs +++ b/dotnet/src/webdriver/BiDi/BrowsingContext/TraverseHistory.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs index 770c2c2143c49..4a47f47015ab4 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetForcedColorsModeThemeOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs index b0f6f77944477..3aef75e20846d 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetGeolocationOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs index f241fe6471fae..e3c0338c1e167 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetLocaleOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs index c8fdd98c5ac1a..cd16e78557ec3 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetNetworkConditions.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs index d49cb5e35dfd3..b68b5b6dfe174 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenOrientationOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs index a5df7bcda9143..c2d2076608f3b 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScreenSettingsOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs index 723c6ddaf1ba7..d38e840659be7 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScriptingEnabled.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs index 810816d495897..9c700d2d1f016 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetScrollbarTypeOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs index a08599b90987b..f1e3854ad8e08 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTimezoneOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs index 93db85bf586ad..aa1fcda9044df 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetTouchOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs index c5e0a878a4dc4..8aafecd0fced5 100644 --- a/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs +++ b/dotnet/src/webdriver/BiDi/Emulation/SetUserAgentOverride.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Input/PerformActions.cs b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs index 86117875cd643..4ec68d9608914 100644 --- a/dotnet/src/webdriver/BiDi/Input/PerformActions.cs +++ b/dotnet/src/webdriver/BiDi/Input/PerformActions.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs b/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs index 9bc773dc1aa0d..54ccb427cdc11 100644 --- a/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs +++ b/dotnet/src/webdriver/BiDi/Input/ReleaseActions.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Input/SetFiles.cs b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs index 2a4b0b9fa6d9c..5271088b4e784 100644 --- a/dotnet/src/webdriver/BiDi/Input/SetFiles.cs +++ b/dotnet/src/webdriver/BiDi/Input/SetFiles.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs index f1b74035d037e..a5db15c0843b5 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddDataCollector.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs index 56fba53e233b2..c8dbf1eca435d 100644 --- a/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs +++ b/dotnet/src/webdriver/BiDi/Network/AddIntercept.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs index 98873bd0e9dcd..5515ed8bd50de 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueRequest.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs index 9bbee6591ff6d..fe2c73289f9bc 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueResponse.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs b/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs index e1164eb25da39..a5805a9a6f33b 100644 --- a/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs +++ b/dotnet/src/webdriver/BiDi/Network/ContinueWithAuth.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/FailRequest.cs b/dotnet/src/webdriver/BiDi/Network/FailRequest.cs index f603ac955b41a..3a8b03ae511b7 100644 --- a/dotnet/src/webdriver/BiDi/Network/FailRequest.cs +++ b/dotnet/src/webdriver/BiDi/Network/FailRequest.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/GetData.cs b/dotnet/src/webdriver/BiDi/Network/GetData.cs index c0d0f3344420f..f8baf19ecf42b 100644 --- a/dotnet/src/webdriver/BiDi/Network/GetData.cs +++ b/dotnet/src/webdriver/BiDi/Network/GetData.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs index 43a89dc6ed69d..7564e5897ad2e 100644 --- a/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs +++ b/dotnet/src/webdriver/BiDi/Network/ProvideResponse.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs b/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs index 605539193b7ab..4ef49f4f10040 100644 --- a/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs +++ b/dotnet/src/webdriver/BiDi/Network/RemoveDataCollector.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs b/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs index 03f0df6757536..84b180508ad39 100644 --- a/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs +++ b/dotnet/src/webdriver/BiDi/Network/RemoveIntercept.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs index 5c67a6e7812f3..7307aff1a72cc 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetCacheBehavior.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs index 3003d0f1a3d18..c3305301085dc 100644 --- a/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs +++ b/dotnet/src/webdriver/BiDi/Network/SetExtraHeaders.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs b/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs index a95953983456d..3c4f5d607c105 100644 --- a/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs +++ b/dotnet/src/webdriver/BiDi/Permissions/SetPermission.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs index fa9acd9bddf23..d4601cc730fc3 100644 --- a/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs +++ b/dotnet/src/webdriver/BiDi/Script/AddPreloadScript.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/CallFunction.cs b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs index 30375fab9b1e7..2adbc739ecc38 100644 --- a/dotnet/src/webdriver/BiDi/Script/CallFunction.cs +++ b/dotnet/src/webdriver/BiDi/Script/CallFunction.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/Disown.cs b/dotnet/src/webdriver/BiDi/Script/Disown.cs index 1d6e9b8cb9992..cefd9d1bb520d 100644 --- a/dotnet/src/webdriver/BiDi/Script/Disown.cs +++ b/dotnet/src/webdriver/BiDi/Script/Disown.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/Evaluate.cs b/dotnet/src/webdriver/BiDi/Script/Evaluate.cs index ccbbbaba28757..a2ff995e08a7f 100644 --- a/dotnet/src/webdriver/BiDi/Script/Evaluate.cs +++ b/dotnet/src/webdriver/BiDi/Script/Evaluate.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/GetRealms.cs b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs index 2a8046b4fa0e0..8530150c508cc 100644 --- a/dotnet/src/webdriver/BiDi/Script/GetRealms.cs +++ b/dotnet/src/webdriver/BiDi/Script/GetRealms.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs b/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs index d1d210d08861c..aeee94d9aa3de 100644 --- a/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs +++ b/dotnet/src/webdriver/BiDi/Script/RemovePreloadScript.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Session/End.cs b/dotnet/src/webdriver/BiDi/Session/End.cs index 398e01937317e..374ae3e5aecad 100644 --- a/dotnet/src/webdriver/BiDi/Session/End.cs +++ b/dotnet/src/webdriver/BiDi/Session/End.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Session/New.cs b/dotnet/src/webdriver/BiDi/Session/New.cs index 38fb54ee90b43..56f539bd388d3 100644 --- a/dotnet/src/webdriver/BiDi/Session/New.cs +++ b/dotnet/src/webdriver/BiDi/Session/New.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Session/Status.cs b/dotnet/src/webdriver/BiDi/Session/Status.cs index 88523fa45b623..6f5ef3ca5f7ae 100644 --- a/dotnet/src/webdriver/BiDi/Session/Status.cs +++ b/dotnet/src/webdriver/BiDi/Session/Status.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Session/Subscribe.cs b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs index 6e68f60c23e53..ac6031262efd3 100644 --- a/dotnet/src/webdriver/BiDi/Session/Subscribe.cs +++ b/dotnet/src/webdriver/BiDi/Session/Subscribe.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs index 2d3954f6874cb..cd84ffab46346 100644 --- a/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs +++ b/dotnet/src/webdriver/BiDi/Session/Unsubscribe.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs b/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs index 71890e8d427a5..e30fd6c0771ca 100644 --- a/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs +++ b/dotnet/src/webdriver/BiDi/Storage/DeleteCookies.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs index 181044397e995..1518312ab8e38 100644 --- a/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs +++ b/dotnet/src/webdriver/BiDi/Storage/GetCookies.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs b/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs index 672df580c320d..2e26166ac8c51 100644 --- a/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs +++ b/dotnet/src/webdriver/BiDi/Storage/SetCookie.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/WebExtension/Install.cs b/dotnet/src/webdriver/BiDi/WebExtension/Install.cs index fc51995e7b476..337af96b9e1e8 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/Install.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/Install.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information diff --git a/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs b/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs index 263efbf5926a7..e07b6fd221063 100644 --- a/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs +++ b/dotnet/src/webdriver/BiDi/WebExtension/Uninstall.cs @@ -1,4 +1,4 @@ -// +// // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information From 510a122886b925976ecc3374cfcefa0c950a5b7b Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Fri, 10 Apr 2026 20:57:48 +0300 Subject: [PATCH 11/11] Move options defintion to Command --- dotnet/src/webdriver/BiDi/Command.cs | 5 +++++ dotnet/src/webdriver/BiDi/CommandOptions.cs | 25 --------------------- 2 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 dotnet/src/webdriver/BiDi/CommandOptions.cs diff --git a/dotnet/src/webdriver/BiDi/Command.cs b/dotnet/src/webdriver/BiDi/Command.cs index 42a0ee1935efe..36e5ab460aed5 100644 --- a/dotnet/src/webdriver/BiDi/Command.cs +++ b/dotnet/src/webdriver/BiDi/Command.cs @@ -33,4 +33,9 @@ public record Parameters public static Parameters Empty { get; } = new Parameters(); } +public abstract record CommandOptions +{ + public TimeSpan? Timeout { get; init; } +} + public abstract record EmptyResult; diff --git a/dotnet/src/webdriver/BiDi/CommandOptions.cs b/dotnet/src/webdriver/BiDi/CommandOptions.cs deleted file mode 100644 index d79285ec8817b..0000000000000 --- a/dotnet/src/webdriver/BiDi/CommandOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -namespace OpenQA.Selenium.BiDi; - -public abstract record CommandOptions -{ - public TimeSpan? Timeout { get; init; } -}