From e5fdba8ce3d4432dfb347e979445e0eace43a24a Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 20 Jul 2026 23:00:14 +0200 Subject: [PATCH 1/7] [dotnet] Add examples for BiDi W3C Browsing Context Adds .NET examples for the BiDi Browsing Context module: creating, closing, navigating, and traversing history for browsing contexts, capturing screenshots, printing, setting the viewport, handling user prompts, and subscribing to browsing-context events. Credit to @nvborisenko for the original work in #1940. That PR was written against a pre-release shape of the .NET BiDi API (OpenQA.Selenium.BiDi.Modules.BrowsingContext) that has since been restructured upstream, so it no longer builds. This PR carries the same examples updated for the current OpenQA.Selenium.BiDi.BrowsingContext API (Selenium.WebDriver 4.46.0): flattened namespace, ImmutableArray-backed results, and IEventSource.SubscribeAsync instead of OnXAsync event methods. It also fixes a syntax error in BaseTest.cs, enables UseWebSocketUrl unconditionally so BiDi actually works via BaseChromeTest, and fixes two timing races (HandleUserPrompt, NavigateForward/TraverseHistory) found by running the tests against real Chrome/Firefox rather than just compiling them. Co-Authored-By: Claude Sonnet 5 --- examples/dotnet/SeleniumDocs/BaseTest.cs | 1 + .../BrowsingContextTest.Activate.cs | 13 +++ .../BrowsingContextTest.CaptureScreenshot.cs | 40 +++++++++ .../BrowsingContextTest.Close.cs | 24 ++++++ .../BrowsingContextTest.Create.cs | 57 +++++++++++++ ...ontextTest.Event.BrowsingContextCreated.cs | 24 ++++++ ...textTest.Event.BrowsingContextDestroyed.cs | 25 ++++++ ...ContextTest.Event.BrowsingContextLoaded.cs | 24 ++++++ ...wsingContextTest.Event.DomContentLoaded.cs | 24 ++++++ ...singContextTest.Event.FragmentNavigated.cs | 26 ++++++ ...singContextTest.Event.NavigationStarted.cs | 23 ++++++ .../BrowsingContextTest.Event.UserPrompt.cs | 46 +++++++++++ .../BrowsingContextTest.GetTree.cs | 43 ++++++++++ .../BrowsingContextTest.HandleUserPrompt.cs | 35 ++++++++ .../BrowsingContextTest.Navigate.cs | 81 +++++++++++++++++++ .../BrowsingContextTest.Print.cs | 17 ++++ .../BrowsingContextTest.Reload.cs | 20 +++++ .../BrowsingContextTest.SetViewport.cs | 14 ++++ .../BrowsingContext/BrowsingContextTest.cs | 21 +++++ 19 files changed, 558 insertions(+) create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs create mode 100644 examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.cs diff --git a/examples/dotnet/SeleniumDocs/BaseTest.cs b/examples/dotnet/SeleniumDocs/BaseTest.cs index 15b53726fc95..7c3e930db759 100644 --- a/examples/dotnet/SeleniumDocs/BaseTest.cs +++ b/examples/dotnet/SeleniumDocs/BaseTest.cs @@ -36,6 +36,7 @@ public void Cleanup() protected void StartDriver(string browserVersion = null) { ChromeOptions options = new ChromeOptions(); + options.UseWebSocketUrl = true; if (browserVersion != null) { options.BrowserVersion = browserVersion; diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs new file mode 100644 index 000000000000..65fbf2742075 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs @@ -0,0 +1,13 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task Activate() + { + await context.ActivateAsync(); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs new file mode 100644 index 000000000000..d56aa1baeb6c --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs @@ -0,0 +1,40 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task CaptureScreenshot() + { + var screenshot = await context.CaptureScreenshotAsync(); + + Assert.IsNotNull(screenshot); + Assert.IsNotNull(screenshot.Data); + Assert.IsNotNull(screenshot.ToByteArray()); + } + + [TestMethod] + public async Task CaptureViewportScreenshot() + { + var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new BoxClipRectangle(5, 5, 10, 10) }); + + Assert.IsNotNull(screenshot); + Assert.IsNotNull(screenshot.Data); + } + + [TestMethod] + public async Task CaptureElementScreenshot() + { + driver.Url = "https://www.selenium.dev/selenium/web/formPage.html"; + + var element = (await context.LocateNodesAsync(new CssLocator("#checky"))).Nodes[0]; + + var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new ElementClipRectangle(element) }); + + Assert.IsNotNull(screenshot); + Assert.IsNotNull(screenshot.Data); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs new file mode 100644 index 000000000000..3d6fdf677706 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task CloseTab() + { + var context = (await bidi.BrowsingContext.CreateAsync(ContextType.Tab)).Context; + + await context.CloseAsync(); + } + + [TestMethod] + public async Task CloseWindow() + { + var context = (await bidi.BrowsingContext.CreateAsync(ContextType.Window)).Context; + + await context.CloseAsync(); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs new file mode 100644 index 000000000000..ad8da92ee7c0 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs @@ -0,0 +1,57 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task OpenNewTab() + { + var bidi = await driver.AsBiDiAsync(); + + var context = (await bidi.BrowsingContext.CreateAsync(ContextType.Tab)).Context; + + Assert.IsNotNull(context); + } + + [TestMethod] + public async Task OpenNewWindow() + { + var bidi = await driver.AsBiDiAsync(); + + var context = (await bidi.BrowsingContext.CreateAsync(ContextType.Window)).Context; + + Assert.IsNotNull(context); + } + + [TestMethod] + public async Task OpenTabWithReferenceBrowsingContext() + { + var context1 = context; + + var context2 = (await context1.BiDi.BrowsingContext.CreateAsync(ContextType.Tab, new() { ReferenceContext = context1 })).Context; + + Assert.IsNotNull(context2); + } + + [TestMethod] + public async Task OpenWindowWithReferenceBrowsingContext() + { + var context1 = context; + + var context2 = (await context1.BiDi.BrowsingContext.CreateAsync(ContextType.Window, new() { ReferenceContext = context1 })).Context; + + Assert.IsNotNull(context2); + } + + [TestMethod] + public async Task UseExistingWindowHandle() + { + var context = (await bidi.BrowsingContext.GetTreeAsync()).Contexts[0].Context; + + Assert.IsNotNull(context); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs new file mode 100644 index 000000000000..1e68bba2c9e8 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task BrowsingContextCreatedEvent() + { + TaskCompletionSource tcs = new(); + + await bidi.BrowsingContext.ContextCreated.SubscribeAsync(tcs.SetResult); + + driver.SwitchTo().NewWindow(OpenQA.Selenium.WindowType.Window); + + var info = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(info); + Console.WriteLine(info); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs new file mode 100644 index 000000000000..ae9b553de8aa --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs @@ -0,0 +1,25 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task BrowsingContextDestroyedEvent() + { + TaskCompletionSource tcs = new(); + + await bidi.BrowsingContext.ContextDestroyed.SubscribeAsync(tcs.SetResult); + + await context.CloseAsync(); + + var contextInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(contextInfo); + Assert.AreEqual(context, contextInfo.Context); + Console.WriteLine(contextInfo); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs new file mode 100644 index 000000000000..74db7cb4ba11 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task BrowsingContextLoadedEvent() + { + TaskCompletionSource tcs = new(); + + await context.Load.SubscribeAsync(tcs.SetResult); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(navigationInfo); + Console.WriteLine(navigationInfo); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs new file mode 100644 index 000000000000..54c2d3464979 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs @@ -0,0 +1,24 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task DomContentLoadedEvent() + { + TaskCompletionSource tcs = new(); + + await context.DomContentLoaded.SubscribeAsync(tcs.SetResult); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(navigationInfo); + Console.WriteLine(navigationInfo); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs new file mode 100644 index 000000000000..85490de5f814 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs @@ -0,0 +1,26 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task FragmentNavigatedEvent() + { + await context.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html", new() { Wait = ReadinessState.Complete }); + + TaskCompletionSource tcs = new(); + + await context.FragmentNavigated.SubscribeAsync(tcs.SetResult); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", new() { Wait = ReadinessState.Complete }); + + var navigationInfo = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(navigationInfo); + Console.WriteLine(navigationInfo); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs new file mode 100644 index 000000000000..40ce8640324e --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs @@ -0,0 +1,23 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task NavigationStartedEvent() + { + TaskCompletionSource tcs = new(); + + await context.NavigationStarted.SubscribeAsync(tcs.SetResult); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + var info = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(info); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs new file mode 100644 index 000000000000..3b1dd04fecfb --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs @@ -0,0 +1,46 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task UserPromptOpenedEvent() + { + TaskCompletionSource tcs = new(); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); + + // TODO: this event can be a part of context + await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(tcs.SetResult); + + driver.FindElement(By.Id("prompt")).Click(); + + var userPromptOpenedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(userPromptOpenedEventArgs); + Console.WriteLine(userPromptOpenedEventArgs); + } + + [TestMethod] + public async Task UserPromptClosedEvent() + { + TaskCompletionSource tcs = new(); + + await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); + + // TODO: this event can be a part of context + await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(tcs.SetResult); + + driver.FindElement(By.Id("prompt")).Click(); + + var userPromptClosedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + Assert.IsNotNull(userPromptClosedEventArgs); + Console.WriteLine(userPromptClosedEventArgs); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs new file mode 100644 index 000000000000..7bae98923090 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs @@ -0,0 +1,43 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi; +using OpenQA.Selenium.BiDi.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()).Contexts; + + Assert.AreEqual(1, contexts.Length); + Assert.IsNotNull(contexts[0].Children); + Assert.IsTrue(contexts[0].Children.Value.Length >= 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 })).Contexts; + + Assert.AreEqual(1, contexts.Length); + Assert.IsNull(contexts[0].Children, "Context should not contain iframes as children since depth is 0"); + } + + [TestMethod] + public async Task GetAllTopLevelBrowsingContexts() + { + var window = (await bidi.BrowsingContext.CreateAsync(ContextType.Window)).Context; + + var contexts = (await bidi.BrowsingContext.GetTreeAsync()).Contexts; + + Assert.AreEqual(2, contexts.Length); + Assert.AreEqual(contexts[1].Context, window); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs new file mode 100644 index 000000000000..da5c2131c435 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs @@ -0,0 +1,35 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium; +using OpenQA.Selenium.BiDi; +using OpenQA.Selenium.BiDi.BrowsingContext; +using OpenQA.Selenium.Firefox; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task HandleUserPrompt() + { + // temporary use firefox because of chrome automatically handle prompts + using var driver = new FirefoxDriver(new FirefoxOptions() { UseWebSocketUrl = true, UnhandledPromptBehavior = UnhandledPromptBehavior.Ignore }); + + var bidi = await driver.AsBiDiAsync(); + + var context = (await bidi.BrowsingContext.GetTreeAsync()).Contexts[0].Context; + + driver.Url = "https://www.selenium.dev/selenium/web/alerts.html"; + + TaskCompletionSource promptOpened = new(); + + await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(promptOpened.SetResult); + + driver.FindElement(By.Id("prompt-with-default")).Click(); + + await promptOpened.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + await context.HandleUserPromptAsync(new() { Accept = true, UserText = "Selenium automates browsers" }); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs new file mode 100644 index 000000000000..15109eeca837 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs @@ -0,0 +1,81 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task NavigateToUrl() + { + var info = await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + Assert.IsNotNull(info); + Assert.IsNotNull(info.Navigation); + StringAssert.Contains(info.Url, "/bidi/logEntryAdded.html"); + } + + [TestMethod] + public async Task NavigateToUrlWithReadinessState() + { + var info = await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + Assert.IsNotNull(info); + Assert.IsNotNull(info.Navigation); + StringAssert.Contains(info.Url, "/bidi/logEntryAdded.html"); + } + + [TestMethod] + public async Task NavigateBack() + { + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + await context.TraverseHistoryAsync(-1); + + var url = await WaitForUrlAsync("about:blank"); + + Assert.AreEqual("about:blank", url); + } + + [TestMethod] + public async Task NavigateForward() + { + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + await context.TraverseHistoryAsync(-1); + await WaitForUrlAsync("about:blank"); + + await context.TraverseHistoryAsync(1); + var url = await WaitForUrlAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html"); + + Assert.AreEqual("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", url); + } + + private async Task WaitForUrlAsync(string expectedUrl) + { + var deadline = DateTime.UtcNow.AddSeconds(5); + string url; + do + { + url = (await context.GetTreeAsync()).Contexts[0].Url; + if (url == expectedUrl) return url; + await Task.Delay(100); + } while (DateTime.UtcNow < deadline); + + return url; + } + + [TestMethod] + public async Task TraverseHistory() + { + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + await context.TraverseHistoryAsync(-1); + + var url = await WaitForUrlAsync("about:blank"); + + Assert.AreEqual("about:blank", url); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs new file mode 100644 index 000000000000..07056fd63cec --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs @@ -0,0 +1,17 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task PrintPage() + { + var pdf = await context.PrintAsync(new() { PageRanges = [1, 2, 3..5, new(3, 5), 7..] }); + + Assert.IsNotNull(pdf); + Assert.IsNotNull(pdf.Data); + Assert.IsNotNull(pdf.ToByteArray()); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs new file mode 100644 index 000000000000..675b2d36ff81 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task Reload() + { + await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); + + var info = await context.ReloadAsync(); + + Assert.IsNotNull(info); + Assert.IsNotNull(info.Navigation); + StringAssert.Contains(info.Url, "/bidi/logEntryAdded.html"); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs new file mode 100644 index 000000000000..5222cc801033 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs @@ -0,0 +1,14 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +partial class BrowsingContextTest +{ + [TestMethod] + public async Task SetViewport() + { + await context.SetViewportAsync(new() { Viewport = new Viewport(Width: 250, Height: 300), DevicePixelRatio = 5 }); + } +} diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.cs new file mode 100644 index 000000000000..622675d95141 --- /dev/null +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.cs @@ -0,0 +1,21 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OpenQA.Selenium.BiDi; +using System.Threading.Tasks; + +namespace SeleniumDocs.BiDi.BrowsingContext; + +[TestClass] +public partial class BrowsingContextTest : BaseChromeTest +{ + private IBiDi bidi; + + private OpenQA.Selenium.BiDi.BrowsingContext.BrowsingContext context; + + [TestInitialize] + public async Task InitializeBidi() + { + bidi = await driver.AsBiDiAsync(); + + context = (await bidi.BrowsingContext.GetTreeAsync()).Contexts[0].Context; + } +} From 2cdf2b0593fcc2eb238dbac35d57ffb39235c7d2 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 20 Jul 2026 23:15:58 +0200 Subject: [PATCH 2/7] [dotnet] Reference BiDi Browsing Context C# examples in docs (all locales) Adds a CSharp tab, referencing the new examples/dotnet/SeleniumDocs/BiDi/ BrowsingContext example files, to every code tabpane in webdriver/bidi/w3c/browsing_context across en, ja, pt-br, and zh-cn. These locales mirror the English page's tabpane structure exactly, so the same gh-codeblock references apply to each. Line ranges were derived by brace-matching each referenced method body and validated against the current file contents, matching the file's existing convention of pointing at just the illustrative body of each method (excluding the signature and braces). Co-Authored-By: Claude Sonnet 5 --- .../webdriver/bidi/w3c/browsing_context.en.md | 90 +++++++++++++++++++ .../webdriver/bidi/w3c/browsing_context.ja.md | 90 +++++++++++++++++++ .../bidi/w3c/browsing_context.pt-br.md | 90 +++++++++++++++++++ .../bidi/w3c/browsing_context.zh-cn.md | 90 +++++++++++++++++++ 4 files changed, 360 insertions(+) diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md index 3149dbf11f07..a5c0588f4264 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md @@ -19,6 +19,9 @@ Creates a new browsing context in a new window. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L51" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -40,6 +43,9 @@ Creates a new browsing context in a new tab. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L60-L63" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -61,6 +67,9 @@ Creates a browsing context for the existing tab/window to run commands. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L39-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L53-L55" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -83,6 +92,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L52-L57" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L43-L47" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -104,6 +116,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L66-L71" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L33-L37" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -123,6 +138,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L74-L82" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -142,6 +160,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L85-L94" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -163,6 +184,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -184,6 +208,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -203,6 +230,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -222,6 +252,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L138-L155" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs#L9-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -241,6 +274,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L159-L163" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs#L11" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -262,6 +298,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L171-L175" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs#L12-L18" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -281,6 +320,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L222-L230" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs#L16-L33" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -300,6 +342,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L250-L254" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L12-L16" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -319,6 +364,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L261-L270" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L22-L25" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -338,6 +386,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -357,6 +408,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L306-L309" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs#L12" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -377,6 +431,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L319-L324" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs#L11-L15" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -396,6 +453,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L332-L338" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L33-L39" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -415,6 +475,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L344-L354" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L45-L53" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -434,6 +497,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L361-L367" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L73-L79" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -456,6 +522,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L36-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -475,6 +544,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L56-L65" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -494,6 +566,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L83-90" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -513,6 +588,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L99-106" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs#L13-L21" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -531,6 +609,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs#L13-L24" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -550,6 +631,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -568,6 +652,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -586,6 +673,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.18" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L172-L183" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs#L13-L23" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md index 5d493d626358..3b63510ace99 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md @@ -25,6 +25,9 @@ Creates a new browsing context in a new window. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L51" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -46,6 +49,9 @@ Creates a new browsing context in a new tab. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L60-L63" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -67,6 +73,9 @@ Creates a browsing context for the existing tab/window to run commands. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L39-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L53-L55" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -89,6 +98,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L52-L57" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L43-L47" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -110,6 +122,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L66-L71" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L33-L37" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -129,6 +144,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L74-L82" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -148,6 +166,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L85-L94" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -169,6 +190,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -190,6 +214,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -209,6 +236,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -228,6 +258,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L138-L155" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs#L9-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -247,6 +280,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L159-L163" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs#L11" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -268,6 +304,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L171-L175" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs#L12-L18" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -287,6 +326,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L222-L230" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs#L16-L33" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -306,6 +348,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L250-L254" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L12-L16" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -325,6 +370,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L261-L270" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L22-L25" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -344,6 +392,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -363,6 +414,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L306-L309" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs#L12" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -383,6 +437,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L319-L324" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs#L11-L15" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -402,6 +459,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L332-L338" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L33-L39" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -421,6 +481,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L344-L354" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L45-L53" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -440,6 +503,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L361-L367" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L73-L79" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -462,6 +528,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L36-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -481,6 +550,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L56-L65" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -500,6 +572,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L83-90" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -519,6 +594,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L99-106" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs#L13-L21" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -537,6 +615,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs#L13-L24" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -556,6 +637,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -574,6 +658,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -592,6 +679,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.18" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L172-L183" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs#L13-L23" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md index b8530b382e6d..f4913d9772b4 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md @@ -25,6 +25,9 @@ Creates a new browsing context in a new window. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L51" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -46,6 +49,9 @@ Creates a new browsing context in a new tab. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L60-L63" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -67,6 +73,9 @@ Creates a browsing context for the existing tab/window to run commands. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L39-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L53-L55" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -89,6 +98,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L52-L57" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L43-L47" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -110,6 +122,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L66-L71" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L33-L37" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -129,6 +144,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L74-L82" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -148,6 +166,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L85-L94" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -169,6 +190,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -190,6 +214,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -209,6 +236,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -228,6 +258,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L138-L155" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs#L9-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -247,6 +280,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L159-L163" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs#L11" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -268,6 +304,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L171-L175" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs#L12-L18" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -287,6 +326,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L222-L230" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs#L16-L33" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -306,6 +348,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L250-L254" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L12-L16" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -325,6 +370,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L261-L270" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L22-L25" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -344,6 +392,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -363,6 +414,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L306-L309" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs#L12" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -383,6 +437,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L319-L324" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs#L11-L15" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -402,6 +459,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L332-L338" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L33-L39" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -421,6 +481,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L344-L354" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L45-L53" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -440,6 +503,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L361-L367" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L73-L79" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -462,6 +528,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L36-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -481,6 +550,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L56-L65" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -500,6 +572,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L83-90" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -519,6 +594,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L99-106" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs#L13-L21" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -537,6 +615,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs#L13-L24" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -556,6 +637,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -574,6 +658,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -592,6 +679,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.18" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L172-L183" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs#L13-L23" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md index d2c7a6a2fe35..d20ceb5c71df 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md @@ -25,6 +25,9 @@ Creates a new browsing context in a new window. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L51" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -46,6 +49,9 @@ Creates a new browsing context in a new tab. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L60-L63" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -67,6 +73,9 @@ Creates a browsing context for the existing tab/window to run commands. {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L39-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L53-L55" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -89,6 +98,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L52-L57" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L43-L47" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -110,6 +122,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L66-L71" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Create.cs#L33-L37" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -129,6 +144,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L74-L82" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L13-L17" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -148,6 +166,9 @@ The API allows to pass the reference browsing context, which is used to create a {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L85-L94" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L23-L27" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -169,6 +190,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -190,6 +214,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -209,6 +236,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -228,6 +258,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.8" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L138-L155" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Close.cs#L9-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -247,6 +280,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L159-L163" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Activate.cs#L11" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -268,6 +304,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L171-L175" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Reload.cs#L12-L18" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -287,6 +326,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L222-L230" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs#L16-L33" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -306,6 +348,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.13.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L250-L254" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L12-L16" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -325,6 +370,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L261-L270" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L22-L25" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -344,6 +392,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -363,6 +414,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L306-L309" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.SetViewport.cs#L12" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -383,6 +437,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.14.1" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L319-L324" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Print.cs#L11-L15" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -402,6 +459,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L332-L338" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L33-L39" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -421,6 +481,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L344-L354" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L45-L53" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -440,6 +503,9 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< badge-version version="4.16.0" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L361-L367" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Navigate.cs#L73-L79" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -462,6 +528,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L36-L43" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -481,6 +550,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L56-L65" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -500,6 +572,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.10" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L83-90" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs#L13-L22" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -519,6 +594,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L99-106" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs#L13-L21" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -537,6 +615,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs#L13-L24" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -556,6 +637,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -574,6 +658,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.15" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} @@ -592,6 +679,9 @@ This section contains the APIs related to browsing context events. {{< badge-version version="4.18" >}} {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L172-L183" >}} {{< /tab >}} +{{< tab header="CSharp" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs#L13-L23" >}} +{{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} {{< /tab >}} From 550631c33e06bc5fda8f43514b9135c98f72cb43 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 20 Jul 2026 23:36:03 +0200 Subject: [PATCH 3/7] [dotnet] Address Qodo review findings on PR 2735 Fixes real issues flagged by Qodo's automated review, verified against the current commit before applying: - Fix a gh-codeblock line reference broken by this PR's own BaseTest.cs edit: adding `options.UseWebSocketUrl = true;` shifted every subsequent line by one, so the four drivers/_index.*.md pages that reference BaseTest.cs#L48 (the "driver = new ChromeDriver(options);" line) were pointing at a lone closing brace. Updated all four locales to #L49. - Make the BiDi event-subscription examples idempotent: SubscribeAsync handlers used TaskCompletionSource.SetResult, which throws if the same event fires more than once during the subscription window. Switched to TrySetResult (wrapped in a lambda, since TrySetResult's bool return isn't method-group-compatible with the Action the API expects). - Guard CaptureElementScreenshot's node lookup with an assertion before indexing, so a failed locator produces a clear failure message instead of an IndexOutOfRangeException. - Replace the positional `contexts[1]` assertion in GetAllTopLevelBrowsingContexts with a containment check, since GetTreeAsync's ordering isn't a documented contract. Updated the browsing_context.*.md gh-codeblock line ranges for the two files whose line counts changed as a result (CaptureScreenshot.cs, GetTree.cs), across all four locales, and re-verified every dotnet gh-codeblock reference site-wide (736 total) against the actual file contents. Qodo also flagged a "partial accessibility mismatch" (public vs internal partial class declarations) as a compile error requiring action. This is incorrect for this code: `dotnet build` succeeds and all 31 tests pass locally, both before and after this commit; C# allows secondary partial declarations to omit the access modifier without conflict. Not changed. Co-Authored-By: Claude Sonnet 5 --- .../BrowsingContextTest.CaptureScreenshot.cs | 6 ++++-- .../BrowsingContextTest.Event.BrowsingContextCreated.cs | 2 +- .../BrowsingContextTest.Event.BrowsingContextDestroyed.cs | 2 +- .../BrowsingContextTest.Event.BrowsingContextLoaded.cs | 2 +- .../BrowsingContextTest.Event.DomContentLoaded.cs | 2 +- .../BrowsingContextTest.Event.FragmentNavigated.cs | 2 +- .../BrowsingContextTest.Event.NavigationStarted.cs | 2 +- .../BrowsingContextTest.Event.UserPrompt.cs | 4 ++-- .../BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs | 3 ++- .../BrowsingContextTest.HandleUserPrompt.cs | 2 +- .../webdriver/bidi/w3c/browsing_context.en.md | 8 ++++---- .../webdriver/bidi/w3c/browsing_context.ja.md | 8 ++++---- .../webdriver/bidi/w3c/browsing_context.pt-br.md | 8 ++++---- .../webdriver/bidi/w3c/browsing_context.zh-cn.md | 8 ++++---- .../content/documentation/webdriver/drivers/_index.en.md | 2 +- .../content/documentation/webdriver/drivers/_index.ja.md | 2 +- .../documentation/webdriver/drivers/_index.pt-br.md | 2 +- .../documentation/webdriver/drivers/_index.zh-cn.md | 2 +- 18 files changed, 35 insertions(+), 32 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs index d56aa1baeb6c..728cb9f0f8da 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs @@ -30,9 +30,11 @@ public async Task CaptureElementScreenshot() { driver.Url = "https://www.selenium.dev/selenium/web/formPage.html"; - var element = (await context.LocateNodesAsync(new CssLocator("#checky"))).Nodes[0]; + var nodes = (await context.LocateNodesAsync(new CssLocator("#checky"))).Nodes; - var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new ElementClipRectangle(element) }); + Assert.IsTrue(nodes.Length > 0, "Expected to locate #checky"); + + var screenshot = await context.CaptureScreenshotAsync(new() { Clip = new ElementClipRectangle(nodes[0]) }); Assert.IsNotNull(screenshot); Assert.IsNotNull(screenshot.Data); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs index 1e68bba2c9e8..303213eeed4a 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextCreated.cs @@ -12,7 +12,7 @@ public async Task BrowsingContextCreatedEvent() { TaskCompletionSource tcs = new(); - await bidi.BrowsingContext.ContextCreated.SubscribeAsync(tcs.SetResult); + await bidi.BrowsingContext.ContextCreated.SubscribeAsync(args => tcs.TrySetResult(args)); driver.SwitchTo().NewWindow(OpenQA.Selenium.WindowType.Window); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs index ae9b553de8aa..4940a9c01204 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextDestroyed.cs @@ -12,7 +12,7 @@ public async Task BrowsingContextDestroyedEvent() { TaskCompletionSource tcs = new(); - await bidi.BrowsingContext.ContextDestroyed.SubscribeAsync(tcs.SetResult); + await bidi.BrowsingContext.ContextDestroyed.SubscribeAsync(args => tcs.TrySetResult(args)); await context.CloseAsync(); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs index 74db7cb4ba11..3a895c8618a7 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.BrowsingContextLoaded.cs @@ -12,7 +12,7 @@ public async Task BrowsingContextLoadedEvent() { TaskCompletionSource tcs = new(); - await context.Load.SubscribeAsync(tcs.SetResult); + await context.Load.SubscribeAsync(args => tcs.TrySetResult(args)); await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs index 54c2d3464979..5eb5116b2668 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.DomContentLoaded.cs @@ -12,7 +12,7 @@ public async Task DomContentLoadedEvent() { TaskCompletionSource tcs = new(); - await context.DomContentLoaded.SubscribeAsync(tcs.SetResult); + await context.DomContentLoaded.SubscribeAsync(args => tcs.TrySetResult(args)); await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs index 85490de5f814..9678b55aa829 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.FragmentNavigated.cs @@ -14,7 +14,7 @@ public async Task FragmentNavigatedEvent() TaskCompletionSource tcs = new(); - await context.FragmentNavigated.SubscribeAsync(tcs.SetResult); + await context.FragmentNavigated.SubscribeAsync(args => tcs.TrySetResult(args)); await context.NavigateAsync("https://www.selenium.dev/selenium/web/linked_image.html#linkToAnchorOnThisPage", new() { Wait = ReadinessState.Complete }); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs index 40ce8640324e..760e55e6b91d 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.NavigationStarted.cs @@ -12,7 +12,7 @@ public async Task NavigationStartedEvent() { TaskCompletionSource tcs = new(); - await context.NavigationStarted.SubscribeAsync(tcs.SetResult); + await context.NavigationStarted.SubscribeAsync(args => tcs.TrySetResult(args)); await context.NavigateAsync("https://www.selenium.dev/selenium/web/bidi/logEntryAdded.html", new() { Wait = ReadinessState.Complete }); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs index 3b1dd04fecfb..5a5b0aaee483 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs @@ -16,7 +16,7 @@ public async Task UserPromptOpenedEvent() await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); // TODO: this event can be a part of context - await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(tcs.SetResult); + await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(args => tcs.TrySetResult(args)); driver.FindElement(By.Id("prompt")).Click(); @@ -34,7 +34,7 @@ public async Task UserPromptClosedEvent() await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); // TODO: this event can be a part of context - await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(tcs.SetResult); + await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(args => tcs.TrySetResult(args)); driver.FindElement(By.Id("prompt")).Click(); diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs index 7bae98923090..648be2566d69 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium.BiDi; using OpenQA.Selenium.BiDi.BrowsingContext; +using System.Linq; using System.Threading.Tasks; namespace SeleniumDocs.BiDi.BrowsingContext; @@ -38,6 +39,6 @@ public async Task GetAllTopLevelBrowsingContexts() var contexts = (await bidi.BrowsingContext.GetTreeAsync()).Contexts; Assert.AreEqual(2, contexts.Length); - Assert.AreEqual(contexts[1].Context, window); + Assert.IsTrue(contexts.Any(c => c.Context == window)); } } diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs index da5c2131c435..4ec5ded7075d 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.HandleUserPrompt.cs @@ -24,7 +24,7 @@ public async Task HandleUserPrompt() TaskCompletionSource promptOpened = new(); - await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(promptOpened.SetResult); + await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(args => promptOpened.TrySetResult(args)); driver.FindElement(By.Id("prompt-with-default")).Click(); diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md index a5c0588f4264..122b996ab56f 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md @@ -185,7 +185,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L14-L20" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -209,7 +209,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L26-L31" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -231,7 +231,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L37-L42" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -387,7 +387,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L40" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md index 3b63510ace99..f6ec602ec0e0 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md @@ -191,7 +191,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L14-L20" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -215,7 +215,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L26-L31" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -237,7 +237,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L37-L42" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -393,7 +393,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L40" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md index f4913d9772b4..88c61f5dae4e 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md @@ -191,7 +191,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L14-L20" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -215,7 +215,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L26-L31" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -237,7 +237,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L37-L42" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -393,7 +393,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L40" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md index d20ceb5c71df..dd50e51c2c02 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md @@ -191,7 +191,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L97-L110" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L13-L19" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L14-L20" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -215,7 +215,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L113-L125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L25-L30" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L26-L31" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -237,7 +237,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L128-L135" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L36-L41" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.GetTree.cs#L37-L42" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -393,7 +393,7 @@ Provides a tree of all browsing contexts descending from the parent browsing con {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextTest.java#L277-L282" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L38" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.CaptureScreenshot.cs#L31-L40" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/_index.en.md b/website_and_docs/content/documentation/webdriver/drivers/_index.en.md index 054ff1556704..f7ed6b0f2790 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/_index.en.md +++ b/website_and_docs/content/documentation/webdriver/drivers/_index.en.md @@ -35,7 +35,7 @@ on the local machine. {{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9" >}} {{% /tab %}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L48" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L49" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L14" >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/_index.ja.md b/website_and_docs/content/documentation/webdriver/drivers/_index.ja.md index 6868a1776263..993422a44e0b 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/_index.ja.md +++ b/website_and_docs/content/documentation/webdriver/drivers/_index.ja.md @@ -32,7 +32,7 @@ weight: 3 {{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9" >}} {{% /tab %}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L48" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L49" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L14" >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/_index.pt-br.md b/website_and_docs/content/documentation/webdriver/drivers/_index.pt-br.md index a2783c16e351..76bb5d7e3765 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/_index.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/drivers/_index.pt-br.md @@ -33,7 +33,7 @@ O principal argumento exclusivo para iniciar um driver local inclui informaçõe {{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9" >}} {{% /tab %}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L48" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L49" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L14" >}} diff --git a/website_and_docs/content/documentation/webdriver/drivers/_index.zh-cn.md b/website_and_docs/content/documentation/webdriver/drivers/_index.zh-cn.md index ce2958db1f9e..6dd9fc198f4e 100644 --- a/website_and_docs/content/documentation/webdriver/drivers/_index.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/drivers/_index.zh-cn.md @@ -33,7 +33,7 @@ weight: 3 {{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9" >}} {{% /tab %}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L48" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BaseTest.cs#L49" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L14" >}} From 1d4d6792362fa57387d11a2a8271d0cf5e79425e Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 20 Jul 2026 23:55:59 +0200 Subject: [PATCH 4/7] [dotnet] Clarify why UserPromptClosedEvent needs no explicit close Qodo's re-review (after the previous fix commit) flagged that UserPromptClosedEvent waits for the closed event without ever explicitly closing the prompt, calling it implicit/behavior-dependent. Tried making it deterministic by explicitly calling HandleUserPromptAsync after waiting for UserPromptOpened. That actually broke the test: OpenQA.Selenium.BiDi.BiDiException: no such alert: No dialog is showing. Chrome's default unhandledPromptBehavior ("dismiss and notify") already closes the prompt on its own, faster than an explicit BiDi call can act on it. This is a known, deliberate constraint in this codebase already: HandleUserPrompt.cs uses Firefox specifically ("temporary use firefox because of chrome automatically handle prompts") whenever the example needs to demonstrate an explicit close. Reverted the explicit-close attempt and documented the actual mechanism in a comment instead: Chrome's own auto-dismiss is what raises the event here, with a pointer to HandleUserPrompt.cs for the explicit-close pattern. Verified the full 31-test suite passes with this change, and updated the shifted gh-codeblock line reference in all four locales. Qodo's other two remaining findings on this PR were addressed in the previous commit's message: "Partial accessibility mismatch" is a false positive (dotnet build and all tests pass with this exact partial-class pattern), and "Two browsers started" is a pre-existing structural choice from the original PR (#1940), not introduced here. Co-Authored-By: Claude Sonnet 5 --- .../BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs | 3 +++ .../documentation/webdriver/bidi/w3c/browsing_context.en.md | 2 +- .../documentation/webdriver/bidi/w3c/browsing_context.ja.md | 2 +- .../documentation/webdriver/bidi/w3c/browsing_context.pt-br.md | 2 +- .../documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs index 5a5b0aaee483..db956dfde494 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs @@ -34,6 +34,9 @@ public async Task UserPromptClosedEvent() await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); // TODO: this event can be a part of context + // Chrome's default unhandled prompt behavior (dismiss and notify) closes the + // prompt automatically, which is what raises this event; see HandleUserPrompt.cs + // for an example that closes a prompt explicitly instead. await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(args => tcs.TrySetResult(args)); driver.FindElement(By.Id("prompt")).Click(); diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md index 122b996ab56f..94d0c5354c7b 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md @@ -653,7 +653,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md index f6ec602ec0e0..07fb5c5ebbaa 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md index 88c61f5dae4e..509424faa2c3 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md index dd50e51c2c02..cd400133e44a 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L44" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} From 59768323020fd2bfd59364e637ae36434ea1ff26 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Tue, 21 Jul 2026 11:03:24 +0200 Subject: [PATCH 5/7] [dotnet] Make UserPromptClosedEvent's prompt close deterministic Implements Qodo's suggested remediation in full this time: subscribe to UserPromptOpened, wait for it, then explicitly call HandleUserPromptAsync, tolerating the case where Chrome's default unhandled-prompt behavior has already closed the dialog (BiDiException: "no such alert"). This demonstrates the explicit-close pattern while staying robust under Chrome's race, verified by running the test 3x plus the full 31-test suite with no flakiness. BiDiException carries no structured error code (just a message), so the catch matches on message text rather than a dedicated exception type. Adding `using OpenQA.Selenium.BiDi;` (needed for BiDiException) shifted every line in the file by one, so both UserPromptOpenedEvent and UserPromptClosedEvent's gh-codeblock references needed updating, across all four locales. Co-Authored-By: Claude Sonnet 5 --- .../BrowsingContextTest.Event.UserPrompt.cs | 26 ++++++++++++++----- .../webdriver/bidi/w3c/browsing_context.en.md | 4 +-- .../webdriver/bidi/w3c/browsing_context.ja.md | 4 +-- .../bidi/w3c/browsing_context.pt-br.md | 4 +-- .../bidi/w3c/browsing_context.zh-cn.md | 4 +-- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs index db956dfde494..0386a04cee9c 100644 --- a/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs +++ b/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium; +using OpenQA.Selenium.BiDi; using OpenQA.Selenium.BiDi.BrowsingContext; using System; using System.Threading.Tasks; @@ -29,19 +30,30 @@ public async Task UserPromptOpenedEvent() [TestMethod] public async Task UserPromptClosedEvent() { - TaskCompletionSource tcs = new(); + TaskCompletionSource opened = new(); + TaskCompletionSource closed = new(); await context.NavigateAsync("https://www.selenium.dev/selenium/web/alerts.html", new() { Wait = ReadinessState.Complete }); - // TODO: this event can be a part of context - // Chrome's default unhandled prompt behavior (dismiss and notify) closes the - // prompt automatically, which is what raises this event; see HandleUserPrompt.cs - // for an example that closes a prompt explicitly instead. - await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(args => tcs.TrySetResult(args)); + // TODO: these events can be a part of context + await bidi.BrowsingContext.UserPromptOpened.SubscribeAsync(args => opened.TrySetResult(args)); + await bidi.BrowsingContext.UserPromptClosed.SubscribeAsync(args => closed.TrySetResult(args)); driver.FindElement(By.Id("prompt")).Click(); - var userPromptClosedEventArgs = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5)); + await opened.Task.WaitAsync(TimeSpan.FromSeconds(5)); + + try + { + // Chrome's default unhandled prompt behavior may already have closed the + // prompt by this point; tolerate that instead of treating it as a failure. + await context.HandleUserPromptAsync(new() { Accept = true }); + } + catch (BiDiException ex) when (ex.Message.Contains("no such alert")) + { + } + + var userPromptClosedEventArgs = await closed.Task.WaitAsync(TimeSpan.FromSeconds(5)); Assert.IsNotNull(userPromptClosedEventArgs); Console.WriteLine(userPromptClosedEventArgs); diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md index 94d0c5354c7b..3baacf3e248e 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.en.md @@ -632,7 +632,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L15-L27" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -653,7 +653,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L33-L59" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md index 07fb5c5ebbaa..0107b1ca0637 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.ja.md @@ -638,7 +638,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L15-L27" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L33-L59" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md index 509424faa2c3..60416a648ae7 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.pt-br.md @@ -638,7 +638,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L15-L27" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L33-L59" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} diff --git a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md index cd400133e44a..ce409d45b435 100644 --- a/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/bidi/w3c/browsing_context.zh-cn.md @@ -638,7 +638,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L115-125" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L14-L26" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L15-L27" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} @@ -659,7 +659,7 @@ This section contains the APIs related to browsing context events. {{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi/BrowsingContextInspectorTest.java#L152-165" >}} {{< /tab >}} {{< tab header="CSharp" >}} -{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L32-L47" >}} +{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/BiDi/BrowsingContext/BrowsingContextTest.Event.UserPrompt.cs#L33-L59" >}} {{< /tab >}} {{< tab header="Ruby" >}} {{< badge-code >}} From cd561d66a0b3e95226d0c563fd9f6c79e7c01def Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 22 Jul 2026 13:33:56 +0200 Subject: [PATCH 6/7] [dotnet] Use a fresh subdirectory for FirefoxTest.SetProfileLocation Matches the Java, Python, and Ruby examples, which all create a dedicated temp subdirectory (Files.createTempDirectory, tempfile.TemporaryDirectory, Dir.mktmpdir) rather than passing the shared OS temp root itself as --profile-root. The shared root is the likely cause of geckodriver exiting immediately on Windows CI (consistently failing on trunk's own scheduled runs, unrelated to any specific PR). Also reorders Cleanup() to quit the driver before deleting the directory, since deleting while Firefox still holds files open in it raced intermittently. Co-Authored-By: Claude Sonnet 5 --- examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs index 3b6d0e6cd65f..955a9de702f0 100644 --- a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs +++ b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs @@ -23,11 +23,11 @@ public void Cleanup() { File.Delete(_logLocation); } - if (_tempPath != null && File.Exists(_tempPath)) + driver.Quit(); + if (_tempPath != null && Directory.Exists(_tempPath)) { - File.Delete(_tempPath); + Directory.Delete(_tempPath, true); } - driver.Quit(); } [TestMethod] @@ -183,9 +183,9 @@ private string GetLogLocation() private string GetTempDirectory() { - if (string.IsNullOrEmpty(_tempPath) && !File.Exists(_tempPath)) + if (string.IsNullOrEmpty(_tempPath)) { - _tempPath = Path.GetTempPath(); + _tempPath = Directory.CreateTempSubdirectory("profile-").FullName + Path.DirectorySeparatorChar; } return _tempPath; From 39ff8cb204ec1a9d681991e16df0b230fd5d50b8 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 22 Jul 2026 14:47:17 +0200 Subject: [PATCH 7/7] [dotnet] Drop trailing separator from ProfileRoot, verify by directory listing The previous fix still failed on Windows CI with the identical crash ("Driver service process exited unexpectedly before initialization completed"), and every other FirefoxDriver launch in the same run succeeded, isolating the problem to the ProfileRoot value itself rather than to sharing vs. not sharing the OS temp root. Both the original code and the previous fix left a trailing separator on that path (Windows' Path.GetTempPath() already ends in one, and the prior fix re-added one explicitly), which is a known Windows command-line quoting hazard when a backslash immediately precedes a closing quote. Stop building a path with a trailing separator, and switch the assertion to list GetTempDirectory()'s contents and check the profile's leaf directory name is among them, mirroring Python's `profile_name in os.listdir(temp_dir)` and Ruby's substring-based check instead of exact string reconstruction that assumed a specific separator style. Co-Authored-By: Claude Sonnet 5 --- examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs index 955a9de702f0..8c40a04f4411 100644 --- a/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs +++ b/examples/dotnet/SeleniumDocs/Browsers/FirefoxTest.cs @@ -123,10 +123,10 @@ public void SetProfileLocation() driver = new FirefoxDriver(service); - string profile = (string)driver.Capabilities.GetCapability("moz:profile"); - string[] directories = profile.Split("/"); - var dirName = directories.Last(); - Assert.AreEqual(GetTempDirectory() + dirName, profile); + string profile = ((string)driver.Capabilities.GetCapability("moz:profile")).Replace('\\', '/'); + var dirName = profile.Split('/').Last(); + var profileDirectories = Directory.GetDirectories(GetTempDirectory()).Select(Path.GetFileName); + Assert.IsTrue(profileDirectories.Contains(dirName)); } [TestMethod] @@ -185,7 +185,7 @@ private string GetTempDirectory() { if (string.IsNullOrEmpty(_tempPath)) { - _tempPath = Directory.CreateTempSubdirectory("profile-").FullName + Path.DirectorySeparatorChar; + _tempPath = Directory.CreateTempSubdirectory("profile-").FullName; } return _tempPath;