Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ namespace OpenQA.Selenium.BiDi.Browser;

public sealed class BrowserModule : Module
{
public async Task<EmptyResult> CloseAsync(CloseOptions? options = null)
public async Task<CloseResult> CloseAsync(CloseOptions? options = null)
{
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.Browser_CloseResult).ConfigureAwait(false);
}

public async Task<UserContextInfo> CreateUserContextAsync(CreateUserContextOptions? options = null)
public async Task<CreateUserContextResult> CreateUserContextAsync(CreateUserContextOptions? options = null)
{
var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior);

return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.UserContextInfo).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.CreateUserContextResult).ConfigureAwait(false);
}

public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOptions? options = null)
{
return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options, JsonContext.GetUserContextsCommand, JsonContext.GetUserContextsResult).ConfigureAwait(false);
}

public async Task<EmptyResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
public async Task<RemoveUserContextResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
{
var @params = new RemoveUserContextParameters(userContext);

return await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, JsonContext.RemoveUserContextCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, JsonContext.RemoveUserContextCommand, JsonContext.RemoveUserContextResult).ConfigureAwait(false);
}

public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)
Expand All @@ -54,24 +54,24 @@ public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindows
).ConfigureAwait(false);
}

public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
{
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts);

return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
}

public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
{
var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts);

return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
}

public async Task<EmptyResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
{
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts);

return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
}
}
4 changes: 3 additions & 1 deletion dotnet/src/webdriver/BiDi/Browser/CloseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
namespace OpenQA.Selenium.BiDi.Browser;

internal sealed class CloseCommand()
: Command<Parameters, EmptyResult>(Parameters.Empty, "browser.close");
: Command<Parameters, CloseResult>(Parameters.Empty, "browser.close");

public sealed class CloseOptions : CommandOptions;

public sealed record CloseResult : EmptyResult;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace OpenQA.Selenium.BiDi.Browser;

internal sealed class CreateUserContextCommand(CreateUserContextParameters @params)
: Command<CreateUserContextParameters, UserContextInfo>(@params, "browser.createUserContext");
: Command<CreateUserContextParameters, CreateUserContextResult>(@params, "browser.createUserContext");

internal sealed record CreateUserContextParameters(bool? AcceptInsecureCerts, Session.ProxyConfiguration? Proxy, Session.UserPromptHandler? UnhandledPromptBehavior) : Parameters;

Expand All @@ -34,3 +34,5 @@ public sealed class CreateUserContextOptions : CommandOptions

public Session.UserPromptHandler? UnhandledPromptBehavior { get; set; }
}

public sealed record CreateUserContextResult(UserContext UserContext) : UserContextInfo(UserContext);
2 changes: 0 additions & 2 deletions dotnet/src/webdriver/BiDi/Browser/GetClientWindowsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows)

public int Count => ClientWindows.Count;



public IEnumerator<ClientWindowInfo> GetEnumerator() => ClientWindows.GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() => (ClientWindows as IEnumerable).GetEnumerator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
namespace OpenQA.Selenium.BiDi.Browser;

internal sealed class RemoveUserContextCommand(RemoveUserContextParameters @params)
: Command<RemoveUserContextParameters, EmptyResult>(@params, "browser.removeUserContext");
: Command<RemoveUserContextParameters, RemoveUserContextResult>(@params, "browser.removeUserContext");

internal sealed record RemoveUserContextParameters(UserContext UserContext) : Parameters;

public sealed class RemoveUserContextOptions : CommandOptions;

public sealed record RemoveUserContextResult : EmptyResult;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
namespace OpenQA.Selenium.BiDi.Browser;

internal sealed class SetDownloadBehaviorCommand(SetDownloadBehaviorParameters @params)
: Command<SetDownloadBehaviorParameters, EmptyResult>(@params, "browser.setDownloadBehavior");
: Command<SetDownloadBehaviorParameters, SetDownloadBehaviorResult>(@params, "browser.setDownloadBehavior");

internal sealed record SetDownloadBehaviorParameters([property: JsonIgnore(Condition = JsonIgnoreCondition.Never)] DownloadBehavior? DownloadBehavior, IEnumerable<UserContext>? UserContexts) : Parameters;

Expand All @@ -41,3 +41,5 @@ public sealed class SetDownloadBehaviorOptions : CommandOptions
{
public IEnumerable<UserContext>? UserContexts { get; set; }
}

public sealed record SetDownloadBehaviorResult : EmptyResult;
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/BiDi/Browser/UserContextInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

namespace OpenQA.Selenium.BiDi.Browser;

public sealed record UserContextInfo(UserContext UserContext) : EmptyResult;
public record UserContextInfo(UserContext UserContext) : EmptyResult;
4 changes: 3 additions & 1 deletion dotnet/src/webdriver/BiDi/BrowsingContext/ActivateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal sealed class ActivateCommand(ActivateParameters @params)
: Command<ActivateParameters, EmptyResult>(@params, "browsingContext.activate");
: Command<ActivateParameters, ActivateResult>(@params, "browsingContext.activate");

