Skip to content

Commit cf93f36

Browse files
committed
Simplify browsing context
1 parent 2e02cc2 commit cf93f36

18 files changed

+87
-87
lines changed

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public async Task Activate()
1212
{
1313
await using var bidi = await driver.AsBidirectionalAsync();
1414

15-
var tab = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Tab);
15+
var tab = await bidi.CreateContextAsync(BrowsingContextType.Tab);
1616

1717
await tab.ActivateAsync();
1818
}

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ partial class BrowsingContextTest
1010
[TestMethod]
1111
public async Task CaptureScreenshot()
1212
{
13-
var browsingContext = await driver.AsBidirectionalContextAsync();
13+
var context = await driver.AsBidirectionalContextAsync();
1414

15-
var screenshot = await browsingContext.CaptureScreenshotAsync();
15+
var screenshot = await context.CaptureScreenshotAsync();
1616

1717
Assert.IsNotNull(screenshot);
1818
Assert.IsNotNull(screenshot.Data);
19-
Assert.IsNotNull(screenshot.AsBytes());
19+
Assert.IsNotNull(screenshot.ToByteArray());
2020
}
2121

2222
[TestMethod]
2323
public async Task CaptureViewportScreenshot()
2424
{
25-
var browsingContext = await driver.AsBidirectionalContextAsync();
25+
var context = await driver.AsBidirectionalContextAsync();
2626

27-
var screenshot = await browsingContext.CaptureScreenshotAsync(new() { Clip = new BoxClipRectangle(5, 5, 10, 10) });
27+
var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new BoxClipRectangle(5, 5, 10, 10) });
2828

2929
Assert.IsNotNull(screenshot);
3030
Assert.IsNotNull(screenshot.Data);
@@ -33,14 +33,14 @@ public async Task CaptureViewportScreenshot()
3333
[TestMethod]
3434
public async Task CaptureElementScreenshot()
3535
{
36-
var browsingContext = await driver.AsBidirectionalContextAsync();
36+
var context = await driver.AsBidirectionalContextAsync();
3737

3838
driver.Url = "https://www.selenium.dev/selenium/web/formPage.html";
3939

40-
var element = (await browsingContext.LocateNodesAsync(Locator.Css("#checky")))[0];
40+
var element = (await context.LocateNodesAsync(Locator.Css("#checky")))[0];
4141

4242
//TODO: ShareId is a type, not string
43-
var screenshot = await browsingContext.CaptureScreenshotAsync(new() { Clip = new ElementClipRectangle(new(element.SharedId)) });
43+
var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new ElementClipRectangle(new(element.SharedId)) });
4444

4545
Assert.IsNotNull(screenshot);
4646
Assert.IsNotNull(screenshot.Data);

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ public async Task CloseTab()
1212
{
1313
await using var bidi = await driver.AsBidirectionalAsync();
1414

15-
var browsingContext = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Tab);
15+
var context = await bidi.CreateContextAsync(BrowsingContextType.Tab);
1616

17-
await browsingContext.CloseAsync();
17+
await context.CloseAsync();
1818
}
1919

2020
[TestMethod]
2121
public async Task CloseWindow()
2222
{
2323
await using var bidi = await driver.AsBidirectionalAsync();
2424

25-
var browsingContext = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Window);
25+
var context = await bidi.CreateContextAsync(BrowsingContextType.Window);
2626

27-
await browsingContext.CloseAsync();
27+
await context.CloseAsync();
2828
}
2929
}

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,50 @@ public async Task OpenNewTab()
1212
{
1313
await using var bidi = await driver.AsBidirectionalAsync();
1414

15-
var browsingContext = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Tab);
15+
var context = await bidi.CreateContextAsync(BrowsingContextType.Tab);
1616

17-
Assert.IsNotNull(browsingContext);
17+
Assert.IsNotNull(context);
1818
}
1919

2020
[TestMethod]
2121
public async Task OpenNewWindow()
2222
{
2323
await using var bidi = await driver.AsBidirectionalAsync();
2424

25-
var browsingContext = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Window);
25+
var context = await bidi.CreateContextAsync(BrowsingContextType.Window);
2626

27-
Assert.IsNotNull(browsingContext);
27+
Assert.IsNotNull(context);
2828
}
2929

3030
[TestMethod]
3131
public async Task OpenTabWithReferenceBrowsingContext()
3232
{
3333
await using var bidi = await driver.AsBidirectionalAsync();
3434

35-
var browsingContext1 = await driver.AsBidirectionalContextAsync();
35+
var context1 = await driver.AsBidirectionalContextAsync();
3636

37-
var browsingContext2 = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Tab, new() { ReferenceContext = browsingContext1 });
37+
var context2 = await bidi.CreateContextAsync(BrowsingContextType.Tab, new() { ReferenceContext = context1 });
3838

39-
Assert.IsNotNull(browsingContext2);
39+
Assert.IsNotNull(context2);
4040
}
4141

