Skip to content

[dotnet] [bidi] Simplify modules namespace for end users (breaking change) #15820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
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
52 changes: 26 additions & 26 deletions dotnet/src/webdriver/BiDi/BiDi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,41 @@ public class BiDi : IAsyncDisposable
{
private readonly Broker _broker;

private readonly Lazy<Modules.Session.SessionModule> _sessionModule;
private readonly Lazy<Modules.BrowsingContext.BrowsingContextModule> _browsingContextModule;
private readonly Lazy<Modules.Browser.BrowserModule> _browserModule;
private readonly Lazy<Modules.Network.NetworkModule> _networkModule;
private readonly Lazy<Modules.Input.InputModule> _inputModule;
private readonly Lazy<Modules.Script.ScriptModule> _scriptModule;
private readonly Lazy<Modules.Log.LogModule> _logModule;
private readonly Lazy<Modules.Storage.StorageModule> _storageModule;
private readonly Lazy<Session.SessionModule> _sessionModule;
private readonly Lazy<BrowsingContext.BrowsingContextModule> _browsingContextModule;
private readonly Lazy<Browser.BrowserModule> _browserModule;
private readonly Lazy<Network.NetworkModule> _networkModule;
private readonly Lazy<Input.InputModule> _inputModule;
private readonly Lazy<Script.ScriptModule> _scriptModule;
private readonly Lazy<Log.LogModule> _logModule;
private readonly Lazy<Storage.StorageModule> _storageModule;

internal BiDi(string url)
{
var uri = new Uri(url);

_broker = new Broker(this, uri);

_sessionModule = new Lazy<Modules.Session.SessionModule>(() => new Modules.Session.SessionModule(_broker));
_browsingContextModule = new Lazy<Modules.BrowsingContext.BrowsingContextModule>(() => new Modules.BrowsingContext.BrowsingContextModule(_broker));
_browserModule = new Lazy<Modules.Browser.BrowserModule>(() => new Modules.Browser.BrowserModule(_broker));
_networkModule = new Lazy<Modules.Network.NetworkModule>(() => new Modules.Network.NetworkModule(_broker));
_inputModule = new Lazy<Modules.Input.InputModule>(() => new Modules.Input.InputModule(_broker));
_scriptModule = new Lazy<Modules.Script.ScriptModule>(() => new Modules.Script.ScriptModule(_broker));
_logModule = new Lazy<Modules.Log.LogModule>(() => new Modules.Log.LogModule(_broker));
_storageModule = new Lazy<Modules.Storage.StorageModule>(() => new Modules.Storage.StorageModule(_broker));
_sessionModule = new Lazy<Session.SessionModule>(() => new Session.SessionModule(_broker));
_browsingContextModule = new Lazy<BrowsingContext.BrowsingContextModule>(() => new BrowsingContext.BrowsingContextModule(_broker));
_browserModule = new Lazy<Browser.BrowserModule>(() => new Browser.BrowserModule(_broker));
_networkModule = new Lazy<Network.NetworkModule>(() => new Network.NetworkModule(_broker));
_inputModule = new Lazy<Input.InputModule>(() => new Input.InputModule(_broker));
_scriptModule = new Lazy<Script.ScriptModule>(() => new Script.ScriptModule(_broker));
_logModule = new Lazy<Log.LogModule>(() => new Log.LogModule(_broker));
_storageModule = new Lazy<Storage.StorageModule>(() => new Storage.StorageModule(_broker));
}

internal Modules.Session.SessionModule SessionModule => _sessionModule.Value;
public Modules.BrowsingContext.BrowsingContextModule BrowsingContext => _browsingContextModule.Value;
public Modules.Browser.BrowserModule Browser => _browserModule.Value;
public Modules.Network.NetworkModule Network => _networkModule.Value;
internal Modules.Input.InputModule InputModule => _inputModule.Value;
public Modules.Script.ScriptModule Script => _scriptModule.Value;
public Modules.Log.LogModule Log => _logModule.Value;
public Modules.Storage.StorageModule Storage => _storageModule.Value;
internal Session.SessionModule SessionModule => _sessionModule.Value;
public BrowsingContext.BrowsingContextModule BrowsingContext => _browsingContextModule.Value;
public Browser.BrowserModule Browser => _browserModule.Value;
public Network.NetworkModule Network => _networkModule.Value;
internal Input.InputModule InputModule => _inputModule.Value;
public Script.ScriptModule Script => _scriptModule.Value;
public Log.LogModule Log => _logModule.Value;
public Storage.StorageModule Storage => _storageModule.Value;

public Task<Modules.Session.StatusResult> StatusAsync()
public Task<Session.StatusResult> StatusAsync()
{
return SessionModule.StatusAsync();
}
Expand All @@ -75,7 +75,7 @@ public static async Task<BiDi> ConnectAsync(string url)
return bidi;
}

