-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathBrowsingContextTest.GetTree.cs
43 lines (33 loc) · 1.46 KB
/
BrowsingContextTest.GetTree.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.BiDi;
using OpenQA.Selenium.BiDi.Modules.BrowsingContext;
using System.Threading.Tasks;
namespace SeleniumDocs.BiDi.BrowsingContext;
partial class BrowsingContextTest
{
[TestMethod]
public async Task GetBrowsingContextTree()
{
await context.NavigateAsync("https://www.selenium.dev/selenium/web/iframes.html", new() { Wait = ReadinessState.Complete });
var contexts = await context.GetTreeAsync();
Assert.AreEqual(1, contexts.Count);
Assert.IsNotNull(contexts[0].Children);
Assert.IsTrue(contexts[0].Children.Count >= 1, "Context should contain iframes as children");
}
[TestMethod]
public async Task GetBrowsingContextTreeWithDepth()
{
await context.NavigateAsync("https://www.selenium.dev/selenium/web/iframes.html", new() { Wait = ReadinessState.Complete });
var contexts = await context.GetTreeAsync(new() { MaxDepth = 0 });
Assert.AreEqual(1, contexts.Count);
Assert.IsNull(contexts[0].Children, "Context should not contain iframes as children since depth is 0");
}
[TestMethod]
public async Task GetAllTopLevelBrowingContexts()
{
var window = await bidi.BrowsingContext.CreateAsync(ContextType.Window);
var contexts = await bidi.BrowsingContext.GetTreeAsync();
Assert.AreEqual(2, contexts.Count);
Assert.AreEqual(contexts[1].Context, window);
}
}