internal sealed record ActivateParameters(BrowsingContext Context) : Parameters;

public sealed class ActivateOptions : CommandOptions;

public sealed record ActivateResult : EmptyResult;
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ public Task<NavigateResult> NavigateAsync(string url, NavigateOptions? options =
return BiDi.BrowsingContext.NavigateAsync(this, url, options);
}

public Task<NavigateResult> ReloadAsync(ReloadOptions? options = null)
public Task<ReloadResult> ReloadAsync(ReloadOptions? options = null)
{
return BiDi.BrowsingContext.ReloadAsync(this, options);
}

public Task<EmptyResult> ActivateAsync(ActivateOptions? options = null)
public Task<ActivateResult> ActivateAsync(ActivateOptions? options = null)
{
return BiDi.BrowsingContext.ActivateAsync(this, options);
}
Expand All @@ -82,7 +82,7 @@ public Task<CaptureScreenshotResult> CaptureScreenshotAsync(CaptureScreenshotOpt
return BiDi.BrowsingContext.CaptureScreenshotAsync(this, options);
}

public Task<EmptyResult> CloseAsync(CloseOptions? options = null)
public Task<CloseResult> CloseAsync(CloseOptions? options = null)
{
return BiDi.BrowsingContext.CloseAsync(this, options);
}
Expand All @@ -92,7 +92,7 @@ public Task<TraverseHistoryResult> TraverseHistoryAsync(int delta, TraverseHisto
return BiDi.BrowsingContext.TraverseHistoryAsync(this, delta, options);
}

public Task<EmptyResult> SetViewportAsync(SetViewportOptions? options = null)
public Task<SetViewportResult> SetViewportAsync(SetViewportOptions? options = null)
{
return BiDi.BrowsingContext.SetViewportAsync(this, options);
}
Expand All @@ -102,7 +102,7 @@ public Task<PrintResult> PrintAsync(PrintOptions? options = null)
return BiDi.BrowsingContext.PrintAsync(this, options);
}

