diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs index 4bc46f3a02bf0..4b00551f03520 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContext.cs @@ -100,6 +100,15 @@ public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null) return _bidi.BrowsingContextModule.HandleUserPromptAsync(this, options); } + public Task> GetTreeAsync(BrowsingContextGetTreeOptions? options = null) + { + options ??= new(); + + options.Root = this; + + return _bidi.BrowsingContextModule.GetTreeAsync(options); + } + public Task OnNavigationStartedAsync(Func handler, SubscriptionOptions? options = null) { return _bidi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] }); diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs index 1979b15ba6368..b550eeceebb03 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextNetworkModule.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using System; using OpenQA.Selenium.BiDi.Modules.Network; @@ -6,7 +6,7 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; public class BrowsingContextNetworkModule(BrowsingContext context, NetworkModule networkModule) { - public async Task InterceptRequestAsync(Func handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) + public async Task InterceptRequestAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { interceptOptions ??= new(); @@ -19,7 +19,7 @@ public async Task InterceptRequestAsync(Func InterceptResponseAsync(Func handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) + public async Task InterceptResponseAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { interceptOptions ??= new(); @@ -32,7 +32,7 @@ public async Task InterceptResponseAsync(Func InterceptAuthenticationAsync(Func handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) + public async Task InterceptAuthenticationAsync(Func handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null) { interceptOptions ??= new(); diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs index 89f24c939d202..0dcd3bf9ec390 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs @@ -6,7 +6,7 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext; public class BrowsingContextScriptModule(BrowsingContext context, ScriptModule scriptModule) { - public async Task AddPreloadScriptAsync(string functionDeclaration, AddPreloadScriptOptions? options = null) + public async Task AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null) { options ??= new(); diff --git a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs index 7e2717dc7c7ab..435a2b62ec977 100644 --- a/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs @@ -19,4 +19,13 @@ public record GetTreeOptions : CommandOptions public BrowsingContext? Root { get; set; } } +public record BrowsingContextGetTreeOptions : GetTreeOptions +{ + internal new BrowsingContext? Root + { + get => base.Root; + set => base.Root = value; + } +} + public record GetTreeResult(IReadOnlyList Contexts); diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs index 78789feb6bbca..01f151adf4524 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs @@ -19,6 +19,15 @@ public record AddInterceptOptions : CommandOptions public IEnumerable? UrlPatterns { get; set; } } +public record BrowsingContextAddInterceptOptions : AddInterceptOptions +{ + internal new IEnumerable? Contexts + { + get => base.Contexts; + set => base.Contexts = value; + } +} + public record AddInterceptResult(Intercept Intercept); public enum InterceptPhase diff --git a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs index a4da0627ccba3..c4b6916621244 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs @@ -23,4 +23,13 @@ public record AddPreloadScriptOptions : CommandOptions public string? Sandbox { get; set; } } +public record BrowsingContextAddPreloadScriptOptions : AddPreloadScriptOptions +{ + internal new IEnumerable? Contexts + { + get => base.Contexts; + set => base.Contexts = value; + } +} + internal record AddPreloadScriptResult(PreloadScript Script);