Skip to content

[dotnet] Add examples for BiDi W3C Browsing Context #1940

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

Draft
wants to merge 24 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Make it even shorter
  • Loading branch information
nvborisenko committed Sep 16, 2024
commit c3d85b947a59a4962f66dde93f78525dc709c234
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task Activate()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

await context.ActivateAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task CaptureScreenshot()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

var screenshot = await context.CaptureScreenshotAsync();

Expand All @@ -22,7 +22,7 @@ public async Task CaptureScreenshot()
[TestMethod]
public async Task CaptureViewportScreenshot()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new BoxClipRectangle(5, 5, 10, 10) });

Expand All @@ -33,7 +33,7 @@ public async Task CaptureViewportScreenshot()
[TestMethod]
public async Task CaptureElementScreenshot()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task CloseTab()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var context = await bidi.CreateContextAsync(ContextType.Tab);

Expand All @@ -20,7 +20,7 @@ public async Task CloseTab()
[TestMethod]
public async Task CloseWindow()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var context = await bidi.CreateContextAsync(ContextType.Window);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task OpenNewTab()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var context = await bidi.CreateContextAsync(ContextType.Tab);

Expand All @@ -20,7 +20,7 @@ public async Task OpenNewTab()
[TestMethod]
public async Task OpenNewWindow()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var context = await bidi.CreateContextAsync(ContextType.Window);

Expand All @@ -30,7 +30,7 @@ public async Task OpenNewWindow()
[TestMethod]
public async Task OpenTabWithReferenceBrowsingContext()
{
var context1 = await driver.AsBiDirectionalContextAsync();
var context1 = await driver.AsBiDiContextAsync();

var context2 = await context1.BiDi.CreateContextAsync(ContextType.Tab, new() { ReferenceContext = context1 });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if context1 can expose CreateContextAsync method, which implicitly sets ReferenceContext to the context1


Expand All @@ -40,7 +40,7 @@ public async Task OpenTabWithReferenceBrowsingContext()
[TestMethod]
public async Task OpenWindowWithReferenceBrowsingContext()
{
var context1 = await driver.AsBiDirectionalContextAsync();
var context1 = await driver.AsBiDiContextAsync();

var context2 = await context1.BiDi.CreateContextAsync(ContextType.Window, new() { ReferenceContext = context1 });

Expand All @@ -50,7 +50,7 @@ public async Task OpenWindowWithReferenceBrowsingContext()
[TestMethod]
public async Task UseExistingWindowHandle()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

Assert.IsNotNull(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task BrowsingContextCreatedEvent()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

TaskCompletionSource<BrowsingContextInfo> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ partial class BrowsingContextTest
[TestMethod]
public async Task BrowsingContextDestroyedEvent()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<BrowsingContextInfo> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task BrowsingContextLoadedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<NavigationInfo> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task DomContentLoadedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<NavigationInfo> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task FragmentNavigatedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task NavigationStartedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<NavigationInfo> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task UserPromptOpenedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<UserPromptOpenedEventArgs> tcs = new();

Expand All @@ -32,7 +32,7 @@ public async Task UserPromptOpenedEvent()
[TestMethod]
public async Task UserPromptClosedEvent()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

TaskCompletionSource<UserPromptClosedEventArgs> tcs = new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task GetBrowsingContextTree()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

await context.NavigateAsync("https://www.selenium.dev/selenium/web/iframes.html", new() { Wait = ReadinessState.Complete });

Expand All @@ -24,7 +24,7 @@ public async Task GetBrowsingContextTree()
[TestMethod]
public async Task GetBrowsingContextTreeWithDepth()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

await context.NavigateAsync("https://www.selenium.dev/selenium/web/iframes.html", new() { Wait = ReadinessState.Complete });

Expand All @@ -37,7 +37,7 @@ public async Task GetBrowsingContextTreeWithDepth()
[TestMethod]
public async Task GetAllTopLevelBrowingContexts()
{
await using var bidi = await driver.AsBiDirectionalAsync();
await using var bidi = await driver.AsBiDiAsync();

var window = await bidi.CreateContextAsync(ContextType.Window);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task HandleUserPrompt()
// temporary use firefox because of chrome automatically handle prompts
using var driver = new FirefoxDriver(new FirefoxOptions() { UseWebSocketUrl = true });

var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

driver.Url = "https://www.selenium.dev/selenium/web/alerts.html";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task NavigateToUrl()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

var info = await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html");

Expand All @@ -22,7 +22,7 @@ public async Task NavigateToUrl()
[TestMethod]
public async Task NavigateToUrlWithReadinessState()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

var info = await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete });

Expand All @@ -34,7 +34,7 @@ public async Task NavigateToUrlWithReadinessState()
[TestMethod]
public async Task NavigateBack()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand All @@ -48,7 +48,7 @@ public async Task NavigateBack()
[TestMethod]
public async Task NavigateForward()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand All @@ -64,7 +64,7 @@ public async Task NavigateForward()
[TestMethod]
public async Task TraverseHistory()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task PrintPage()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

var pdf = await context.PrintAsync(new() { PageRanges = [1, 2, 3..5, new(3, 5), 7..] });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task Reload()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ partial class BrowsingContextTest
[TestMethod]
public async Task SetViewport()
{
var context = await driver.AsBiDirectionalContextAsync();
var context = await driver.AsBiDiContextAsync();

await context.SetViewportAsync(new() { Viewport = new(Width: 250, Height: 300), DevicePixelRatio = 5 });
}
Expand Down
2 changes: 1 addition & 1 deletion examples/dotnet/SeleniumDocs/SeleniumDocs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="Selenium.Support" Version="4.25.0-nightly202409150847" />
<PackageReference Include="Selenium.WebDriver" Version="4.25.0-nightly202409160013" />
<PackageReference Include="Selenium.WebDriver" Version="4.25.0-nightly202409160014" />
</ItemGroup>

<ItemGroup>
Expand Down