Skip to content

Commit 1d054e7

Browse files
committed
[dotnet] [bidi] Return EmptyResult object which might be non-empty
1 parent 2cdef8f commit 1d054e7

File tree

10 files changed

+56
-59
lines changed

10 files changed

+56
-59
lines changed

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace OpenQA.Selenium.BiDi.Browser;
2424

2525
public sealed class BrowserModule(Broker broker) : Module(broker)
2626
{
27-
public async Task CloseAsync(CloseOptions? options = null)
27+
public async Task<EmptyResult> CloseAsync(CloseOptions? options = null)
2828
{
29-
await Broker.ExecuteCommandAsync(new CloseCommand(), options).ConfigureAwait(false);
29+
return await Broker.ExecuteCommandAsync<CloseCommand, EmptyResult>(new CloseCommand(), options).ConfigureAwait(false);
3030
}
3131

3232
public async Task<UserContextInfo> CreateUserContextAsync(CreateUserContextOptions? options = null)
@@ -41,11 +41,11 @@ public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOpt
4141
return await Broker.ExecuteCommandAsync<GetUserContextsCommand, GetUserContextsResult>(new GetUserContextsCommand(), options).ConfigureAwait(false);
4242
}
4343

44-
public async Task RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
44+
public async Task<EmptyResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
4545
{
4646
var @params = new RemoveUserContextCommandParameters(userContext);
4747

48-
await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options).ConfigureAwait(false);
48+
return await Broker.ExecuteCommandAsync<RemoveUserContextCommand, EmptyResult>(new RemoveUserContextCommand(@params), options).ConfigureAwait(false);
4949
}
5050

5151
public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
using System.Threading.Tasks;
2121
using System;
22+
using OpenQA.Selenium.BiDi.Communication;
2223

2324
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2425

@@ -66,7 +67,7 @@ public Task<NavigateResult> ReloadAsync(ReloadOptions? options = null)
6667
return BiDi.BrowsingContext.ReloadAsync(this, options);
6768
}
6869

69-
public Task ActivateAsync(ActivateOptions? options = null)
70+
public Task<EmptyResult> ActivateAsync(ActivateOptions? options = null)
7071
{
7172
return BiDi.BrowsingContext.ActivateAsync(this, options);
7273
}
@@ -81,17 +82,17 @@ public Task<CaptureScreenshotResult> CaptureScreenshotAsync(CaptureScreenshotOpt
8182
return BiDi.BrowsingContext.CaptureScreenshotAsync(this, options);
8283
}
8384

84-
public Task CloseAsync(CloseOptions? options = null)
85+
public Task<EmptyResult> CloseAsync(CloseOptions? options = null)
8586
{
8687
return BiDi.BrowsingContext.CloseAsync(this, options);
8788
}
8889

89-
public Task TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
90+
public Task<TraverseHistoryResult> TraverseHistoryAsync(int delta, TraverseHistoryOptions? options = null)
9091
{
9192
return BiDi.BrowsingContext.TraverseHistoryAsync(this, delta, options);
9293
}
9394

94-
public Task SetViewportAsync(SetViewportOptions? options = null)
95+
public Task<EmptyResult> SetViewportAsync(SetViewportOptions? options = null)
9596
{
9697
return BiDi.BrowsingContext.SetViewportAsync(this, options);
9798
}
@@ -101,7 +102,7 @@ public Task<PrintResult> PrintAsync(PrintOptions? options = null)
101102
return BiDi.BrowsingContext.PrintAsync(this, options);
102103
}
103104

104-
public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
105+
public Task<EmptyResult> HandleUserPromptAsync(HandleUserPromptOptions? options = null)
105106
{
106107
return BiDi.BrowsingContext.HandleUserPromptAsync(this, options);
107108
}

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@
2020
using System.Threading.Tasks;
2121
using OpenQA.Selenium.BiDi.Input;
2222
using System.Collections.Generic;
23+
using OpenQA.Selenium.BiDi.Communication;
2324

2425
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2526