public Task EndAsync(Modules.Session.EndOptions? options = null)
public Task EndAsync(Session.EndOptions? options = null)
{
return SessionModule.EndAsync(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

public sealed class BrowserModule(Broker broker) : Module(broker)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// under the License.
// </copyright>

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

public record ClientWindow
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// under the License.
// </copyright>

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

public record ClientWindowInfo(bool Active, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

internal class CloseCommand()
: Command<CommandParameters, EmptyResult>(CommandParameters.Empty, "browser.close");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

internal class CreateUserContextCommand(CreateUserContextCommandParameters @params)
: Command<CreateUserContextCommandParameters, UserContextInfo>(@params, "browser.createUserContext");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System.Collections;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

internal class GetClientWindowsCommand()
: Command<CommandParameters, GetClientWindowsResult>(CommandParameters.Empty, "browser.getClientWindows");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System.Collections;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

internal class GetUserContextsCommand()
: Command<CommandParameters, GetUserContextsResult>(CommandParameters.Empty, "browser.getUserContexts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

internal class RemoveUserContextCommand(RemoveUserContextCommandParameters @params)
: Command<RemoveUserContextCommandParameters, EmptyResult>(@params, "browser.removeUserContext");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System;
using System.Threading.Tasks;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

public class UserContext : IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.Browser;
namespace OpenQA.Selenium.BiDi.Browser;

public record UserContextInfo(UserContext UserContext) : EmptyResult;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class ActivateCommand(ActivateCommandParameters @params)
: Command<ActivateCommandParameters, EmptyResult>(@params, "browsingContext.activate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System.Threading.Tasks;
using System;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public record BrowsingContextInfo(BiDi BiDi, IReadOnlyList<BrowsingContextInfo>? Children, Browser.ClientWindow ClientWindow, BrowsingContext Context, BrowsingContext? OriginalOpener, string Url, Browser.UserContext UserContext)
: BrowsingContextEventArgs(BiDi, Context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// </copyright>

using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Modules.Input;
using OpenQA.Selenium.BiDi.Input;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextInputModule(BrowsingContext context, InputModule inputModule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Modules.Log;
using OpenQA.Selenium.BiDi.Log;
using System.Threading.Tasks;
using System;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextLogModule(BrowsingContext context, LogModule logModule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextModule(Broker broker) : Module(broker)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

using System.Threading.Tasks;
using System;
using OpenQA.Selenium.BiDi.Modules.Network;
using OpenQA.Selenium.BiDi.Network;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextNetworkModule(BrowsingContext context, NetworkModule networkModule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// </copyright>

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

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextScriptModule(BrowsingContext context, ScriptModule scriptModule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
// </copyright>

using System.Threading.Tasks;
using OpenQA.Selenium.BiDi.Modules.Storage;
using OpenQA.Selenium.BiDi.Storage;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public class BrowsingContextStorageModule(BrowsingContext context, StorageModule storageModule)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using OpenQA.Selenium.BiDi.Communication;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params)
: Command<CaptureScreenshotCommandParameters, CaptureScreenshotResult>(@params, "browsingContext.captureScreenshot");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class CloseCommand(CloseCommandParameters @params)
: Command<CloseCommandParameters, EmptyResult>(@params, "browsingContext.close");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class CreateCommand(CreateCommandParameters @params)
: Command<CreateCommandParameters, CreateResult>(@params, "browsingContext.create");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using OpenQA.Selenium.BiDi.Communication;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class GetTreeCommand(GetTreeCommandParameters @params)
: Command<GetTreeCommandParameters, GetTreeResult>(@params, "browsingContext.getTree");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

class HandleUserPromptCommand(HandleUserPromptCommandParameters @params)
: Command<HandleUserPromptCommandParameters, EmptyResult>(@params, "browsingContext.handleUserPrompt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System.Collections;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class LocateNodesCommand(LocateNodesCommandParameters @params)
: Command<LocateNodesCommandParameters, LocateNodesResult>(@params, "browsingContext.locateNodes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(AccessibilityLocator), "accessibility")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class NavigateCommand(NavigateCommandParameters @params)
: Command<NavigateCommandParameters, NavigateResult>(@params, "browsingContext.navigate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
// under the License.
// </copyright>

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public record Navigation(string Id);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using System;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public record NavigationInfo(BiDi BiDi, BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url)
: BrowsingContextEventArgs(BiDi, Context);
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System;
using System.Collections.Generic;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class PrintCommand(PrintCommandParameters @params)
: Command<PrintCommandParameters, PrintResult>(@params, "browsingContext.print");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class ReloadCommand(ReloadCommandParameters @params)
: Command<ReloadCommandParameters, NavigateResult>(@params, "browsingContext.reload");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class SetViewportCommand(SetViewportCommandParameters @params)
: Command<SetViewportCommandParameters, EmptyResult>(@params, "browsingContext.setViewport");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

internal class TraverseHistoryCommand(TraverseHistoryCommandParameters @params)
: Command<TraverseHistoryCommandParameters, TraverseHistoryResult>(@params, "browsingContext.traverseHistory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
namespace OpenQA.Selenium.BiDi.BrowsingContext;

public record UserPromptClosedEventArgs(BiDi BiDi, BrowsingContext Context, bool Accepted)
: BrowsingContextEventArgs(BiDi, Context)
Expand Down
Loading