Skip to content

Commit 6c0df70

Browse files
authored
[dotnet] [bidi] Get tree from browsing context as root (#14495)
1 parent 6b4c39c commit 6c0df70

File tree

6 files changed

+41
-5
lines changed

6 files changed

+41
-5
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ public Task HandleUserPromptAsync(HandleUserPromptOptions? options = null)
100100
return _bidi.BrowsingContextModule.HandleUserPromptAsync(this, options);
101101
}
102102

103+
public Task<IReadOnlyList<BrowsingContextInfo>> GetTreeAsync(BrowsingContextGetTreeOptions? options = null)
104+
{
105+
options ??= new();
106+
107+
options.Root = this;
108+
109+
return _bidi.BrowsingContextModule.GetTreeAsync(options);
110+
}
111+
103112
public Task<Subscription> OnNavigationStartedAsync(Func<NavigationInfo, Task> handler, SubscriptionOptions? options = null)
104113
{
105114
return _bidi.BrowsingContextModule.OnNavigationStartedAsync(handler, new BrowsingContextsSubscriptionOptions(options) { Contexts = [this] });

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using System.Threading.Tasks;
1+
using System.Threading.Tasks;
22
using System;
33
using OpenQA.Selenium.BiDi.Modules.Network;
44

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

77
public class BrowsingContextNetworkModule(BrowsingContext context, NetworkModule networkModule)
88
{
9-
public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
9+
public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
1010
{
1111
interceptOptions ??= new();
1212

@@ -19,7 +19,7 @@ public async Task<Intercept> InterceptRequestAsync(Func<BeforeRequestSentEventAr
1919
return intercept;
2020
}
2121

22-
public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
22+
public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
2323
{
2424
interceptOptions ??= new();
2525

@@ -32,7 +32,7 @@ public async Task<Intercept> InterceptResponseAsync(Func<ResponseStartedEventArg
3232
return intercept;
3333
}
3434

35-
public async Task<Intercept> InterceptAuthenticationAsync(Func<AuthRequiredEventArgs, Task> handler, AddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
35+
public async Task<Intercept> InterceptAuthenticationAsync(Func<AuthRequiredEventArgs, Task> handler, BrowsingContextAddInterceptOptions? interceptOptions = null, SubscriptionOptions? options = null)
3636
{
3737
interceptOptions ??= new();
3838

‎dotnet/src/webdriver/BiDi/Modules/BrowsingContext/BrowsingContextScriptModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
66

77
public class BrowsingContextScriptModule(BrowsingContext context, ScriptModule scriptModule)
88
{
9-
public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaration, AddPreloadScriptOptions? options = null)
9+
public async Task<PreloadScript> AddPreloadScriptAsync(string functionDeclaration, BrowsingContextAddPreloadScriptOptions? options = null)
1010
{
1111
options ??= new();
1212

‎dotnet/src/webdriver/BiDi/Modules/BrowsingContext/GetTreeCommand.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,13 @@ public record GetTreeOptions : CommandOptions
1919
public BrowsingContext? Root { get; set; }
2020
}
2121

22+
public record BrowsingContextGetTreeOptions : GetTreeOptions
23+
{
24+
internal new BrowsingContext? Root
25+
{
26+
get => base.Root;
27+
set => base.Root = value;
28+
}
29+
}
30+
2231
public record GetTreeResult(IReadOnlyList<BrowsingContextInfo> Contexts);

‎dotnet/src/webdriver/BiDi/Modules/Network/AddInterceptCommand.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public record AddInterceptOptions : CommandOptions
1919
public IEnumerable<UrlPattern>? UrlPatterns { get; set; }
2020
}
2121

22+
public record BrowsingContextAddInterceptOptions : AddInterceptOptions
23+
{
24+
internal new IEnumerable<BrowsingContext.BrowsingContext>? Contexts
25+
{
26+
get => base.Contexts;
27+
set => base.Contexts = value;
28+
}
29+
}
30+
2231
public record AddInterceptResult(Intercept Intercept);
2332

2433
public enum InterceptPhase

‎dotnet/src/webdriver/BiDi/Modules/Script/AddPreloadScriptCommand.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,13 @@ public record AddPreloadScriptOptions : CommandOptions
2323
public string? Sandbox { get; set; }
2424
}
2525

26+
public record BrowsingContextAddPreloadScriptOptions : AddPreloadScriptOptions
27+
{
28+
internal new IEnumerable<BrowsingContext.BrowsingContext>? Contexts
29+
{
30+
get => base.Contexts;
31+
set => base.Contexts = value;
32+
}
33+
}
34+
2635
internal record AddPreloadScriptResult(PreloadScript Script);

0 commit comments

Comments
 (0)