2627
public sealed class BrowsingContextInputModule(BrowsingContext context, InputModule inputModule)
2728
{
28-
public Task PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
29+
public Task<EmptyResult> PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
2930
{
3031
return inputModule.PerformActionsAsync(context, actions, options);
3132
}
3233

33-
public Task ReleaseActionsAsync(ReleaseActionsOptions? options = null)
34+
public Task<EmptyResult> ReleaseActionsAsync(ReleaseActionsOptions? options = null)
3435
{
3536
return inputModule.ReleaseActionsAsync(context, options);
3637
}
3738

38-
public Task SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
39+
public Task<EmptyResult> SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
3940
{
4041
return inputModule.SetFilesAsync(context, element, files, options);
4142
}

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public async Task<NavigateResult> NavigateAsync(BrowsingContext context, string
4141
return await Broker.ExecuteCommandAsync<NavigateCommand, NavigateResult>(new NavigateCommand(@params), options).ConfigureAwait(false);
4242
}
4343

44-
public async Task ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
44+
public async Task<EmptyResult> ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
4545
{
4646
var @params = new ActivateCommandParameters(context);
4747

48-
await Broker.ExecuteCommandAsync(new ActivateCommand(@params), options).ConfigureAwait(false);
48+
return await Broker.ExecuteCommandAsync<ActivateCommand, EmptyResult>(new ActivateCommand(@params), options).ConfigureAwait(false);
4949
}
5050

5151
public async Task<LocateNodesResult> LocateNodesAsync(BrowsingContext context, Locator locator, LocateNodesOptions? options = null)
@@ -62,11 +62,11 @@ public async Task<CaptureScreenshotResult> CaptureScreenshotAsync(BrowsingContex
6262
return await Broker.ExecuteCommandAsync<CaptureScreenshotCommand, CaptureScreenshotResult>(new CaptureScreenshotCommand(@params), options).ConfigureAwait(false);
6363
}
6464

65-
public async Task CloseAsync(BrowsingContext context, CloseOptions? options = null)
65+
public async Task<EmptyResult> CloseAsync(BrowsingContext context, CloseOptions? options = null)
6666
{
6767
var @params = new CloseCommandParameters(context, options?.PromptUnload);
6868

69-
await Broker.ExecuteCommandAsync(new CloseCommand(@params), options).ConfigureAwait(false);
69+
return await Broker.ExecuteCommandAsync<CloseCommand, EmptyResult>(new CloseCommand(@params), options).ConfigureAwait(false);
7070
}
7171

7272
public async Task<TraverseHistoryResult> TraverseHistoryAsync(BrowsingContext context, int delta, TraverseHistoryOptions? options = null)
@@ -83,11 +83,11 @@ public async Task<NavigateResult> ReloadAsync(BrowsingContext context, ReloadOpt
8383
return await Broker.ExecuteCommandAsync<ReloadCommand, NavigateResult>(new ReloadCommand(@params), options).ConfigureAwait(false);
8484
}
8585

86-
public async Task SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
86+
public async Task<EmptyResult> SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
8787
{
8888
var @params = new SetViewportCommandParameters(context, options?.Viewport, options?.DevicePixelRatio);
8989

90-
await Broker.ExecuteCommandAsync(new SetViewportCommand(@params), options).ConfigureAwait(false);
90+
return await Broker.ExecuteCommandAsync<SetViewportCommand, EmptyResult>(new SetViewportCommand(@params), options).ConfigureAwait(false);
9191
}
9292

9393
public async Task<GetTreeResult> GetTreeAsync(GetTreeOptions? options = null)
@@ -104,11 +104,11 @@ public async Task<PrintResult> PrintAsync(BrowsingContext context, PrintOptions?
104104
return await Broker.ExecuteCommandAsync<PrintCommand, PrintResult>(new PrintCommand(@params), options).ConfigureAwait(false);
105105
}
106106

107-
public async Task HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
107+
public async Task<EmptyResult> HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
108108
{
109109
var @params = new HandleUserPromptCommandParameters(context, options?.Accept, options?.UserText);
110110

111-
await Broker.ExecuteCommandAsync(new HandleUserPromptCommand(@params), options).ConfigureAwait(false);
111+
return await Broker.ExecuteCommandAsync<HandleUserPromptCommand, EmptyResult>(new HandleUserPromptCommand(@params), options).ConfigureAwait(false);
112112
}
113113

114114
public async Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Threading.Tasks;
2121
using System;
2222
using OpenQA.Selenium.BiDi.Network;
23+
using OpenQA.Selenium.BiDi.Communication;
2324

2425
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2526

@@ -73,7 +74,7 @@ await intercept.OnAuthRequiredAsync(
7374
return intercept;
7475
}
7576

76-
public Task SetCacheBehaviorAsync(CacheBehavior behavior, BrowsingContextSetCacheBehaviorOptions? options = null)
77+
public Task<EmptyResult> SetCacheBehaviorAsync(CacheBehavior behavior, BrowsingContextSetCacheBehaviorOptions? options = null)
7778
{
7879
SetCacheBehaviorOptions setCacheBehaviorOptions = new(options)
7980
{

dotnet/src/webdriver/BiDi/Communication/Broker.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ private async Task ProcessEventsAwaiterAsync()
179179
}
180180
}
181181

182-
public async Task ExecuteCommandAsync<TCommand>(TCommand command, CommandOptions? options)
183-
where TCommand : Command
184-
{
185-
await ExecuteCommandCoreAsync(command, options).ConfigureAwait(false);
186-
}
187-
188182
public async Task<TResult> ExecuteCommandAsync<TCommand, TResult>(TCommand command, CommandOptions? options)
189183
where TCommand : Command
190184
where TResult : EmptyResult

dotnet/src/webdriver/BiDi/Input/InputModule.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ namespace OpenQA.Selenium.BiDi.Input;
2525

2626
public sealed class InputModule(Broker broker) : Module(broker)
2727
{
28-
public async Task PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
28+
public async Task<EmptyResult> PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
2929
{
3030
var @params = new PerformActionsCommandParameters(context, actions);
3131

32-
await Broker.ExecuteCommandAsync(new PerformActionsCommand(@params), options).ConfigureAwait(false);
32+
return await Broker.ExecuteCommandAsync<PerformActionsCommand, EmptyResult>(new PerformActionsCommand(@params), options).ConfigureAwait(false);
3333
}
3434

35-
public async Task ReleaseActionsAsync(BrowsingContext.BrowsingContext context, ReleaseActionsOptions? options = null)
35+
public async Task<EmptyResult> ReleaseActionsAsync(BrowsingContext.BrowsingContext context, ReleaseActionsOptions? options = null)
3636
{
3737
var @params = new ReleaseActionsCommandParameters(context);
3838

39-
await Broker.ExecuteCommandAsync(new ReleaseActionsCommand(@params), options).ConfigureAwait(false);
39+
return await Broker.ExecuteCommandAsync<ReleaseActionsCommand, EmptyResult>(new ReleaseActionsCommand(@params), options).ConfigureAwait(false);
4040
}
4141

42-
public async Task SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
42+
public async Task<EmptyResult> SetFilesAsync(BrowsingContext.BrowsingContext context, Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
4343
{
4444
var @params = new SetFilesCommandParameters(context, element, files);
4545

46-
await Broker.ExecuteCommandAsync(new SetFilesCommand(@params), options).ConfigureAwait(false);
46+
return await Broker.ExecuteCommandAsync<SetFilesCommand, EmptyResult>(new SetFilesCommand(@params), options).ConfigureAwait(false);
4747
}
4848
}

dotnet/src/webdriver/BiDi/Network/NetworkModule.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,61 +35,61 @@ internal async Task<Intercept> AddInterceptAsync(IEnumerable<InterceptPhase> pha
3535
return result.Intercept;
3636
}
3737

38-
internal async Task RemoveInterceptAsync(Intercept intercept, RemoveInterceptOptions? options = null)
38+
internal async Task<EmptyResult> RemoveInterceptAsync(Intercept intercept, RemoveInterceptOptions? options = null)
3939
{
4040
var @params = new RemoveInterceptCommandParameters(intercept);
4141

42-
await Broker.ExecuteCommandAsync(new RemoveInterceptCommand(@params), options).ConfigureAwait(false);
42+
return await Broker.ExecuteCommandAsync<RemoveInterceptCommand, EmptyResult>(new RemoveInterceptCommand(@params), options).ConfigureAwait(false);
4343
}
4444

45-
public async Task SetCacheBehaviorAsync(CacheBehavior behavior, SetCacheBehaviorOptions? options = null)
45+
public async Task<EmptyResult> SetCacheBehaviorAsync(CacheBehavior behavior, SetCacheBehaviorOptions? options = null)
4646
{
4747
var @params = new SetCacheBehaviorCommandParameters(behavior, options?.Contexts);
4848

49-
await Broker.ExecuteCommandAsync(new SetCacheBehaviorCommand(@params), options).ConfigureAwait(false);
49+
return await Broker.ExecuteCommandAsync<SetCacheBehaviorCommand, EmptyResult>(new SetCacheBehaviorCommand(@params), options).ConfigureAwait(false);
5050
}
5151

52-
internal async Task ContinueRequestAsync(Request request, ContinueRequestOptions? options = null)
52+
internal async Task<EmptyResult> ContinueRequestAsync(Request request, ContinueRequestOptions? options = null)
5353
{
5454
var @params = new ContinueRequestCommandParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.Method, options?.Url);
5555

56-
await Broker.ExecuteCommandAsync(new ContinueRequestCommand(@params), options).ConfigureAwait(false);
56+
return await Broker.ExecuteCommandAsync<ContinueRequestCommand, EmptyResult>(new ContinueRequestCommand(@params), options).ConfigureAwait(false);
5757
}
5858

59-
internal async Task ContinueResponseAsync(Request request, ContinueResponseOptions? options = null)
59+
internal async Task<EmptyResult> ContinueResponseAsync(Request request, ContinueResponseOptions? options = null)
6060
{
6161
var @params = new ContinueResponseCommandParameters(request, options?.Cookies, options?.Credentials, options?.Headers, options?.ReasonPhrase, options?.StatusCode);
6262

63-
await Broker.ExecuteCommandAsync(new ContinueResponseCommand(@params), options).ConfigureAwait(false);
63+
return await Broker.ExecuteCommandAsync<ContinueResponseCommand, EmptyResult>(new ContinueResponseCommand(@params), options).ConfigureAwait(false);
6464
}
6565

66-
internal async Task FailRequestAsync(Request request, FailRequestOptions? options = null)
66+
internal async Task<EmptyResult> FailRequestAsync(Request request, FailRequestOptions? options = null)
6767
{
6868
var @params = new FailRequestCommandParameters(request);
6969

70-
await Broker.ExecuteCommandAsync(new FailRequestCommand(@params), options).ConfigureAwait(false);
70+
return await Broker.ExecuteCommandAsync<FailRequestCommand, EmptyResult>(new FailRequestCommand(@params), options).ConfigureAwait(false);
7171
}
7272

73-
internal async Task ProvideResponseAsync(Request request, ProvideResponseOptions? options = null)
73+
internal async Task<EmptyResult> ProvideResponseAsync(Request request, ProvideResponseOptions? options = null)
7474
{
7575
var @params = new ProvideResponseCommandParameters(request, options?.Body, options?.Cookies, options?.Headers, options?.ReasonPhrase, options?.StatusCode);
7676

77-
await Broker.ExecuteCommandAsync(new ProvideResponseCommand(@params), options).ConfigureAwait(false);
77+
return await Broker.ExecuteCommandAsync<ProvideResponseCommand, EmptyResult>(new ProvideResponseCommand(@params), options).ConfigureAwait(false);
7878
}
7979

80-
internal async Task ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null)
80+
internal async Task<EmptyResult> ContinueWithAuthAsync(Request request, AuthCredentials credentials, ContinueWithAuthCredentialsOptions? options = null)
8181
{
82-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCredentials(request, credentials)), options).ConfigureAwait(false);
82+
return await Broker.ExecuteCommandAsync<ContinueWithAuthCommand, EmptyResult>(new ContinueWithAuthCommand(new ContinueWithAuthCredentials(request, credentials)), options).ConfigureAwait(false);
8383
}
8484