public Task<EmptyResult> HandleUserPromptAsync(HandleUserPromptOptions? options = null)
public Task<HandleUserPromptResult> HandleUserPromptAsync(HandleUserPromptOptions? options = null)
{
return BiDi.BrowsingContext.HandleUserPromptAsync(this, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@
using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Input;
using System.Collections.Generic;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed class BrowsingContextInputModule(BrowsingContext context, InputModule inputModule)
{
public Task<EmptyResult> PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
public Task<PerformActionsResult> PerformActionsAsync(IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
{
return inputModule.PerformActionsAsync(context, actions, options);
}

public Task<EmptyResult> ReleaseActionsAsync(ReleaseActionsOptions? options = null)
public Task<ReleaseActionsResult> ReleaseActionsAsync(ReleaseActionsOptions? options = null)
{
return inputModule.ReleaseActionsAsync(context, options);
}

public Task<EmptyResult> SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
public Task<SetFilesResult> SetFilesAsync(Script.ISharedReference element, IEnumerable<string> files, SetFilesOptions? options = null)
{
return inputModule.SetFilesAsync(context, element, files, options);
}
Expand Down
26 changes: 12 additions & 14 deletions dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed class BrowsingContextModule : Module
{
public async Task<BrowsingContext> CreateAsync(ContextType type, CreateOptions? options = null)
public async Task<CreateResult> CreateAsync(ContextType type, CreateOptions? options = null)
{
var @params = new CreateParameters(type, options?.ReferenceContext, options?.Background, options?.UserContext);

var createResult = await Broker.ExecuteCommandAsync(new CreateCommand(@params), options, JsonContext.CreateCommand, JsonContext.CreateResult).ConfigureAwait(false);

return createResult.Context;
return await Broker.ExecuteCommandAsync(new CreateCommand(@params), options, JsonContext.CreateCommand, JsonContext.CreateResult).ConfigureAwait(false);
}

public async Task<NavigateResult> NavigateAsync(BrowsingContext context, string url, NavigateOptions? options = null)
Expand All @@ -41,11 +39,11 @@ public async Task<NavigateResult> NavigateAsync(BrowsingContext context, string
return await Broker.ExecuteCommandAsync(new NavigateCommand(@params), options, JsonContext.NavigateCommand, JsonContext.NavigateResult).ConfigureAwait(false);
}

public async Task<EmptyResult> ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
public async Task<ActivateResult> ActivateAsync(BrowsingContext context, ActivateOptions? options = null)
{
var @params = new ActivateParameters(context);

return await Broker.ExecuteCommandAsync(new ActivateCommand(@params), options, JsonContext.ActivateCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new ActivateCommand(@params), options, JsonContext.ActivateCommand, JsonContext.ActivateResult).ConfigureAwait(false);
}

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

public async Task<EmptyResult> CloseAsync(BrowsingContext context, CloseOptions? options = null)
public async Task<CloseResult> CloseAsync(BrowsingContext context, CloseOptions? options = null)
{
var @params = new CloseParameters(context, options?.PromptUnload);

return await Broker.ExecuteCommandAsync(new CloseCommand(@params), options, JsonContext.BrowsingContext_CloseCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new CloseCommand(@params), options, JsonContext.BrowsingContext_CloseCommand, JsonContext.BrowsingContext_CloseResult).ConfigureAwait(false);
}

public async Task<TraverseHistoryResult> TraverseHistoryAsync(BrowsingContext context, int delta, TraverseHistoryOptions? options = null)
Expand All @@ -76,18 +74,18 @@ public async Task<TraverseHistoryResult> TraverseHistoryAsync(BrowsingContext co
return await Broker.ExecuteCommandAsync(new TraverseHistoryCommand(@params), options, JsonContext.TraverseHistoryCommand, JsonContext.TraverseHistoryResult).ConfigureAwait(false);
}

public async Task<NavigateResult> ReloadAsync(BrowsingContext context, ReloadOptions? options = null)
public async Task<ReloadResult> ReloadAsync(BrowsingContext context, ReloadOptions? options = null)
{
var @params = new ReloadParameters(context, options?.IgnoreCache, options?.Wait);

return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options, JsonContext.ReloadCommand, JsonContext.NavigateResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new ReloadCommand(@params), options, JsonContext.ReloadCommand, JsonContext.ReloadResult).ConfigureAwait(false);
}

public async Task<EmptyResult> SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
public async Task<SetViewportResult> SetViewportAsync(BrowsingContext context, SetViewportOptions? options = null)
{
var @params = new SetViewportParameters(context, options?.Viewport, options?.DevicePixelRatio);

return await Broker.ExecuteCommandAsync(new SetViewportCommand(@params), options, JsonContext.SetViewportCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new SetViewportCommand(@params), options, JsonContext.SetViewportCommand, JsonContext.SetViewportResult).ConfigureAwait(false);
}

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

public async Task<EmptyResult> HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
public async Task<HandleUserPromptResult> HandleUserPromptAsync(BrowsingContext context, HandleUserPromptOptions? options = null)
{
var @params = new HandleUserPromptParameters(context, options?.Accept, options?.UserText);

return await Broker.ExecuteCommandAsync(new HandleUserPromptCommand(@params), options, JsonContext.HandleUserPromptCommand, JsonContext.EmptyResult).ConfigureAwait(false);
return await Broker.ExecuteCommandAsync(new HandleUserPromptCommand(@params), options, JsonContext.HandleUserPromptCommand, JsonContext.HandleUserPromptResult).ConfigureAwait(false);
}

public async Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, BrowsingContextsSubscriptionOptions? options = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Threading.Tasks;
using System;
using OpenQA.Selenium.BiDi.Network;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand Down Expand Up @@ -74,7 +73,7 @@ await intercept.OnAuthRequiredAsync(
return intercept;
}

public Task<EmptyResult> SetCacheBehaviorAsync(CacheBehavior behavior, BrowsingContextSetCacheBehaviorOptions? options = null)
public Task<SetCacheBehaviorResult> SetCacheBehaviorAsync(CacheBehavior behavior, BrowsingContextSetCacheBehaviorOptions? options = null)
{
SetCacheBehaviorOptions setCacheBehaviorOptions = new(options)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@

using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Script;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

public sealed class BrowsingContextScriptModule(BrowsingContext context, ScriptModule scriptModule)
{
public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null)
public async Task<AddPreloadScriptResult> AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null)
{
AddPreloadScriptOptions addPreloadScriptOptions = new(options)
{
Expand All @@ -35,7 +34,7 @@ public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaratio
return await scriptModule.AddPreloadScriptAsync(functionDeclaration, addPreloadScriptOptions).ConfigureAwait(false);
}

public async Task<IReadOnlyList<RealmInfo>> GetRealmsAsync(GetRealmsOptions? options = null)
public async Task<GetRealmsResult> GetRealmsAsync(GetRealmsOptions? options = null)
{
options ??= new();

Expand Down
4 changes: 3 additions & 1 deletion dotnet/src/webdriver/BiDi/BrowsingContext/CloseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal sealed class CloseCommand(CloseParameters @params)
: Command<CloseParameters, EmptyResult>(@params, "browsingContext.close");
: Command<CloseParameters, CloseResult>(@params, "browsingContext.close");

internal sealed record CloseParameters(BrowsingContext Context, bool? PromptUnload) : Parameters;

public sealed class CloseOptions : CommandOptions
{
public bool? PromptUnload { get; set; }
}

public sealed record CloseResult : EmptyResult;
Loading