4242
[TestMethod]
4343
public async Task OpenWindowWithReferenceBrowsingContext()
4444
{
4545
await using var bidi = await driver.AsBidirectionalAsync();
4646

47-
var browsingContext1 = await driver.AsBidirectionalContextAsync();
47+
var context1 = await driver.AsBidirectionalContextAsync();
4848

49-
var browsingContext2 = await bidi.CreateBrowsingContextAsync(BrowsingContextType.Window, new() { ReferenceContext = browsingContext1 });
49+
var context2 = await bidi.CreateContextAsync(BrowsingContextType.Window, new() { ReferenceContext = context1 });
5050

51-
Assert.IsNotNull(browsingContext2);
51+
Assert.IsNotNull(context2);
5252
}
5353

5454
[TestMethod]
5555
public async Task UseExistingWindowHandle()
5656
{
57-
var browsingContext = await driver.AsBidirectionalContextAsync();
57+
var context = await driver.AsBidirectionalContextAsync();
5858

59-
Assert.IsNotNull(browsingContext);
59+
Assert.IsNotNull(context);
6060
}
6161
}

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public async Task BrowsingContextCreatedEvent()
1515

1616
TaskCompletionSource<BrowsingContextInfo> tcs = new();
1717

18-
await bidi.OnBrowsingContextCreatedAsync(tcs.SetResult);
18+
await bidi.OnContextCreatedAsync(tcs.SetResult);
1919

2020
driver.SwitchTo().NewWindow(OpenQA.Selenium.WindowType.Window);
2121

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ public async Task BrowsingContextDestroyedEvent()
1313
{
1414
await using var bidi = await driver.AsBidirectionalAsync();
1515

16-
var browsingContext = await driver.AsBidirectionalContextAsync();
16+
var context = await driver.AsBidirectionalContextAsync();
1717

1818
TaskCompletionSource<BrowsingContextInfo> tcs = new();
1919

20-
await bidi.OnBrowsingContextDestroyedAsync(tcs.SetResult);
20+
await bidi.OnContextDestroyedAsync(tcs.SetResult);
2121

22-
await browsingContext.CloseAsync();
22+
await context.CloseAsync();
2323

24-
var browsingContextInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
24+
var contextInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
2525

26-
Assert.IsNotNull(browsingContextInfo);
27-
Assert.AreEqual(browsingContext, browsingContextInfo.Context);
28-
Console.WriteLine(browsingContextInfo);
26+
Assert.IsNotNull(contextInfo);
27+
Assert.AreEqual(context, contextInfo.Context);
28+
Console.WriteLine(contextInfo);
2929
}
3030
}

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ partial class BrowsingContextTest
1111
[TestMethod]
1212
public async Task BrowsingContextLoadedEvent()
1313
{
14-
var browsingContext = await driver.AsBidirectionalContextAsync();
14+
var context = await driver.AsBidirectionalContextAsync();
1515

1616
TaskCompletionSource<NavigationInfo> tcs = new();
1717

18-
await browsingContext.OnLoadAsync(tcs.SetResult);
18+
await context.OnLoadAsync(tcs.SetResult);
1919

20-
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
20+
await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
2121

2222
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
2323

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ partial class BrowsingContextTest
1111
[TestMethod]
1212
public async Task DomContentLoadedEvent()
1313
{
14-
var browsingContext = await driver.AsBidirectionalContextAsync();
14+
var context = await driver.AsBidirectionalContextAsync();
1515

1616
TaskCompletionSource<NavigationInfo> tcs = new();
1717

18-
await browsingContext.OnDomContentLoadedAsync(tcs.SetResult);
18+
await context.OnDomContentLoadedAsync(tcs.SetResult);
1919

20-
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
20+
await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
2121

2222
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
2323

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ partial class BrowsingContextTest
1111
[TestMethod]
1212
public async Task FragmentNavigatedEvent()
1313
{
14-
var browsingContext = await driver.AsBidirectionalContextAsync();
14+
var context = await driver.AsBidirectionalContextAsync();
1515

16-
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html", new() { Wait = ReadinessState.Complete });
16+
await context.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html", new() { Wait = ReadinessState.Complete });
1717

1818
TaskCompletionSource<NavigationInfo> tcs = new();
1919

20-
await browsingContext.OnFragmentNavigatedAsync(tcs.SetResult);
20+
await context.OnFragmentNavigatedAsync(tcs.SetResult);
2121

22-
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", new() { Wait = ReadinessState.Complete });
22+
await context.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", new() { Wait = ReadinessState.Complete });
2323

2424
var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
2525

examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ partial class BrowsingContextTest
1111
[TestMethod]
1212
public async Task NavigationStartedEvent()
1313
{
14-
var browsingContext = await driver.AsBidirectionalContextAsync();
14+
var context = await driver.AsBidirectionalContextAsync();
1515

1616
TaskCompletionSource<NavigationInfo> tcs = new();
1717

18-
await browsingContext.OnNavigationStartedAsync(tcs.SetResult);
18+
await context.OnNavigationStartedAsync(tcs.SetResult);
1919

20-
await browsingContext.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
20+
await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });
2121

2222
var info = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
2323

0 commit comments

Comments
 (0)