85-
internal async Task ContinueWithAuthAsync(Request request, ContinueWithAuthDefaultCredentialsOptions? options = null)
85+
internal async Task<EmptyResult> ContinueWithAuthAsync(Request request, ContinueWithAuthDefaultCredentialsOptions? options = null)
8686
{
87-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthDefaultCredentials(request)), options).ConfigureAwait(false);
87+
return await Broker.ExecuteCommandAsync<ContinueWithAuthCommand, EmptyResult>(new ContinueWithAuthCommand(new ContinueWithAuthDefaultCredentials(request)), options).ConfigureAwait(false);
8888
}
8989

90-
internal async Task ContinueWithAuthAsync(Request request, ContinueWithAuthCancelCredentialsOptions? options = null)
90+
internal async Task<EmptyResult> ContinueWithAuthAsync(Request request, ContinueWithAuthCancelCredentialsOptions? options = null)
9191
{
92-
await Broker.ExecuteCommandAsync(new ContinueWithAuthCommand(new ContinueWithAuthCancelCredentials(request)), options).ConfigureAwait(false);
92+
return await Broker.ExecuteCommandAsync<ContinueWithAuthCommand, EmptyResult>(new ContinueWithAuthCommand(new ContinueWithAuthCancelCredentials(request)), options).ConfigureAwait(false);
9393
}
9494

9595
public async Task<Subscription> OnBeforeRequestSentAsync(Func<BeforeRequestSentEventArgs, Task> handler, SubscriptionOptions? options = null)

dotnet/src/webdriver/BiDi/Script/ScriptModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaratio
6969
return result.Script;
7070
}
7171

72-
public async Task RemovePreloadScriptAsync(PreloadScript script, RemovePreloadScriptOptions? options = null)
72+
public async Task<EmptyResult> RemovePreloadScriptAsync(PreloadScript script, RemovePreloadScriptOptions? options = null)
7373
{
7474
var @params = new RemovePreloadScriptCommandParameters(script);
7575

76-
await Broker.ExecuteCommandAsync(new RemovePreloadScriptCommand(@params), options).ConfigureAwait(false);
76+
return await Broker.ExecuteCommandAsync<RemovePreloadScriptCommand, EmptyResult>(new RemovePreloadScriptCommand(@params), options).ConfigureAwait(false);
7777
}
7878

7979
public async Task<Subscription> OnMessageAsync(Func<MessageEventArgs, Task> handler, SubscriptionOptions? options = null)

0 commit comments

Comments
 (0)